This screenshot shows the formula E = mc2 being edited using VisualEditor. The window is opened by typing "<math>" in VisualEditor. The visual editor shows a button that allows to choose one of three offered modes to display a formula.

There are three methods for displaying formulas in Wikipedia: raw HTML, HTML with math templates (abbreviated here as {{math}}), and a subset of LaTeX implemented with the HTML markup <math></math> (referred to as MediaWiki software. The Manual of Style Mathematics has not always evolved accordingly. So the how-to recommendations that appear below may differ from those of the Manual of Style. In this case, they express a consensus resulting of the practice of the most experienced members of WikiProject Mathematics and many discussions at Wikipedia talk:WikiProject Mathematics.

For example, the famous Einstein formula can be entered with:

  • Raw HTML: {{nowrap|''E'' {{=}} ''mc''<sup>2</sup>}}, which is rendered as E = mc2
    • The template {{nowrap}} is used here only for avoiding a line break inside the formula.
  • {{math}}: {{math|''E'' {{=}} ''mc''{{sup|2}}}}, which is rendered as E = mc2
  • LaTeX: <math>E=mc^2</math>, which is rendered as

Use of raw HTML

Variable names and many symbols appear very different to the reader when raw HTML is used compared to the other rendering methods. This may be confusing in the common case where several methods are used in the same article. Moreover, mathematicians who are used to reading and writing texts written with LaTeX often find the raw HTML rendering awful.

So, raw HTML should normally not be used for new content. However, raw HTML is still present in many mathematical articles. It is generally a good editing practice to convert it to {{math}} format, but consistency must be respected; that is, such a conversion must be done in a whole article, or at least in a whole section. Moreover, such a conversion must be identified as such in the edit summary, and making other changes in the same edit should be avoided. This is to help other users identify changes that are possibly controversial (the "diff" of a conversion may be very large, and may hide other changes).

Converting raw HTML to {{math}} is rather simple: when the formula is enclosed with {{nowrap}}, it suffices to change "nowrap" into "math". However, if the formula contains an equal sign, one has to add 1= just before the formula for avoiding confusion with the template syntax; for example, {{math|1=''E'' = ''mc''{{sup|2}}}}. Also, vertical bars (|), if any, must either be replaced with {{!}} or avoided by using {{abs}}.

LaTeX vs. {{math}}

Both accepted by MOS:MATH, these two methods of writing mathematical expressions—using {{math}} and LaTeX—have both advantages and disadvantages. The visual rendering of variable names is largely consistent between them, and displaying variables within the same paragraph using either method generally does not cause formatting issues.

The disadvantages of LaTeX include:

  • On some browser configurations, LaTeX inline formulas appear with a slight vertical misalignment, or with a font size that may be slightly different from that of the surrounding text. This is not a problem with a block displayed formula, and also typically not with inline formulas that exceed the normal line height marginally (for example, formulas with subscripts and superscripts).
  • The use of LaTeX in a piped link or in a section heading does not appear in blue in the linked text or the table of contents. Moreover, links to section headings containing LaTeX formulas do not always work as expected.
  • Finally, having many LaTeX formulas may significantly increase the processing time of a page. LaTeX formulas should be avoided in image captions or footnotes, because when the image is clicked for a larger display or a footnote is selected on a mobile device, LaTeX in the caption or footnote will not render.

Disadvantages of {{math}} include:

  • not all formulas can be displayed,
  • complicated formulae may be poorly rendered,
  • except for the most common symbols such as letters, numerals, and basic punctuation, rendering of Unicode mathematical symbols can be inconsistent in size or alignment where fallback fonts do not match,
  • some readers may not have any font which includes certain uncommon symbols,
  • spaces within a formula must be directly managed (for example, by including explicit hair or thin spaces),
  • variable names must be italicized explicitly, and superscripts and subscripts must use an explicit tag or template, and
  • except for short formulas, the source of a formula typically has more markup overhead and can be difficult to read.

The common practice of most members of WikiProject Mathematics is the following:

  • Use of {{mvar}} and {{math}} for isolated variables and {{math}} for simple inline formulas; or alternately the use of LaTeX for these purposes (optionally using the {{tmath}} template), especially on articles with many complex formulas or where rendering seems inconsistent
  • Use of {{mvar}} and {{math}} for formulas in image captions, even if the rendering is mediocre
  • Use of LaTeX for separately displayed formulas and more complicated inline formulas
  • Use of LaTeX for formulas involving symbols that are not regularly rendered in Unicode (see Manual of Style/Mathematics § Blackboard bold)
  • Avoid formulas in section headings, and when this is necessary, use raw HTML (see Finite field § GF(p2) for an odd prime p for an example)

The choice between {{math}} and LaTeX depends on the editor. Converting a page from one format to another must be done with stronger reasons than editor preference.

Display format of LaTeX

By default SVG images with non-visible MathML are generated. The text-only form of the LaTeX can be set via Preferences → Appearance → Math.

The hidden MathML can be used by screen readers and other assistive technology. In Firefox, to display the MathML:

In either case, you must have fonts that support MathML (see Mozilla Fonts for MathML) installed on your system. For copy-paste support in Firefox, you can also install MathML Copy.

Spaces and ordinary text

Formulas using multiple words and hyphens are not functional in <math>. For example, this code, which gives a simple formula for calculating pollution risks:

Risk = \frac{Measured environmental concentration}{Predicted no-effect concentration}

produces this unreadable result:

A possible workaround is the use of \text:

\text{Risk} = \frac{\text{Measured environmental concentration}}{\text{Predicted no-effect concentration}}

which produces:

Use of HTML templates

TeX (LaTeX) markup is not the only way to render mathematical formulas. For simple inline formulas, the template {{math}} and its associated templates are often preferred. The following comparison table shows that similar results can be achieved with the two methods. (See also Help:Special characters.)

LaTeX syntax LaTeX rendering   HTML syntax HTML rendering
<math>\alpha</math> {{math|''&alpha;''}}
or {{mvar|&alpha;}}
α
or α
<math>f(x) = x^2</math> {{math|1=''f''(''x'') = ''x''<sup>2</sup>}}f(x) = x2
<math>\{1,e,\pi\}</math> {{math|{{mset|1, ''e'', ''&pi;''}}}} {1, e, π}
<math>|z| \leq 2</math> {{math|{{abs|''z''}} &le; 2}} |z| 2

Here is a summary of the mathematical templates:

When writing sets or expressions involving braces, vertical bars, or equal signs within {{math}}, care is required, as these characters can conflict with template syntax. To avoid such issues:

  • Use {{mset}} to safely enclose elements in curly braces ({})
  • Use {{abs}} to wrap values in absolute value bars (| · |), avoiding parser function confusion with template pipes.
  • For a single vertical bar (|), use {{!}}.
  • For an equal sign (=) within template parameters, use {{=}}.

HTML entities

Though Unicode characters are generally preferred, sometimes HTML entities are needed to avoid problems with wikitext or confusion with other characters:

< > ·
&lt; &gt; &minus; &bull; &prime; &Prime; &sdot; &middot; &ndash; &mdash;

In the table below, the HTML syntax on the left produces the symbols on the right, but these symbols can also be entered directly into the wikitext either by typing them if they are available on the keyboard, by copy-pasting them, or by using the special character button () in the toolbar. (When editing any Wikipedia page in a desktop web browser, use the "Insert" pulldown menu immediately below the article text, or the "Special characters" menu immediately above the article text.) Normally, lowercase Greek letters should be entered in italics, that is, enclosed between two single quotes (for example,''β'').

HTML syntax Rendering
&alpha; &beta; &gamma; &delta; &epsilon; &zeta;
&eta; &theta; &iota; &kappa; &lambda; &mu; &nu;
&xi; &omicron; &pi; &rho; &sigma; &sigmaf;
&tau; &upsilon; &phi; &chi; &psi; &omega;

α β γ δ ε ζ
η θ ι κ λ μ ν
ξ ο π ρ σ ς
τ υ φ χ ψ ω

&Gamma; &Delta; &Theta; &Lambda; &Xi; &Pi;
&Sigma; &Phi; &Psi; &Omega;

Γ Δ Θ Λ Ξ Π
Σ Φ Ψ Ω

&int; &sum; &prod; &minus; &plusmn; &infin;
&asymp; &prop; = &equiv; &ne; &le; &ge;
&times; &middot; &sdot; &divide; &part; &prime; &Prime;
&nabla; &permil; &deg; &there4; &empty;

∫ ∑ ∏ − ± ∞
≈ ∝ = ≡ ≠ ≤ ≥
× · ⋅ ÷ ∂ ′ ″
∇ ‰ ° ∴ ∅

&isin; &notin; &cap; &cup; &sub; &sup; &sube; &supe;
&not; &and; &or; &exist; &forall;
&rArr; &hArr; &rarr; &harr; &uarr; &darr;
&alefsym; - &ndash; &mdash;

∈ ∉ ∩ ∪ ⊂ ⊃ ⊆ ⊇
¬ ∧ ∨ ∃ ∀
⇒ ⇔ → ↔ ↑ ↓
ℵ - – —

Superscripts and subscripts

x2 x3 x2
1
x<sup>2</sup>x<sub>3</sub>x{{su|b=1|p=2|lh=1}}

Spacing

To avoid line-wrapping in the middle of a formula, use {{math}}. If necessary, a non-breaking space ( ) can be inserted with &nbsp;. When an inline formula is long enough, it can be helpful to allow it to break across lines. Whether using LaTeX or templates, split the formula at each acceptable breakpoint into separate <math> tags or {{math}} templates with any binary relations or operators and intermediate whitespace included at the trailing end rather than leading end of a part.

Typically whitespace should be a regular space ( ) or none at all. In rare circumstances, such as where one character overlaps another due to one being in italics, a thin space can be added with {{thin space}}.

Additional

For more on Wikipedia how-tos and math style guidelines, see:

For more on special characters:

LaTeX basics

Math markup goes inside <math>...</math>. Chemistry markup goes inside <math chem>...</math> or <chem>...</chem>. {{tmath|...}} can be used in place of <math>...</math> to avoid line-wrapping of adjacent text (with caveats). All these tags use TeX.

#if expression, etc. See m:Template:Demo of attempt to use parameters within TeX for more information.

The now deprecated tag <ce> was considered too ambiguous, and it has been replaced by <chem>.[1]

LaTeX commands

LaTeX commands are case-sensitive, and take one of the following two formats:

  • They start with a backslash \ and then have a name consisting of letters only. Command names are terminated by a space, a number or any other "non-letter" character.
  • They consist of a backslash \ and exactly one non-letter.

Some commands need an argument, which has to be given between curly braces {} after the command name. Some commands support optional parameters, which are added after the command name in square brackets []. The general syntax is:

\commandname[option1,option2,...]{argument1}{argument2}...

Special characters

The following symbols are reserved characters that either have a special meaning under LaTeX or are unavailable in all the fonts. If you enter them directly in your text, they will normally not render, but rather do things you did not intend.

# $ % ^ & _ { } ~ \

These characters can be entered by prefixing the escape character backslash \ or using special sequences:

\# \$ \% ^\wedge \& \_ \{ \} \sim \backslash

yielding:

Spaces

"Whitespace" characters, such as blank or tab, are treated uniformly as "space" by LaTeX. Several consecutive whitespace characters are treated as one "space". See § Spacing for commands that produce spaces of different size.

Vertical spacing is accomplished via an optional parameter passed to the terminate line command, \\, passing it a number of units and the name of a unit; for example, \\[0.6mu] is 0.6 "mu" units. Not all LaTeX units are available; available options are:

Valid spacing units
Type Unit Definition Notes Demonstration
Relative em Current font's total height.

mu em/18
ex Current font's x-height. Not the height of an x.
Absolute in 1 inch

pc 12in/72.27 Smaller than 1 pica.
pt in/72.27 Smaller than 1 point.
cm in/2.54
mm in/25.4

LaTeX environments

Environments in LaTeX have a role that is quite similar to commands, but they usually have effect on a wider part of formula. Their syntax is:

 \begin{environmentname}
   text to be influenced
 \end{environmentname}

Environments supported by Wikipedia include matrix, align, etc. See § Fractions, matrices, multilines.

Rendering

The font sizes and types are independent of browser settings or CSS. Font sizes and types will often deviate from what HTML renders. Vertical alignment with the surrounding text can also be a problem; a work-around is described in § Alignment with normal text flow. The CSS selector of the images is img.tex.

Apart from function and operator names, as is customary in mathematics, variables and letters are in italics; digits are not. For other text, (like variable labels) to avoid being rendered in italics like variables, use \text or \mathrm (formerly \rm). You can also define new function names using \operatorname{...}. For example, \text{abc} gives . \operatorname{...} provides spacing before and after the operator name when appropriate, as when a\operatorname{sn}b is rendered as (with space to the left and right of "sn") and a\operatorname{sn}(b+c) as (with space to the left and not to the right). LaTeX's starred version, \operatorname* is not supported, but a workaround is to add \limits instead. For example, \operatorname{sn}_{b>c}(b+c) \qquad \operatorname{sn}\limits_{b>c}(b+c) renders as:

LaTeX does not have full support for Unicode characters, and not all characters render. Most Latin characters with accents render correctly. However some do not, in particular those that include multiple diacritics (e.g. with Latin letters used in Vietnamese) or that cannot be precomposed into a single character (such as the uppercase Latin letter W with ring ), or that use other diacritics (like the ogonek or the double grave accent, used in Central European languages like Polish, or the horn attached above some vowels in Vietnamese), or other modified letter forms (used in IPA notations, African languages, or in medieval texts), some digram ligatures (like IJ in Dutch), or Latin letters borrowed from Greek, or small capitals, as well as superscripts and subscript letters. For example, \text{ð} and \text{þ} (used in Icelandic) will give errors.

The normal way of entering quotation marks in text mode (two back ticks for the left and two apostrophes for the right), such as \text{a ``quoted'' word} will not work correctly. As a workaround, you can use the Unicode left and right quotation mark characters, which are available from the special characters button (), or "Symbols" dropdown panel beneath the editor: \text{a “quoted” word}.

Force-rerendering of formulas

MediaWiki stores rendered formulas in a cache so that the images of those formulas do not need to be created each time the page is opened by a user. To force the rerendering of all formulas of a page, you must open it with the getter variables action=purge&mathpurge=true. Imagine for example there is a wrong rendered formula in the article Integral. To force the re-rendering of this formula you need to open the URL: https://en.wikipedia.org/w/index.php?title=Integral&action=purge&mathpurge=true

Afterwards you need to bypass your browser cache, so that the new created images of the formulas are actually downloaded.

Formatting using LaTeX

Functions, symbols, special characters

Accents and diacritics

\dot{a}, \ddot{a}, \acute{a}, \grave{a}
\check{a}, \breve{a}, \tilde{a}, \bar{a}
\hat{a}, \widehat{a}, \vec{a}

Standard numerical functions

\exp_a b = a^b, \exp b = e^b, 10^m
\ln c = \log c, \lg d = \log_{10} d
\sin a, \cos b, \tan c, \cot d, \sec f, \csc g
\arcsin h, \arccos i, \arctan j
\sinh k, \cosh l, \tanh m, \coth n
\operatorname{sh}k, \operatorname{ch}l, \operatorname{th}m, \operatorname{coth}n
\operatorname{argsh}o, \operatorname{argch}p, \operatorname{argth}q
\sgn r, \left\vert s \right\vert
\min(x,y), \max(x,y)

Bounds

\min x, \max y, \inf s, \sup t
\lim u, \liminf v, \limsup w
\dim p, \deg q, \det m, \ker\phi
\injlim, \varinjlim, \projlim, \varprojlim

Projections

\Pr j, \hom l, \lVert z \rVert, \arg z

Differentials and derivatives

dt, \mathrm{d}t, \partial t, \nabla\psi
dy/dx, \mathrm{d}y/\mathrm{d}x, \frac{dy}{dx}, \frac{\mathrm{d}y}{\mathrm{d}x}
\frac{\partial^2}{\partial x_1\partial x_2}y, \left.\frac{\partial^3 f}{\partial^2 x \partial y}\right\vert_{p_0}
\prime, \backprime, f^\prime, f', f'', f^{(3)}, \dot y, \ddot y

Letter-like symbols or constants

\infty, \aleph, \complement, \backepsilon, \eth, \Finv, \hbar, \N, \R, \Z, \C, \Q
\Im, \imath, \jmath, \Bbbk, \ell, \mho, \wp, \Re, \circledS, \S, \P, \AA

Modular arithmetic

s_k \equiv 0 \pmod{m}
a \bmod b
\gcd(m, n), \operatorname{lcm}(m, n)
\mid, \nmid, \shortmid, \nshortmid

Radicals

\surd, \sqrt{2}, \sqrt[n]{2}, \sqrt[3]{\frac{x^3+y^3}{2}}

Operators

+, -, \pm, \mp, \dotplus
\times, \div, \divideontimes, /, \backslash
\cdot, * \ast, \star, \circ, \bullet
\boxplus, \boxminus, \boxtimes, \boxdot
\oplus, \ominus, \otimes, \oslash, \odot
\circleddash, \circledcirc, \circledast
\bigoplus, \bigotimes, \bigodot

Sets

\{ \}, \O \empty \emptyset, \varnothing
\in, \notin \not\in, \ni, \not\ni
\cap, \Cap, \sqcap, \bigcap
\cup, \Cup, \sqcup, \bigcup, \bigsqcup, \uplus, \biguplus
\setminus, \smallsetminus, \times
\subset, \Subset, \sqsubset
\supset, \Supset, \sqsupset
\subseteq, \nsubseteq, \subsetneq, \varsubsetneq, \sqsubseteq
\supseteq, \nsupseteq, \supsetneq, \varsupsetneq, \sqsupseteq
\subseteqq, \nsubseteqq, \subsetneqq, \varsubsetneqq
\supseteqq, \nsupseteqq, \supsetneqq, \varsupsetneqq

Relations

=, \ne, \neq, \equiv, \not\equiv
\doteq, \doteqdot, \mathrel{\overset{\underset{\mathrm{def}}{}}=}, \mathrel{\stackrel{\mathrm{def}}=}, :=
\sim, \nsim, \backsim, \thicksim, \simeq, \backsimeq, \eqsim, \cong, \ncong
\approx, \thickapprox, \approxeq, \asymp, \propto, \varpropto
<, \nless, \ll, \not\ll, \lll, \not\lll, \lessdot
>, \ngtr, \gg, \not\gg, \ggg, \not\ggg, \gtrdot
\le, \leq, \lneq, \leqq, \nleq, \nleqq, \lneqq, \lvertneqq
\ge, \geq, \gneq, \geqq, \ngeq, \ngeqq, \gneqq, \gvertneqq
\lessgtr, \lesseqgtr, \lesseqqgtr, \gtrless, \gtreqless, \gtreqqless
\leqslant, \nleqslant, \eqslantless
\geqslant, \ngeqslant, \eqslantgtr
\lesssim, \lnsim, \lessapprox, \lnapprox
\gtrsim, \gnsim, \gtrapprox, \gnapprox
\prec, \nprec, \preceq, \npreceq, \precneqq
\succ, \nsucc, \succeq, \nsucceq, \succneqq
\preccurlyeq, \curlyeqprec
\succcurlyeq, \curlyeqsucc
\precsim, \precnsim, \precapprox, \precnapprox
\succsim, \succnsim, \succapprox, \succnapprox

Geometric

\parallel, \nparallel, \shortparallel, \nshortparallel
\perp, \angle, \sphericalangle, \measuredangle, 45^\circ for degrees
\Box, \square, \blacksquare, \diamond, \Diamond, \lozenge, \blacklozenge, \bigstar
\bigcirc, \triangle, \bigtriangleup, \bigtriangledown
\vartriangle, \triangledown
\blacktriangle, \blacktriangledown, \blacktriangleleft, \blacktriangleright

Logic

\forall, \exists, \nexists
\therefore, \because, \And
\lor, \vee, \curlyvee, \bigvee

don't use \or which is now deprecated

\land, \wedge, \curlywedge, \bigwedge

don't use \and which is now deprecated

\lnot, \neg, \not\operatorname{R}, \bot, \top
\vdash, \dashv, \vDash, \Vdash, \models
\Vvdash, \nvdash, \nVdash, \nvDash, \nVDash
\ulcorner, \urcorner, \llcorner, \lrcorner

Arrows

\Rrightarrow, \Lleftarrow
\Rightarrow, \nRightarrow, \Longrightarrow, \implies
\Leftarrow, \nLeftarrow, \Longleftarrow
\Leftrightarrow, \nLeftrightarrow, \Longleftrightarrow, \iff
\Uparrow, \Downarrow, \Updownarrow
\rightarrow, \to, \nrightarrow, \longrightarrow
\leftarrow, \gets, \nleftarrow, \longleftarrow
\leftrightarrow, \nleftrightarrow, \longleftrightarrow
\uparrow, \downarrow, \updownarrow
\nearrow, \swarrow, \nwarrow, \searrow
\mapsto, \longmapsto
\rightharpoonup \rightharpoondown \leftharpoonup \leftharpoondown \upharpoonleft \upharpoonright \downharpoonleft \downharpoonright \rightleftharpoons \leftrightharpoons
\curvearrowleft \circlearrowleft \Lsh \upuparrows \rightrightarrows \rightleftarrows \rightarrowtail \looparrowright
\curvearrowright \circlearrowright \Rsh \downdownarrows \leftleftarrows \leftrightarrows \leftarrowtail \looparrowleft
\hookrightarrow \hookleftarrow \multimap \leftrightsquigarrow \rightsquigarrow \twoheadrightarrow \twoheadleftarrow

Special

\amalg \P \S \% \dagger \ddagger \ldots \cdots \vdots \ddots
\smile \frown \wr \triangleleft \triangleright
\diamondsuit, \heartsuit, \clubsuit, \spadesuit, \Game, \flat, \natural, \sharp

Unsorted (new stuff)

\diagup \diagdown \centerdot \ltimes \rtimes \leftthreetimes \rightthreetimes
\eqcirc \circeq \triangleq \bumpeq \Bumpeq \doteqdot \risingdotseq \fallingdotseq
\intercal \barwedge \veebar \doublebarwedge \between \pitchfork
\vartriangleleft \ntriangleleft \vartriangleright \ntriangleright
\trianglelefteq \ntrianglelefteq \trianglerighteq \ntrianglerighteq

For a little more semantics on these symbols, see this brief TeX Cookbook or here TeX Cookbook.

Larger expressions

Subscripts, superscripts, integrals

FeatureSyntaxHow it looks rendered
Superscript a^2, a^{x+3}
Subscript a_2
Grouping 10^{30} a^{2+2}
a_{i,j} b_{f'}
Combining sub & super without and with horizontal separation x_2^3
{x_2}^3
Super super 10^{10^{8}}
Preceding and/or additional sub & super \sideset{_1^2}{_3^4}\prod_a^b
{}_1^2\!\Omega_3^4
Stacking \overset{\alpha}{\omega}
\underset{\alpha}{\omega}
\overset{\alpha}{\underset{\gamma}{\omega}}
\stackrel{\alpha}{\omega}
Derivatives x', y'', f', f''
x^\prime, y^{\prime\prime}
Derivative dots \dot{x}, \ddot{x}
Underlines, overlines, vectors \hat a \ \bar b \ \vec c
\overrightarrow{a b} \ \overleftarrow{c d} \ \widehat{d e f}
\overline{g h i} \ \underline{j k l}
Arc (workaround) \overset{\frown} {AB}
Arrows A \xleftarrow{n+\mu-1} B \xrightarrow[T]{n\pm i-1} C
Overbraces \overbrace{ 1+2+\cdots+100 }^{5050}
Underbraces \underbrace{ a+b+\cdots+z }_{26}
Sum \sum_{k=1}^N k^2
Sum (force \textstyle) \textstyle \sum_{k=1}^N k^2
Sum in a fraction (default \textstyle) \frac{\sum_{k=1}^N k^2}{a}
Sum in a fraction (force \displaystyle) \frac{\displaystyle \sum_{k=1}^N k^2}{a}
Sum in a fraction (alternative limits style) \frac{\sum\limits^{N}_{k=1} k^2}{a}
Product \prod_{i=1}^N x_i
Product (force \textstyle) \textstyle \prod_{i=1}^N x_i
Coproduct \coprod_{i=1}^N x_i
Coproduct (force \textstyle) \textstyle \coprod_{i=1}^N x_i
Limit \lim_{n \to \infty}x_n
Limit (force \textstyle) \textstyle \lim_{n \to \infty}x_n
Integral \int_{1}^{3}\frac{e^3/x}{x^2}\, dx
Integral (alternative limits style) \int\limits_{1}^{3}\frac{e^3/x}{x^2}\, dx
Integral (force \textstyle) \textstyle \int_{-N}^{N} e^x\,dx
Integral (force \textstyle, alternative limits style) \textstyle \int\limits_{-N}^{N} e^x\,dx
Double integral \iint_D dx\,dy
Triple integral \iiint_E dx\,dy\,dz
Quadruple integral \iiiint_F dx\,dy\,dz\,dt
Line or path integral \int_{(x,y)\in C} x^3\, dx + 4y^2\, dy
Closed line or path integral \oint_{(x,y)\in C} x^3\, dx + 4y^2\, dy
Intersections \bigcap_{i=1}^n E_i
Unions \bigcup_{i=1}^n E_i

Fractions, matrices, multilines

Feature Syntax How it looks rendered
Fractions \frac{2}{4}=0.5 or {2 \over 4}=0.5
Small fractions (force \textstyle) \tfrac{2}{4} = 0.5
Large (normal) fractions (force \displaystyle) \dfrac{2}{4} = 0.5 \qquad \dfrac{2}{c + \dfrac{2}{d + \dfrac{2}{4}}} = a
Large (nested) fractions \cfrac{2}{c + \cfrac{2}{d + \cfrac{2}{4}}} = a
Cancellations in fractions \cfrac{x}{1 + \cfrac{\cancel{y}}{\cancel{y}}} = \cfrac{x}{2}
Binomial coefficients \binom{n}{k}
Small binomial coefficients (force \textstyle) \tbinom{n}{k}
Large (normal) binomial coefficients (force \displaystyle) \dbinom{n}{k}
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}
\bigl( \begin{smallmatrix}
a&b\\ c&d
\end{smallmatrix} \bigr)
Case distinctions
f(n) =
\begin{cases}
n/2, & \text{if }n\text{ is even} \\
3n+1, & \text{if }n\text{ is odd}
\end{cases}
Simultaneous equations
\begin{cases}
3x + 5y + z \\
7x - 2y + 4z \\
-6x + 3y + 2z
\end{cases}
Multiline equations
\begin{align}
f(x) & = (a+b)^2 \\
& = a^2+2ab+b^2 \\
\end{align}
\begin{alignat}{2}
f(x) & = (a-b)^2 \\
& = a^2-2ab+b^2 \\
\end{alignat}
Multiline equations with multiple alignments per row
\begin{alignat}{3}
f(a,b) & = (a+b)^2 && = (a+b)(a+b) \\
& = a^2+ab+ba+b^2  && = a^2+2ab+b^2 \\
\end{alignat}
Multiline equations (must define number of columns used ({lcl})) (should not be used unless needed)
\begin{array}{lcl}
z & = & a \\
f(x,y,z) & = & x + y + z
\end{array}
Multiline equations (more)
\begin{array}{lcr}
z & = & a \\
f(x,y,z) & = & x + y + z
\end{array}
Multiline alignment using & to left align (top example) versus && to right align (bottom example) the last column
\begin{alignat}{4}
F:\; && C(X) && \;\to\;     & C(X) \\
     && g    && \;\mapsto\; & g^2
\end{alignat}
\begin{alignat}{4}
F:\; && C(X) && \;\to\;     && C(X) \\
     && g    && \;\mapsto\; && g^2
\end{alignat}


Breaking up a long expression so that it wraps when necessary (this sometimes requires workarounds for correct spacing)
The function <math>f</math> is defined by
<math>f(x) = {}</math><math display=inline>\sum_{n=0}^\infty a_n x^n = {}</math><math>a_0+a_1x+a_2x^2+\cdots.</math>
The function is defined by
Arrays
\begin{array}{|c|c|c|} a & b & S \\
\hline
0 & 0 & 1 \\
0 & 1 & 1 \\
1 & 0 & 1 \\
1 & 1 & 0 \\
\end{array}

Parenthesizing big expressions, brackets, bars

FeatureSyntaxHow it looks rendered
Bad ✗ ( \frac{1}{2} )^n
Good ✓ \left ( \frac{1}{2} \right )^n

You can use various delimiters with \left and \right:

Feature Syntax How it looks rendered
Parentheses \left ( \frac{a}{b} \right )
Brackets \left [ \frac{a}{b} \right ] \quad
\left \lbrack \frac{a}{b} \right \rbrack
Braces \left \{ \frac{a}{b} \right \} \quad
\left \lbrace \frac{a}{b} \right \rbrace
Angle brackets \left \langle \frac{a}{b} \right \rangle
Bars and double bars \left | \frac{a}{b} \right \vert \quad
\left \Vert \frac{c}{d} \right \|
Floor and ceiling functions: \left \lfloor \frac{a}{b} \right \rfloor \quad
\left \lceil \frac{c}{d} \right \rceil
Slashes and backslashes \left / \frac{a}{b} \right \backslash
Up, down, and up-down arrows \left \uparrow \frac{a}{b} \right \downarrow \quad
\left \Uparrow \frac{a}{b} \right \Downarrow \quad
\left \updownarrow \frac{a}{b} \right \Updownarrow
Delimiters can be mixed,
as long as \left and \right match
\left [ 0,1 \right )
\left \langle \psi \right |

Use \left. and \right. if you
do not want a delimiter to appear
\left . \frac{A}{B} \right \} \to X
Size of the delimiters (add "l" or "r" to indicate the side for proper spacing) ( \bigl( \Bigl( \biggl( \Biggl( \dots \Biggr] \biggr] \Bigr] \bigr] ]
\{ \bigl\{ \Bigl\{ \biggl\{ \Biggl\{ \dots
\Biggr\rangle \biggr\rangle \Bigr\rangle \bigr\rangle \rangle
\| \big\| \Big\| \bigg\| \Bigg\| \dots \Bigg| \bigg| \Big| \big| |
\lfloor \bigl\lfloor \Bigl\lfloor \biggl\lfloor \Biggl\lfloor \dots
\Biggr\rceil \biggr\rceil \Bigr\rceil \bigr\rceil \ceil
\uparrow \big\uparrow \Big\uparrow \bigg\uparrow \Bigg\uparrow \dots
\Bigg\Downarrow \bigg\Downarrow \Big\Downarrow \big\Downarrow \Downarrow
\updownarrow \big\updownarrow \Big\updownarrow \bigg\updownarrow \Bigg\updownarrow \dots
\Bigg\Updownarrow \bigg\Updownarrow \Big\Updownarrow \big\Updownarrow \Updownarrow
/ \big/ \Big/ \bigg/ \Bigg/ \dots
\Bigg\backslash \bigg\backslash \Big\backslash \big\backslash \backslash

Display attribute

The <math> tag can take a display attribute with possible values of inline and block.

Inline

If the value of the display attribute is inline, the contents will be rendered in inline mode: there will be no new paragraph for the equation and the operators will be rendered to consume only a small amount of vertical space.

The sum converges to 2;
the vertical space between lines is not disturbed by large operators.

The code for the math example reads:

<math display="inline">\sum_{i=0}^\infty 2^{-i}</math>

inline are optional and display=inline is also valid.[2]

Technically, the command \textstyle will be added to the user input before the TeX command is passed to the renderer. The result will be displayed without further formatting by outputting the image or MathML element to the page.

Block

In block-style, the equation is rendered in its own paragraph and the operators are rendered consuming less horizontal space. The equation is indented.

The sum converges to 2.

It was entered as

<math display="block">\sum_{i=0}^\infty 2^{-i}</math>

\displaystyle will be added to the user input (if the user input does not already contain the string \displaystyle or \align) before the TeX command is passed to the renderer. The result will be displayed in a new paragraph. Therefore, the style of the MathImage is altered, i.e. the style attribute display: block; margin: auto; is added. For MathML, it is ensured that display=inline is replaced by display block which produces a new paragraph.

Not specified

If nothing is specified, the equation is rendered in the same display style as "block", but without using a new paragraph. If the equation does appear on a line by itself, it is not automatically indented.

The sum converges to 2;
the vertical space between lines is disturbed by large operators.

Or:

The sum

converges to 2.

In both cases, the math is coded as:

<math>\sum_{i=0}^\infty 2^{-i}</math>

Equation numbering

The templates {{NumBlk}} and {{EquationRef}} can be used to number equations. The template {{EquationNote}} can be used to refer to a numbered equation from surrounding text. For example, the following syntax:

{{NumBlk|:|<math>x^2 + y^2 + z^2 = 1</math>|{{EquationRef|1}}}}

produces the following result (note the equation number in the right margin):

Later on, the text can refer to this equation by its number using syntax like this:

As seen in equation ({{EquationNote|1}}), example text...

The result looks like this:

As seen in equation (1), example text...

The equation number produced by {{EquationNote}} is a link that the user can click to go immediately to the cited equation.