Help:Formula

TeX
MediaWiki uses TeX markup for mathematical formulae. It generates either PNG images or simple HTML markup, depending on user preferences and the complexity of the expression. In the future, as more browsers are smarter, it will be able to generate enhanced HTML or even MathML in many cases.

Math markup goes inside  $$ ... $$ . The edit toolbar has a button for this.

The PNG images are black on white (not transparent). These colors, as well as font sizes and types, are independent of browser settings or css. Font sizes and types will often deviate from what HTML renders. The css selector of the images is img.tex.

In the case of a non-white page background, the white background of the formula effectively highlights it, which can be an advantage or a disadvantage.

One may want to avoid using TeX markup as part of a line of regular text, as the formulae don't align properly and the font size, as said, usually does not match.

The alt attribute of the TeX images (the text that shows up in the hover box) is the wikitext that produced them, excluding the $$ and $$.

Discussion, bug reports and feature requests should go to the Wikitech-l mailing list. These can also be filed on MediaZilla under MediaWiki extensions.

General
Spaces and newlines are ignored. Apart from function and operator names, as is customary in mathematics for variables, letters are in italics; digits are not. For other text, to avoid being rendered in italics like variables, use :   gives $$\mbox{abc}$$

Line breaks help keep the wikitext clear, for instance, a line break after each term or matrix row.

Functions, symbols, special characters
For producing special characters without math tags, see Help:Special characters.

Comparison:
 * &amp;alpha; gives &alpha;, $$\alpha$$ gives $$\alpha$$ ("&amp;" and ";" vs. "\", in this case the same code word "alpha"
 * &amp;radic;2 gives &radic;2, $$\sqrt{2}$$ gives $$\sqrt{2}$$ (the same difference as above, but also another code word, "radic" vs. "sqrt"; in TeX braces)
 * &amp;radic;(1-e&amp;sup2;) gives &radic;(1-e&sup2;), $$\sqrt{1-e^2}$$ gives $$\sqrt{1-e^2}$$ (parentheses vs. braces, " e " vs. "e", "&amp;sup2;" vs. "^2")

Parenthesizing big expressions, brackets, bars
You can use various delimiters with \left and \right:

Spacing
Note that TeX handles most spacing automatically, but you may sometimes want manual control.

Align with normal text flow
Due to the default css

img.tex { vertical-align: middle; }

an inline expression like $$\int_{-N}^{N} e^x\, dx$$ should look good.

Forced PNG rendering
To force the formula to render as PNG, add \, (small space) at the end of the formula (where it is not rendered). This will force PNG if the user is in "HTML if simple" mode, but not for "HTML if possible" mode (math rendering settings in preferences).

You can also use \,\! (small space and negative space, which cancel out) anywhere inside the math tags. This does force PNG even in "HTML if possible" mode, unlike \,.

This could be useful to keep the rendering of formulae in a proof consistent, for example, or to fix formulae that render incorrectly in HTML (at one time, a^{2+2} rendered with an extra underscore), or to demonstrate how something is rendered when it would normally show up as HTML (as in the examples above).

For instance:

This has been tested with most of the formulae on this page, and seems to work perfectly.

You might want to include a comment in the HTML so people don't "correct" the formula by removing it:



Examples
$$\frac{2}{3-x} = \frac{3}{2-x}$$

$$\left(3-x\right) \times \left( \frac{2}{3-x} \right) = \left(3-x\right) \times \left( \frac{3}{2-x} \right)$$

$$2 = \left(3-x\right) \times \left( \frac{3}{2-x} \right)$$

$$2 = \left( \frac{\left(3-x\right) \times 3}{2-x} \right)$$

$$2 = \left( \frac{9-3x}{2-x} \right)$$

$$2 \times \left(2-x\right) = \left(2-x\right) \times \left( \frac{9-3x}{2-x} \right)$$

$$2 \times \left(2-x\right) = \frac{\left(2-x\right) \times \left(9-3x\right)}{2-x}$$

$$2 \times \left(2-x\right) = 9-3x \!$$

$$4-2x = 9-3x \!$$

$$-2x+3x = 9-4 \!$$

$$x = 5 \!$$