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 LaTeX in this article). Each method has some advantages and some disadvantages, which have evolved over time with improvements to the 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.
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 the image
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}}.
Both accepted by MOS:MATH, these two methods of writing mathematical expressions—using {{math}} and LaTeX—have 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.
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.
Use {{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 {{mvar}} and {{math}} for formulas in image captions, even if the rendering is mediocre
Use LaTeX for separately displayed formulas and more complicated inline formulas
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.
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:
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|''α''}} or {{mvar|α}}
α 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'', ''π''}}}}
{1, e, π}
<math>|z| \leq 2</math>
{{math|{{abs|''z''}}≤ 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 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:
<
>
−
•
′
″
⋅
·
–
—
<
>
−
•
′
″
⋅
·
–
—
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,''β'').
To avoid line-wrapping in the middle of a formula, use {{math}}. If necessary, a non-breaking space () can be inserted with . 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:
MOS:FRAC for how to input fractions in various circumstances
MOS:RADICAL for how to square and other roots in various circumstances
Per MOS:ELLIPSIS, "..." (three ASCII periods) is used instead of "…" (single character)
Math markup goes inside <math>...</math>. Chemistry markup goes inside <mathchem>...</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.
The TeX code has to be put literally: MediaWiki templates, predefined templates, and parameters cannot be used within math tags: pairs of double braces are ignored and "#" gives an error message. However, math tags work in the true and false parameters of an #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:
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:
The backslash character \ can not be entered by adding another backslash in front of it (\\); this sequence is used for line breaking. For introducing a backslash in math mode, you can use \backslash instead which gives .
The command \tilde produces a tilde which is placed over the next letter. For example, \tilde{a} gives . To produce just a tilde character ~, use \tilde{\ } which gives , placing a ~ over an empty box. Alternatively \sim produces , a large centred ~ which may be more appropriate in some situations.
The command \hat produces a hat over the next character, for example \hat{o} produces . For a stretchable version, use \widehat{abc} giving . The wedge \wedge is normally used as a mathematical operator . The sequence {}^\wedge produces the best equivalent to the ASCII caret ^ character.
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.
Modified 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] means to add 0.6 "mu" units. Not all LaTeX units are available; available options are:
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 W̊), 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, and superscript 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
Afterward you need to bypass your browser cache, so that the new created images of the formulas are actually downloaded.
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 <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 quotation marks around 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.
Technically, the command \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}^\infty2^{-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:
Texvc (used in MediaWiki 1.32 and older) cannot render arbitrary Unicode characters. Those it can handle, can be entered by the expressions below. For others, such as Cyrillic, they can be entered as Unicode or HTML entities in running text, but cannot be used in displayed formulas.
In the above directives, the text-mode layout algorithm is used: spaces and kerning "just work". In addition to the \math...{} font directives, the text-fonts such as \textit{} are also available. The text-fonts are subtly different from their math-font siblings.
Mixed text faces
Feature
Syntax
How it looks rendered
Italicised characters (spaces are ignored)
x y z
Non-italicised characters
\text{x y z}
Mixed italics (bad)
\text{if} n \text{is even}
Mixed italics (good)
\text{if }n\text{ is even}
Mixed italics (alternative: ~ or "\ " forces a space)
\text{if}~n\\text{is even}
Color
Equations can use color with the \color command. For example,
The \color command colors all symbols to its right.
However, if the \color command is enclosed in a pair of braces (e.g. {\color{Red}...}) then no symbols outside of those braces are affected.
How it looks rendered
Syntax
Feature
x\color{Red}\neq y=z
Colors Red everything to the right of \color{Red}. To only color the symbol red, place braces around \color{Red}\neq or insert \color{black} to the right of \neq.
The outermost braces in {\color{Red}a}c limit the effect of \color{Red} to the symbol a. Similarly, \color{Blue} does not affect any symbols outside of the \sqrt{} that encloses it, and \color{Green} does not affect any symbols outside of the numerator.
To color some parts of an expression while leaving others the default black, either wrap the parts that should be colored in braces or explicitly switch back to black each time.
Some color names are predeclared according to the following table, you can use them directly for the rendering of formulas (or for declaring the intended color of the page background).
Color should not be used as the only way to identify something, because it will become meaningless on black-and-white media or for color-blind people. See WP:Manual of Style (accessibility)#Color.
LaTeX does not have a command for setting the background color. The most effective way of setting a background color is by setting a CSS styling rule for a table cell. CSS supports the HTML color names – which are different from the colors supported in LaTeX, even though some of them use the same names – and also colors specified by hex triplet or by numerical coordinates.
When relational symbols such as are employed as ordinary symbols, for example in bra–ket notation, additional spacing may have to be avoided:
Feature
Syntax
How it looks rendered
without special formatting
| \uparrow\rangle
explicit opening and closing delimiter
\left| \uparrow\right\rangle
with additional braces
| {\uparrow}\rangle
arrow as ordinary symbol
| \mathord\uparrow\rangle
Empty horizontal or vertical spacing
The phantom commands create empty horizontal and/or vertical space the same height and/or width of the argument.
Feature
Syntax
How it looks rendered
Empty horizontal and vertical spacing
\Gamma^{\phantom{i}j}_{i\phantom{j}k}
Empty vertical spacing
-e\sqrt{\vphantom{p'}p},\; -e'\sqrt{p'},\;\ldots
Empty horizontal spacing
\int u^2\,du=\underline{\hphantom{(2/3)u^3+C}}
Alignment with normal text flow
Because of the default CSS
img.tex{vertical-align:middle;}
an inline expression like should look good.
If you need to align it otherwise, use <math style="vertical-align:-100%;">...</math> and play with the vertical-align argument until you get it right; however, how it looks may depend on the browser and the browser settings.
If you rely on this workaround, if and when the rendering on the server gets fixed in a future release, this extra manual offset will suddenly make every affected formula align incorrectly. So use it sparingly, if at all.
Unimplemented elements and workarounds
The Math extension works by translating a LaTeX input to MathML and then optionally using MathJax 3 to render the MathML. As a result both the translator and MathJax can cause an equation to error out, with the feature appearing unimplemented. The authors of the Math extension try to make sure that every error is found in the "translating" step, so it is used even if not needed as a safety check. (Because MathJax's own tranlator is not used in any point, their list of differences cannot be used to predict whether an expression can be displayed through the Math extension.)
The full grammar for the subset of (La)TeX allowed by the current WikiTexVC checker can be found in parser.pegjs. This subset is much more restrictive than the MathJax subset, so do expect to see things that work in MathJax fail to work here. As the name suggests, it mostly implements the dialect accepted by texvc, representative of what was considered "enough" for LaTeX on the web circa 2007.
Special integral operators
The following integral operators that are not supported by the default font of MathJax 2.7 are available:
They have poor horizontal spacing, generate cropped SVG images unless used with other tall characters, and appear different from the usual integral symbol \int:
Elements which are not yet implemented are \oiint, namely a two-fold integral \iint() with a circular curve through the centre of the two integrals, and similarly \oiiint, a circular curve through three integrals. In contrast, \oint() exists for the single dimension (integration over a curved line within a plane or any space with higher dimension).
These elements appear in many contexts: \oiint denotes a surface integral over the closed 2d boundary of a 3d region (which occurs in much of 3d vector calculus and physical applications – like Maxwell's equations), likewise \oiiint denotes integration over the closed 3d boundary (surface volume) of a 4d region, and they would be strong candidates for the next TeX version. As such there are a lot of workarounds in the present version.
\oiint and \oiiint using currently implemented symbols
\oiint looks like:
, which uses \iint along with \subset and \supset (overdrawn after backspacing):
\iint\limits_{S}\!\!\!\!\!\!\!\!\!\!\!\subset\!\supset\mathbf D \cdot\mathrm{d}\mathbf A
, which uses \int twice (with some backward kerning) along with \bigcirc (also overdrawn after backpacing) to produce a more consistent circle:
\int\!\!\!\!\int_{\partial V}\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\;\;\;\bigcirc\,\,\mathbf D\cdot\mathrm{d}\mathbf A
\oiiint (should also be preferably more tightly kerned) looks more or less like:
which uses three \int symbols (with more backward kerning) with \subset and \supset (overdrawn after backspacing):
\int\!\!\!\!\!\int\!\!\!\!\!\int_{\partial V}\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\;\;\;\subset\!\supset\mathbf D\;\cdot\mathrm{d}\mathbf A
, which uses three \int symbols (with more backward kerning) along with \bigcirc (also overdrawn after backspacing):
\int\!\!\!\!\!\int\!\!\!\!\!\int_{\partial V}\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\;\;\;\bigcirc\,\,\mathbf D\;\cdot\mathrm{d}\mathbf A
However, since no standardisation exists as yet, any workaround like this (which uses many \! symbols for backspacing) should be avoided, if possible. See below for a possibility using PNG image enforcement.
Note that \iint (the double integral) and \iiint (the triple integral) are still not kerned as they should preferably be, and are currently rendered as if they were successive \int symbols; this is not a major problem for reading the formulas, even if the integral symbols before the last one do not have bounds, so it's best to avoid backspacing "hacks" as they may be inconsistent with a possible future better implementation of integrals symbols (with more precisely computed kerning positions).
\oiint and \oiiint as PNG images
These symbols are available as PNG images which are also integrated into two templates, {{oiint}} and {{oiiint}}, which take care of the formatting around the symbols.
The templates have three parameters:
preintegral
the text or formula immediately before the integral
intsubscpt
the subscript below the integral
integrand
the text or formula immediately after the integral
Some variants of \oiint and \oiiint have arrows on them to indicate the sense of integration, such as a line integral around a closed curve in the clockwise sense, and higher dimensional analogues. These are not implemented in TeX on Wikipedia either, although the template {{intorient}} is available - see link for details.
Arc notation \overarc
\overarc is not yet implemented to display the arc notation. However, there exists a workaround: use \overset{\frown}{AB}, which gives
Strikethrough like \sout or \st is not implemented, nor is overlapping like \rlap. This means struck characters like ƛ are difficult to type, except the hardcoded \hbar. A workaround suffix for a normal strikethrough is q \!\!\!\frac{}{\}, and for elevated strikethrough is \lambda\!\!\!^{{}^\underline{\\}}, which give
Formatting in \text
Formatting in \text is not supported. In other words, you cannot use:
\text{\textsf{textual description of a variable}}
but have to use:
\mathsf{textual\ description\ of\ a\ variable}
More specifically, in Mathoid's MathJax, no processing is done to the contents of \text at all. The texvcjs component blocks the use of macros, but another way this behavior leaks through is in the processing of quotation marks, where the Unicode version must be used instead of `:
A similar but not-quite-related issue is that there is also no such thing as a "bold sans-serif" because formatting macros cannot be nested.
\textsf{\textbf{I\ hope\ this\ is\ bold\ sf}}
Automatic line-breaking
The current image-based implementation precludes automatic line-breaking of inline formulae after binary operators and "=" as seen in TeX. The only workarounds are to not write long formulae inline, or to split the formula into separate parts at each acceptable break point.
Non-ASCII Unicode characters like π work in MathML, but not in Mathoid (server-side MathJax in SVG/PNG mode, after validation by texvcjs). They should be avoided for maximum compatibility.
MathJax itself supports Unicode characters in \text{}, but the texvcjs validator insists on blocking them (replicating old texvc behavior). A formal feature request and discussion is required to fix this.
Inline framed box
TeX has \fbox{} for putting text in a box, and LaTeX+AMSMath has \boxed{} where the inside is instead in math mode. Both are supported by MathJax, but neither is supported by Mathoid for some reason (possibly another one of those texvc bug-compatible featues). There is no workaround except using a different way to emphasize a part of your formula.
Syntax to avoid
Invisible Unicode characters
A rare but very frustrating cause of inexplicable syntax errors is invisible Unicode characters copied from some other source. For example, the Windows Calculator includes Unicode bidirectional text control characters in its output: U+202D (left-to-right override) at the beginning and U+202C (pop directional formatting) at the end. These characters can be invisibly pasted into the Wikipedia editor, but will cause Failed to parse (syntax error): messages from the LaTeX renderer, despite the source appearing to be correct. It can usually be fixed by deleting and manually retyping the beginning and end of the pasted text.
Long variable names in math mode
In LaTeX (and compatible implementations such as MathJax), the math mode is designed with the assumption that variable names should be single letters. Breaking the rule causes visibly bad kerning, such as in . To work around this problem, either avoid using these kinds of variable names, or surround them with a typeface or text directive such as \mathit{WorkTab} (see § Alphabets and typefaces above). If a function name is intended, use \operatorname{func}.
Deprecated syntax
The texvc processor accepted some non-standard control sequences. These are now deprecated for Wikipedia use because the MathJax-based renderers do not support them. This is part of an effort to update the math engine.
See mw:Extension:Math/Roadmap for details. A bot User:Texvc2LaTeXBot will replace this syntax on the English Wikipedia.
texvc syntax
Suggested replacement
Comment
$
\$
redefinition would involve changing the character code
%
\%
redefinition would involve changing the character code
If the formula reaches a certain "complexity", spaces might be ignored (<chem>A + B</chem> might be rendered as if it were <chem>A+B</chem> with a positive charge). In that case, write <chem>A{} + B</chem> (and not<chem>{A} + {B}</chem> as was previously suggested). This will allow auto-cleaning of formulas once the bug is fixed and/or a newer version of mhchem is available.
There are still major issues with mhchem support in MediaWiki. Some issues can be solved by enabling the extension using <mathchem> and formatting individual items with \ce. For example,
Note, the syntax <chem>A->[{}\atop text] B</chem>,
previously used as a workaround, currently causes render errors (as of August 2025). It should be replaced with the simpler syntax, <chem>A->[text] B</chem>.
To align the equations or color them, use <math chem> and \ce.
Commutative diagrams
1-step method
<math>\begin{array}{lcl} & X & \overset{f}\rightarrow & Z & \\ & g \downarrow && \downarrow g'\\ & Y & \underset{f'}\rightarrow & W & \\\end{array}</math>
3-step method
A sample commutative diagram, created in the manner described
\documentclass[border=10pt]{standalone}% Crop to size, remove page numbers, leave margin\usepackage[all]{xy}% Loading the XY-Pic package\begin{document}\SelectTips{eu}{}% Euler (shorter) arrowheads (tips)$$\xymatrix{%%% Diagram goes here %%%}$$\end{document}
Using postscript drivers may in some cases give smoother curves and will handle fonts differently:
\usepackage[all, ps, dvips]{xy}
Convert to SVG
Once you have produced your diagram in LaTeX (or TeX), you can convert it to an SVG file using the following sequence of commands:
pdflatexfile.tex
pdf2svgfile.pdffile.svg
The pdfcrop and pdf2svg utilities are needed for this procedure. You can alternatively use pdf2svg (redirects) from PDFTron for the last step.
If you do not have pdfTeX (which is unlikely) you can use the following commands to replace the first step (TeX → PDF):
latexfile.tex
dvipdfmfile.dvi
In general, you will not be able to get anywhere with diagrams without TeX and Ghostscript, and the inkscape program is a useful tool for creating or modifying your diagrams by hand. There is also a utility pstoedit which supports direct conversion from Postscript files to many vector graphics formats, but it requires a non-free plugin to convert to SVG, and regardless of the format, this editor has not been successful in using it to convert diagrams with diagonal arrows from TeX-created files.
As the diagram is your own work, upload it to Wikimedia Commons, so that all projects (notably, all languages) can use it without having to copy it to their language's Wiki. (If you've previously uploaded a file to somewhere other than Commons, to Commons.)
Check size
Before uploading, check that the default size of the image is neither too large nor too small by opening in an SVG application and viewing at default size (100% scaling), otherwise adjust the -y option to dvips.
Now go to the image page and add a description, including the source code, using this template:
{{Information|description ={{en|1='''Description [[:en:Link to WP page|topic]]'''}}|source ={{own}}, created as per:
[[:en:Help:Displaying a formula#Commutative diagrams]];
source code below.
|date ='''The Creation Date, like 1999-12-31'''|author ='''[[User:YourUserName|Your Real Name]]'''|permission ={{self|PD-self '''(or [[Commons:Licensing#Well-known licenses|other license]])'''|author ='''[[User:YourUserName|Your Real Name]]'''}}}}====TeX source====<syntaxhighlightlang="latex">% TeX source here</syntaxhighlight>[[Category:Commutative diagrams]][[Category:Xy-pic diagrams]][[Category:Images with LaTeX source code]]
Source code
Include the source code in the image page, in the Source section of the {{Information}} template, so that the diagram can be edited in future.
Include the complete .tex file, not just the fragment, so future editors do not need to reconstruct a compilable file.
You may optionally make the source code section collapsible, using the {{cot}} or {{cob}} templates.
(Don't include it in the Summary section, which is just supposed to be a summary.)
License
The most common license for commutative diagrams is PD-self; some use PD-ineligible, especially for simple diagrams, or other licenses. Please do not use the GFDL, as it requires the entire text of the GFDL to be attached to any document that uses the diagram.
Description
If possible, link to a Wikipedia page relevant to the diagram. (The 1= is necessary if you use nest templates within the description, and harmless otherwise.)
Category
Include [[Category:Commutative diagrams]], so that it appears in Commons:Category:Commutative diagrams. There are also subcategories, which you may choose to use.
Include image
Now include the image on the original page via [[File:Diagram.svg]]. Use [[File:Diagram.svg|class=skin-invert]] to invert colors in dark mode.
While links from formulas using LaTeX macros such as \href or \url or are currently not supported, one can link individual math expressions to Wikidata items to explain the meaning of individual terms of mathematical expressions. For example,
Markup
<math qid=Q35875>E=mc^2</math>
Renders as
links to a special page that displays additional information on that formula.
To change the information shown on the special page, navigate to the Wikidata item linked at the bottom of the special page. Use the has part property to link parts of the equation to other Wikidata items with their respective Wikipedia articles. This is not limited to individual identifiers, but can also be used to link more complex terms.
In SVG rendering mode, a condensed version of that special page is shown as a popup. However, in native MathML mode, pop-ups are displayed for individual identifiers.
Oetiker, Tobias; Partl, Hubert; Hyna, Irene; Schlegl, Elisabeth (December 13, 2009), The Not So Short Introduction to LaTeX 2ε(PDF) (4.27ed.). A paper introducing LaTeX — skip to page 49 for the math section. See page 63 for a complete reference list of symbols included in LaTeX and AMS-LaTeX.
"Handwriting Recognition". Mathpix. Optical character recognition of handwritten mathematical formulas into LaTeX and other formats, offering 10 free snips a month (registration required).
MathML: A product of the W3CMath working group, is a low-level specification for describing mathematics as a basis for machine-to-machine communication
You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.