Extension:WikiTex

Adding the &lt;wikitex&gt; ... &lt;/wikitex&gt; tags for an easier entry of mathematical formulas.

Problems with the standard &lt;math&gt; tag

 * too much to type, error prone (&lt;math&gt;x&lt;/math&gt; rather than $x$)
 * slow to generate the result
 * white background (rather than transparent)
 * no proper vertical alignmentd
 * smart syntax checker which knows better than I do.

This formula $$\frac{1}{\displaystyle1+\frac{1}{\displaystyle 1+\sqrt{5}}}$$ is on a non-white background and aligned badly. While one can change formula background to transparent by hacking the helper function, it requires another round by the sloooow convert program.

What Extension:WikiTex offers

 * math text is entered between $ symbols
 * fast turnaround (using plain TeX -&gt; dvipng)
 * transparent background
 * proper vertical alignment (almost)
 * displayed formulas between $$ and $$
 * user costumizable TeX definition files

Caveats

 * no fancy things, all math is a picture
 * unfriendly error messages ( syntax error)
 * easy littering: pictures of erased math text remain around
 * possible formatting problems with new lines; certain extensions might not work properly (due to the recursive call of wiki formatting)
 * tested on linux only

Parser extension tags
This extension adds two tags. The main additional tag is &lt;wikitex&gt; which indicates that from here math text is entered between $..$. Internally math text is wrapped inside &lt;tex&gt; tags, but this can also be used directly. The extension supports certain attributes, such as dpi=100 to make smaller images, or include="Math:Mycommands" to automatically include your TeX macros.

Documentation
Full documentation is in Extension:WikiTex/Documentation.

How to use it
Use &lt;wikitex&gt; and &lt;/wikitex&gt; to enclose the part of the page (maybe the all page) on which you want to use the usual math editing: &lt;wikitex&gt; Let $Q$ be any finite set, and $\mathcal B=2^Q$ be the collection of the subsets of $Q$. Let $f:\mathcal B\rightarrow \mathbb R$ be a function assigning real numbers to the subsets of $Q$ and suppose $f$ satisfies the following conditions: :(i) $f(A)\ge 0$ for all $A\subseteq Q$, $f(\emptyset)=0$, :(ii) $f$ is monotone, i.e. if $A\subseteq B\subseteq Q$ then $f(A)\le f(B)$, :(iii) $f$ is submodular, i.e. if $A$ and $B$ are different subsets of $Q$ then $$f(A)+f(B)\ge f(A\cap B) + f(A\cup B).\eqno{(2)}$$ &lt;/wikitex&gt; Beware: formulas are typeset with plain TeX with some predefined commands (such as \mathcal or \mathbb above). LaTeX constructs do not work.

Formula numbers
Displayed formulas might have formula numbers. They should come inside the $$ signs, and it should be the argument of the TeX macro \eqno{...}: $$f(A)+f(B)\ge f(A\cap B) + f(A\cup B). \eqno{(2)}$$ Be default, formula numbers appear on the right of the formula (but can be on the left when changing the appropriate style), and are not part of the formula. $$a_2^3$$

Installation

 * 1) You need the standard  &lt;math&gt; tag enabled and working
 * 2) You need an external worker program which transforms plain tex files into pictures and returns certain status information.
 * 3) If your wiki was configured with  math, then probably TeX was installed. Otherwise you need to install TeX as well.
 * 4) Install dvipng, a fast dvi bitmap converter program.
 * 5) Copy the supplied shell program, or something similar, into /usr/local/bin/texconvert, or change the name and/or location in WikiTex.php.
 * 6) Install the supplied WikiTex.php program into the extensions directory of your wiki.
 * 7) Edit MediaWiki:Common.css which sets how displayed formulas are shown.
 * 8) Edit MediaWiki:TexInclude which contains some standard TeX macros.
 * 9) Enjoy

Details a and source are in Extension:WikiTex/Installation.