Help:Formula
Contents
 1 TeX
 2 General
 3 Functions, symbols, special characters
 4 Subscripts, superscripts, integrals
 5 Fractions, matrices, multilines
 6 Fonts
 7 Parenthesizing big expressions, brackets, bars
 8 Spacing
 9 Align with normal text flow
 10 Forced PNG rendering
 11 Examples
 12 See also
 13 External Links
 14 Wikinewsspecific content and links to other help pages
TeX[edit]
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 <math> ... </math>. 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 nonwhite 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 <math> and </math>.
Discussion, bug reports and feature requests should go to the Wikitechl mailing list. These can also be filed on MediaZilla under MediaWiki extensions.
General[edit]
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 \mbox
: <math>\mbox{abc}</math>
gives
Line breaks help keep the wikitext clear, for instance, a line break after each term or matrix row.
Functions, symbols, special characters[edit]
For producing special characters without math tags, see Help:Special characters.
Comparison:
 α gives α, <math>\alpha</math> gives ("&" and ";" vs. "\", in this case the same code word "alpha"
 √2 gives √2, <math>\sqrt{2}</math> gives (the same difference as above, but also another code word, "radic" vs. "sqrt"; in TeX braces)
 √(1e²) gives √(1e²), <math>\sqrt{1e^2}</math> gives (parentheses vs. braces, "''e''" vs. "e", "²" vs. "^2")
Feature  Syntax  How it looks rendered 

std. functions (good)  \sin x + \ln y +\operatorname{sgn} z  
std. functions (wrong)  sin x + ln y + sgn z  
Modular arithm.  s_k \equiv 0 \pmod{m}  
Derivatives  \nabla \partial x dx \dot x \ddot y  
Sets  \forall x \not\in \empty \varnothing \subseteq A \cap \bigcap B \cup \bigcup \exists \{x,y\} \times C  
Logic  p \land \bar{q} \to p\lor \lnot q  
Root  \sqrt{2}\approx 1.4  
\sqrt[n]{x}  
Relations  \sim \simeq \cong \le \ge \equiv \not\equiv \approx \ne \propto  
Geometric  \triangle \angle \perp \ 45^\circ  
Arrows 
\leftarrow \rightarrow \leftrightarrow 

\Leftarrow \Rightarrow \Leftrightarrow 


Special  \oplus \otimes \pm \mp \hbar \wr \dagger \ddagger \star * \ldots \circ \cdot \times \bullet \infty \vdash \models  
Lowercase \mathcal has some extras  \mathcal {45abcdenpqstuvwx} 
Subscripts, superscripts, integrals[edit]
Feature  Syntax  How it looks rendered  

Superscript  a^2  
Subscript  a_2  
Grouping  a^{2+2}  
a_{i,j}  
Combining sub & super  x_2^3  
Preceding sub & super  {}_1^2\!X_3^4  
Derivative (good)  x'  
Derivative (wrong in HTML)  x^\prime  
Derivative (wrong in PNG)  x\prime  
Derivative dots  \dot{x}, \ddot{x}  
Underlines & overlines  \hat a \bar b \vec c \widehat {d e f} \overline {g h i} \underline {j k l}  
Sum  \sum_{k=1}^N k^2  
Product  \prod_{i=1}^N x_i  
Limit  \lim_{n \to \infty}x_n  
Integral  \int_{N}^{N} e^x\, dx  
Path Integral  \oint_{C} x^3\, dx + 4y^2\, dy 
Fractions, matrices, multilines[edit]
Feature  Syntax  How it looks rendered  

Fractions  \frac{2}{4} or {2 \over 4}  
Binomial coefficients  {n \choose k}  
Small Fractions  \begin{matrix} \frac{2}{4} \end{matrix}  
Matrices  \begin{matrix} x & y \\ z & v \end{matrix}  
\begin{vmatrix} x & y \\ z & v \end{vmatrix}  
\begin{Vmatrix} x & y \\ z & v \end{Vmatrix}  
\begin{bmatrix} 0 & \cdots & 0 \\ \vdots &
\ddots & \vdots \\ 0 & \cdots & 0\end{bmatrix} 

\begin{Bmatrix} x & y \\ z & v \end{Bmatrix}  
\begin{pmatrix} x & y \\ z & v \end{pmatrix}  
Case distinctions  f(n) = \begin{cases} n/2, & \mbox{if }n\mbox{ is even} \\ 3n+1, & \mbox{if }n\mbox{ is odd} \end{cases}  
Multiline equations  \begin{matrix}f(n+1) & = & (n+1)^2 \\ \ & = & n^2 + 2n + 1 \end{matrix}  
Alternative multiline equations (using tables) 
{  <math>f(n+1)</math> <math>=(n+1)^2</math>   <math>=n^2 + 2n + 1</math> } 

Fonts[edit]
Feature  Syntax  How it looks rendered  

Greek letters  \alpha \beta \gamma \Gamma \phi \Phi \Psi\ \tau \Omega  
Blackboard bold  x\in\mathbb{R}\sub\mathbb{C}  
boldface (vectors)  \mathbf{x}\cdot\mathbf{y} = 0  
boldface (greek)  \boldsymbol{\alpha} + \boldsymbol{\beta} + \boldsymbol{\gamma}  
Fraktur typeface  \mathfrak{a} \mathfrak{B}  
Script  \mathcal{ABC}  
Hebrew  \aleph \beth \gimel \daleth  
nonitalicised characters  \mbox{abc}  
mixed italics (bad)  \mbox{if} n \mbox{is even}  
mixed italics (good)  \mbox{if }n\mbox{ is even} 
Parenthesizing big expressions, brackets, bars[edit]
Feature  Syntax  How it looks rendered 

Not good  ( \frac{1}{2} )  
Better  \left ( \frac{1}{2} \right ) 
You can use various delimiters with \left and \right:
Feature  Syntax  How it looks rendered 

Parentheses  \left ( A \right )  
Brackets  \left [ A \right ]  
Braces  \left \{ A \right \}  
Angle brackets  \left \langle A \right \rangle  
Bars and double bars  \left  A \right  and \left \ B \right \  
Delimiters can be mixed, 
\left [ 0,1 \right ) 

Use \left. and \right. if you don't want a delimiter to appear: 
\left . \frac{A}{B} \right \} \to X  
Floor and ceiling functions:  \lfloor x \rfloor = \lceil y \rceil 
Spacing[edit]
Note that TeX handles most spacing automatically, but you may sometimes want manual control.
Feature  Syntax  How it looks rendered 

double quad space  a \qquad b  
quad space  a \quad b  
text space  a\ b  
text space without PNG conversion  a \mbox{ } b  
large space  a\;b  
medium space  a\>b  [not supported] 
small space  a\,b  
no space  ab  
negative space  a\!b 
Align with normal text flow[edit]
Due to the default css
img.tex { verticalalign: middle; }
an inline expression like should look good.
Forced PNG rendering[edit]
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:
Syntax  How it looks rendered 

a^{c+2}  
a^{c+2} \,  
a^{\,\!c+2}  
a^{b^{c+2}}  (WRONG with option "HTML if possible or else PNG"!) 
a^{b^{c+2}} \,  (WRONG with option "HTML if possible or else PNG"!) 
a^{b^{c+2}}\approx 5  (due to "" correctly displayed, no code "\,\!" needed) 
a^{b^{\,\!c+2}}  
\int_{N}^{N} e^x\, dx  
\int_{N}^{N} e^x\, dx \,  
\int_{N}^{N} e^x\, dx \,\! 
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:
 <! The \,\! is to keep the formula rendered as PNG instead of HTML. Please don't remove it.>
Examples[edit]
See also[edit]
 Proposed GNU LilyPond support
External Links[edit]
 A LaTeX tutorial. http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/
 A PDF document introducing TeX  see page 39 onwards for a good introduction to the maths side of things: http://www.ctan.org/texarchive/info/gentle/gentle.pdf
 A PDF document introducing LaTeX  skip to page 59 for the math section. See page 72 for a complete reference list of symbols included in LaTeX and AMSLaTeX. http://www.ctan.org/texarchive/info/lshort/english/lshort.pdf
 TeX reference card: http://www.csit.fsu.edu/~mimi/tex/texrefcardletter.pdf
 Can't remember but I put it here so it must be ok ;) http://www.ams.org/tex/amslatex.html
 A set of public domain fixedsize math symbol bitmaps: http://us.metamath.org/symbols/symbols.html
Wikinewsspecific content and links to other help pages[edit]
Help contents Reading: Go  Search  URL  Namespace  Page name  Section  Link  Backlinks  Piped link  Interwiki link  Redirect  Variable  Category 
,,,,,,,