Help:Math
MediaWiki uses LaTeX markup to render mathematical formulas, generating either PNG images or simple HTML markup, depending on user preferences and the complexity of the expression.
Math markup goes inside <math> ... </math> tags. Line breaks within these tags are allowed but will not be rendered.
Contents |
Special characters
| Feature | Syntax | How it looks rendered |
|---|---|---|
| std. functions (good) | \sin x + \ln y +\operatorname{sgn} z | <math>\sin x + \ln y +\operatorname{sgn} z</math> |
| std. functions (wrong) | sin x + ln y + sgn z | <math>sin x + ln y + sgn z\,</math> |
| Modular arithmetic | s_k \equiv 0 \pmod{m} | <math>s_k \equiv 0 \pmod{m}</math> |
| Derivatives | \nabla \partial x dx \dot x \ddot y | <math>\nabla \ \partial x \ dx \ \dot x\ \ddot y</math> |
| Sets | \forall \exists \empty \emptyset \varnothing | <math>\forall \exists \empty \emptyset \varnothing</math> |
| \in \ni \not \in \notin \subset \subseteq \supset \supseteq | <math>\in \ni \not \in \notin \subset \subseteq \supset \supseteq</math> | |
| \cap \bigcap \cup \bigcup \biguplus \setminus \smallsetminus | <math>\cap \bigcap \cup \bigcup \biguplus \setminus \smallsetminus</math> | |
| Logic | p \land \bar{q} \to p\lor \lnot q | <math>p \land \bar{q} \to p\lor \lnot q</math> |
| Roots | \sqrt{2}\approx 1.4 | <math>\sqrt{2}\approx 1.4</math> |
| \sqrt[n]{x} | <math>\sqrt[n]{x}</math> | |
| Relations | \sim \simeq \cong \le \ge \equiv \not\equiv \approx \ne | <math> \sim \ \simeq \ \cong \ \le \ \ge \ \equiv \ \not\equiv \ \approx \ \ne</math> |
| Geometric | \Diamond \Box \triangle \angle \perp \mid \nmid \| 45^\circ | 45^\circ</math> |
| Arrows |
\leftarrow \rightarrow \leftrightarrow |
<math>\leftarrow\ \rightarrow\ \leftrightarrow</math>
|
|
\Leftarrow \Rightarrow \Leftrightarrow |
<math>\Leftarrow\ \Rightarrow\ \Leftrightarrow</math>
| |
| Special |
\oplus \otimes \pm \mp \hbar \dagger \ddagger \star \circ \cdot \times \bullet \infty |
<math>\oplus \otimes \pm \mp \hbar \dagger \ddagger \star \circ \cdot \times \bullet\ \infty</math>
|
Subscripts and superscripts
| Feature | Syntax | How it looks rendered |
|---|---|---|
| Superscript | a^2 | <math>a^2</math> |
| Subscript | a_2 | <math> a_2 </math> |
| Grouping | a^{2+2} | <math>a^{2+2}</math> |
| a_{i,j} | <math>a_{i,j}</math> | |
| Combining sub & super | x_2^3 | <math>x_2^3</math> |
| Derivative (good) | x' | <math>x'</math> |
| Derivative (wrong in HTML) | x^\prime | <math>x^\prime</math> |
| Derivative (wrong in PNG) | x\prime | <math>x\prime</math> |
| Underlines and overlines | \hat a \bar b \vec c \widehat {d e f} \overline {g h i} \underline {j k l} | <math>\hat a \ \bar b \ \vec c \ \widehat {d e f} \ \overline {g h i} \ \underline {j k l}</math> |
| Arrows | A \xleftarrow{n+\mu-1} B \xrightarrow[T]{n\pm i-1} C | <math>A \xleftarrow{n+\mu-1} B \xrightarrow[T]{n\pm i-1} C</math> |
| Overbraces | \overbrace{ 1+2+\cdots+100 }^{5050} | <math>\overbrace{ 1+2+\cdots+100 }^{5050}</math> |
| Underbraces | \underbrace{ a+b+\cdots+z }_{26} | <math>\underbrace{ a+b+\cdots+z }_{26}</math> |
| Sum | \sum_{k=1}^N k^2 | <math>\sum_{k=1}^N k^2</math> |
| Product | \prod_{i=1}^N x_i | <math>\prod_{i=1}^N x_i</math> |
| Limit | \lim_{n \to \infty}x_n | <math>\lim_{n \to \infty}x_n</math> |
| Integral | \int_{-N}^{N} e^x\, dx | <math>\int_{-N}^{N} e^x\, dx</math> |
| Line Integral | \oint_{C} x^3\, dx + 4y^2\, dy | <math>\oint_{C} x^3\, dx + 4y^2\, dy</math> |
Fractions, matrices and multilines
| Feature | Syntax | How it looks rendered |
|---|---|---|
| Fractions | \frac{2}{4} or {2 \over 4} | <math>\frac{2}{4}</math> |
| Binomial coefficients | {n \choose k} | <math>{n \choose k}</math> |
| Matrices | \begin{pmatrix} x & y \\ z & v \end{pmatrix} | <math>\begin{pmatrix} x & y \\ z & v
\end{pmatrix}</math> |
| \begin{bmatrix} 0 & \cdots & 0 \\ \vdots &
\ddots & \vdots \\ 0 & \cdots & 0\end{bmatrix} |
<math>\begin{bmatrix} 0 & \cdots & 0 \\ \vdots
& \ddots & \vdots \\ 0 & \cdots & 0\end{bmatrix} </math> | |
| \begin{Bmatrix} x & y \\ z & v \end{Bmatrix} | <math>\begin{Bmatrix} x & y \\ z & v
\end{Bmatrix}</math> | |
| \begin{vmatrix} x & y \\ z & v \end{vmatrix} | <math>\begin{vmatrix} x & y \\ z & v
\end{vmatrix}</math> | |
| \begin{Vmatrix} x & y \\ z & v \end{Vmatrix} | <math>\begin{Vmatrix} x & y \\ z & v
\end{Vmatrix}</math> | |
| \begin{matrix} x & y \\ z & v \end{matrix} | <math>\begin{matrix} x & y \\ z & v
\end{matrix}</math> | |
| Case distinctions | f(n) = \left \{ \begin{matrix} n/2, & \mbox{if }n\mbox{ is
even} \\ 3n+1, & \mbox{if }n\mbox{ is odd} \end{matrix} \right. |
<math>f(n) = \left \{ \begin{matrix} n/2, & \mbox{if }n\mbox{ is even} \\ 3n+1, & \mbox{if }n\mbox{ is odd} \end{matrix} \right. </math> |
| Multiline equations | \begin{matrix}f(n+1) & = & (n+1)^2 \\ \ &
= & n^2 + 2n + 1 \end{matrix} |
<math>\begin{matrix}f(n+1) & = & (n+1)^2 \\ \ & = & n^2 + 2n + 1 \end{matrix}</math> |
Fonts
| Feature | Syntax | How it looks rendered |
|---|---|---|
| Greek letters | \alpha \beta \gamma \Gamma \phi \Phi \Psi\ \tau \Omega | <math>\alpha\ \beta\ \gamma\ \Gamma\ \phi\ \Phi\ \Psi\ \tau\ \Omega</math> |
| Blackboard bold | x\in\mathbb{R}\sub\mathbb{C} | <math>x\in\mathbb{R}\subset\mathbb{C}</math> |
| Boldface (vectors) | \mathbf{x}\cdot\mathbf{y} = 0 | <math>\mathbf{x}\cdot\mathbf{y} = 0</math> |
| Boldface (Greek) | \boldsymbol{\alpha} + \boldsymbol{\beta} + \boldsymbol{\gamma} | <math>\boldsymbol{\alpha} + \boldsymbol{\beta} + \boldsymbol{\gamma}</math> |
| Fraktur typeface | \mathfrak{a} \mathfrak{B} | <math>\mathfrak{a} \mathfrak{B}</math> |
| Script | \mathcal{ABC} | <math>\mathcal{ABC}</math> |
| Hebrew | \aleph \beth \gimel \daleth | <math>\aleph\ \beth\ \gimel\ \daleth</math> |
| Non-italicized characters | \mbox{abc} | <math>\mbox{abc}</math> |
| Mixed italics (bad) | \mbox{if} n \mbox{is even} | <math>\mbox{if} n \mbox{is even}</math> |
| Mixed italics (good) | \mbox{if }n\mbox{ is even} | <math>\mbox{if }n\mbox{ is even}</math> |
Parenthesizing big expressions
| Feature | Syntax | How it looks rendered |
|---|---|---|
| Not good | ( \frac{1}{2} ) | <math>( \frac{1}{2} )</math> |
| Better | \left ( \frac{1}{2} \right ) | <math>\left ( \frac{1}{2} \right )</math> |
You can use various delimiters with \left and \right:
| Feature | Syntax | How it looks rendered |
|---|---|---|
| Parentheses | \left ( A \right ) | <math>\left ( A \right )</math> |
| Brackets | \left [ A \right ] | <math>\left [ A \right ]</math> |
| Braces | \left \{ A \right \} | <math>\left \{ A \right \}</math> |
| Angle brackets | \left \langle A \right \rangle | <math>\left \langle A \right \rangle</math> |
| Bars and double bars | \left | A \right | and \left \| B \right \| | A \right | and \left \| B \right \|</math> |
|
Delimiters can be mixed, as |
\left [ 0,1 \right ) |
<math>\left [ 0,1 \right )</math>
|
| Use \left. and \right. if you don't want a delimiter to appear |
\left . \frac{A}{B} \right \} \to X | <math>\left . \frac{A}{B} \right \} \to X</math> |
Spacing
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 | <math>a \qquad b</math> |
| quad space | a \quad b | <math> a \quad b</math> |
| text space | a\ b | <math>a\ b</math> |
| large space | a\;b | <math>a\;b</math> |
| medium space | a\>b | [not supported] |
| small space | a\,b | <math>a\,b</math> |
| no space | ab | <math>ab\,</math> |
| negative space | a\!b | <math>a\!b</math> |
Forced PNG rendering
If you must, it is possible to force the formula to render as PNG, without affecting the display of the formula, by adding \,\! (small space and negative space, which cancel out) somewhere inside the math tags (probably at the end).
This could be useful to keep the rendering of formulas in a proof consistent, for example, or to fix formulas that render incorrectly in HTML (x prime, or a^{2+2}), 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^{2+2}
|
<math>a^{2+2}</math> |
| a^{2+2} \,\! | <math>a^{2+2} \,\!</math> |
| \int_{-N}^{N} e^x\, dx | <math> \int_{-N}^{N} e^x\, dx </math> |
| \int_{-N}^{N} e^x\, dx \,\! | <math> \int_{-N}^{N} e^x\, dx \,\! </math> |