Changes
→Pros of HTML
{{H:h|editor toc}}
[[w:MediaWiki|MediaWiki]] uses a subset of '''[[w:TeX|TeX]] markup''', including some extensions from LaTeX and AMSLaTeX, for mathematical formulae. It generates either [[w:PNG|PNG]] images or simple [[w:HTML|HTML]] markup, depending on [[Help:Preferences#Rendering_math|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 [[w:MathML|MathML]] in many cases. (See [[blahtex]] for information about current work on adding MathML support.)
More precisely, MediaWiki filters the markup through [[w:Texvc|Texvc]], which in turn passes the commands to TeX for the actual [[w:Rendering (computer graphics)|render]]ing. Thus, only a limited part of the full TeX language is supported; see below for details.
==Syntax==
Math markup goes inside <code><nowiki><math> ... </math></nowiki></code>. The [[Help:Edit toolbar|edit toolbar]] has a button for this.
Similarly to HTML, in TeX extra spaces and newlines are ignored.
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 then and else part of #if, etc. See {{tim|Demo of attempt to use parameters within TeX}}.
==Rendering==
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. Vertical alignment with the surrounding text can also be a problem. The [[Help:User style#CSS_selectors|css selector]] of the images is img.tex.
It should be pointed out that most of these shortcomings have been addressed by [[m:Help talk:Formula#Maynard_Handley.27s_suggestions|Maynard Handley]], but have not been released yet.
The <code>alt</code> attribute of the PNG images (the text that is displayed if your browser can't display images; Internet Explorer shows it up in the hover box) is the wikitext that produced them, excluding the <code><nowiki><math></nowiki></code> and <code><nowiki></math></nowiki></code>.
Apart from function and operator names, as is customary in mathematics for variables, letters are in italics; digits are not. For other text, (like variable labels) to avoid being rendered in italics like variables, use <code>\mbox</code> or <code>\mathrm</code>. For example, <code><nowiki><math>\mbox{abc}</math></nowiki></code> gives <math>\mbox{abc}</math>.
==TeX vs HTML==
Before introducing TeX markup for producing special characters, it should be noted that, as this comparison table shows, sometimes similar results can be achieved in HTML (see [[Help:Special characters]]).
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;"
|-
! TeX Syntax ([[#Forced_PNG_rendering|forcing PNG]])
! TeX Rendering
! HTML Syntax
! HTML Rendering
|-
| <tt><nowiki><math>\alpha\,</math></nowiki></tt>
| <math>\alpha\,</math>
| <tt><nowiki>&alpha;</nowiki></tt>
| α
|-
| <tt><nowiki><math>\sqrt{2}</math></nowiki></tt>
| <math>\sqrt{2}</math>
| <tt><nowiki>&radic;2</nowiki></tt>
| √2
|-
| <tt><nowiki><math>\sqrt{1-e^2}</math></nowiki></tt>
| <math>\sqrt{1-e^2}</math>
| <tt><nowiki>&radic;(1&minus;''e''&sup2;)</nowiki></tt>
| √(1−''e''²)
|}
The use of HTML instead of TeX is still under discussion. The arguments either way can be summarised
as follows.
===Pros of HTML===
# In-line HTML formulae always align properly with the rest of the HTML text.
# The formula's background, font size and face match the rest of HTML contents and the appearance respects CSS and browser settings.
# Pages using HTML will load faster.
===Pros of TeX===
# TeX is semantically superior to HTML. In TeX, "<code><nowiki><math>x</math></nowiki></code>" means "mathematical variable <math>x</math>", whereas in HTML "<code>x</code>" could mean anything. Information has been irrevocably lost.
# TeX has been specifically designed for typesetting formulae, so input is easier and more natural, and output is more aesthetically pleasing.
# One consequence of point 1 is that TeX can be transformed into HTML, but not vice-versa. This means that on the server side we can always transform a formula, based on its complexity and location within the text, user preferences, type of browser, etc. Therefore, where possible, all the benefits of HTML can be retained, together with the benefits of TeX. It's true that the current situation is not ideal, but that's not a good reason to drop information/contents. It's more a reason to [[#Bug_reports|help improve the situation]].
# When writing in TeX, editors need not worry about whether this or that version of this or that browser supports this or that HTML entity. The burden of these decisions is put on the server. This doesn't hold for HTML formulae, which can easily end up being rendered wrongly or differently from the editor's intentions on a different browser.
== Functions, symbols, special characters ==
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;"
|-
! Feature
! Syntax
! How it looks rendered
|-
| Accents/Diacritics
| <pre>\acute{a} \quad \grave{a} \quad \hat{a}
\tilde{a} \quad \breve{a} \quad \check{a} \quad \bar{a}
\ddot{a} \quad \dot{a}</pre>
| <math>\acute{a} \quad \grave{a} \quad \hat{a}</math><br />
<math>\tilde{a} \quad \breve{a} \quad \check{a} \quad \bar{a}</math><br />
<math>\ddot{a} \quad \dot{a}</math>
|-
| Std. functions (good)
| <pre>\sin a \ \cos b \ \tan c \ \cot d
\sec e \ \csc f
\arcsin k \ \arccos l \ \arctan m
\sinh g \ \cosh h \ \tanh i \ \coth j
\operatorname{sh}\,g \ \operatorname{argsh}\,k
\operatorname{ch}\,h \ \operatorname{argch}\,l
\operatorname{th}\,i \ \operatorname{argth}\,m
\lim n \ \limsup o \ \liminf p
\min q \ \max r \ \inf s \ \sup t
\exp u \ \ln v \ \lg w \ \log x \ \log_{10} y
\ker x \ \deg x \ \gcd x \ \Pr x
\det x \ \hom x \ \arg x \ \dim x</pre>
| <math>\sin a \ \cos b \ \tan c \ \cot d</math><br/>
<math>\sec e \ \csc f</math><br/>
<math>\arcsin k \ \arccos l \ \arctan m</math><br/>
<math>\sinh g \ \cosh h \ \tanh i \ \coth j</math><br/>
<math>\operatorname{sh}\,g \ \operatorname{argsh}\,k</math><br/>
<math>\operatorname{ch}\,h \ \operatorname{argch}\,l</math><br/>
<math>\operatorname{th}\,i \ \operatorname{argth}\,m</math><br/>
<math>\lim n \ \limsup o \ \liminf p</math><br/>
<math>\min q \ \max r \ \inf s \ \sup t</math><br/>
<math>\exp u \ \ln v \ \lg w \ \log x \ \log_{10} y</math><br/>
<math>\ker x \ \deg x \ \gcd x \ \Pr x</math><br/>
<math>\det x \ \hom x \ \arg x \ \dim x</math>
|-
| ''Std. functions (wrong)''
| <pre>sin x + ln y + sgn z</pre>
| <math>sin x + ln y + sgn z\,\!</math>
|-
| Modular arithmetic
| <pre>s_k \equiv 0 \pmod{m}
a \bmod b</pre>
| <math>s_k \equiv 0 \pmod{m}</math><br/>
<math>a \bmod b\,\!</math>
|-
| Derivatives
| <pre>\nabla \; \partial x \; dx \; \dot x \; \ddot y</pre>
| <math>\nabla \; \partial x \; dx \; \dot x \; \ddot y</math>
|-
| rowspan="2" | Sets<br/>
(Square symbols may not work for some wikis)
| <pre>\forall \; \exists \; \empty \; \emptyset \; \varnothing
\in \ni \not\in \notin \subset \subseteq
\supset \supseteq \cap \bigcap \cup \bigcup \biguplus
\setminus \; \smallsetminus</pre>
| <math>\forall \; \exists \; \empty \; \emptyset \; \varnothing</math><br/>
<math>\in \ni \not\in \notin \subset \subseteq</math><br/>
<math>\supset \supseteq \cap \bigcap \cup \bigcup \biguplus</math><br/>
<math>\setminus \; \smallsetminus</math>
|-
| <pre>\sqsubset \sqsubseteq \sqsupset \sqsupseteq
\sqcap \sqcup \bigsqcup</pre>
| <math>\sqsubset \sqsubseteq \sqsupset \sqsupseteq</math><br/>
<math>\sqcap \sqcup \bigsqcup</math>
|-
|Operators
| <pre>+ \; \oplus \; \bigoplus \; \pm \; \mp \; -
\times \; \otimes \; \bigotimes
\cdot \; \circ \; \bullet \; \bigodot \; \star \; *
/ \; \div \; \begin{matrix} \frac{1}{2} \end{matrix}</pre>
| <math>+ \; \oplus \; \bigoplus \; \pm \; \mp \; -</math><br/>
<math>\times \; \otimes \; \bigotimes </math><br/>
<math>\cdot \; \circ \; \bullet \; \bigodot \; \star \; *</math><br/>
<math>/ \; \div \; \begin{matrix} \frac{1}{2} \end{matrix}</math>
|-
| Logic
| <pre>p \land \wedge \; \bigwedge \; \bar{q} \to p
\lor \; \vee \; \bigvee \; \lnot \; \neg q</pre>
| <math>p \land \wedge \; \bigwedge \; \bar{q} \to p</math><br/>
<math>\lor \; \vee \; \bigvee \; \lnot \; \neg q</math>
|-
| rowspan="2" | Root
| <pre>\sqrt{2}\approx 1.4</pre>
| <math>\sqrt{2}\approx 1.4</math>
|-
| <pre>\sqrt[n]{x}</pre>
| <math>\sqrt[n]{x}</math>
|-
| Relations
| <pre>\sim \; \approx \; \simeq \; \cong \; \dot=
\le \; < \; \ll \; \gg \; \ge >
\equiv \; \not\equiv \; \ne \mbox{or} \neq \; \propto</pre>
| <math>\sim \; \approx \; \simeq \; \cong \; \dot=</math><br/>
<math>\le \; < \; \ll \; \gg \; \ge \; ></math><br/>
<math>\equiv \; \not\equiv \; \ne \mbox{or} \neq \; \propto</math>
|-
| Geometric
| <pre>\Diamond \; \Box \; \triangle \; \angle \; \perp
\; \mid \; \nmid \; \<nowiki>|</nowiki> \; 45^\circ</pre>
| <math>\Diamond \; \Box \; \triangle \; \angle \; \perp
\; \mid \; \nmid \; \| \; 45^\circ</math>
|-
| rowspan="3" | Arrows<br/>
(Harpoons may not work for some wikis)
| <pre>\leftarrow \; \gets \; \rightarrow \; \to \; \not\to
\leftrightarrow \; \longleftarrow \; \longrightarrow
\mapsto \; \longmapsto
\hookrightarrow \; \hookleftarrow
\nearrow \; \searrow \; \swarrow \; \nwarrow
\uparrow \; \downarrow \; \updownarrow</pre>
| <math>\leftarrow \; \gets \; \rightarrow \; \to \; \not\to</math><br/>
<math>\leftrightarrow \; \longleftarrow \; \longrightarrow</math><br/>
<math>\mapsto \; \longmapsto</math><br/>
<math>\hookrightarrow \; \hookleftarrow</math><br/>
<math>\nearrow \; \searrow \; \swarrow \; \nwarrow</math><br/>
<math>\uparrow \; \downarrow \; \updownarrow</math>
|-
| <pre>\rightharpoonup \; \rightharpoondown
\; \leftharpoonup \; \leftharpoondown
\; \upharpoonleft \; \upharpoonright
\; \downharpoonleft \; \downharpoonright</pre>
| <math>\rightharpoonup \; \rightharpoondown
\; \leftharpoonup \; \leftharpoondown
\; \upharpoonleft \; \upharpoonright
\; \downharpoonleft \; \downharpoonright</math>
|-
| <pre>\Leftarrow \; \Rightarrow \; \Leftrightarrow
\Longleftarrow \; \Longrightarrow
\Longleftrightarrow (or \iff)
\Uparrow \; \Downarrow \; \Updownarrow</pre>
| <math>\Leftarrow \; \Rightarrow \; \Leftrightarrow</math><br/>
<math>\Longleftarrow \; \Longrightarrow</math><br/>
<math>\Longleftrightarrow (or \iff)</math><br/>
<math>\Uparrow \; \Downarrow \; \Updownarrow</math>
|-
|rowspan="4"| Special
| <pre>\eth \; \S \; \P \; \% \; \dagger \; \ddagger
\ldots \smile \frown \wr</pre>
| <math>\eth \; \S \; \P \; \% \; \dagger \; \ddagger</math><br/>
<math>\ldots \; \smile \frown \wr</math>
|-
| <pre>\triangleleft \triangleright \infty \bot \top
\vdash \vDash \Vdash \models \lVert \rVert</pre>
| <math>\triangleleft \triangleright \infty \bot \top</math><br/>
<math>\vdash \vDash \Vdash \models \lVert \rVert</math>
|-
| <pre>\imath \; \hbar \; \ell \; \mho \; \Finv
\Re \; \Im \; \wp \; \complement</pre>
| <math>\imath \; \hbar \; \ell \; \mho \; \Finv</math><br/>
<math>\Re \; \Im \; \wp \; \complement</math>
|-
| <pre>\diamondsuit \; \heartsuit \; \clubsuit \; \spadesuit
\Game \; \flat \; \natural \; \sharp</pre>
| <math>\diamondsuit \; \heartsuit \; \clubsuit \; \spadesuit</math><br/>
<math>\Game \; \flat \; \natural \; \sharp</math>
|-
| Lowercase \mathcal has some extras
| <pre>\mathcal{5} \; \mathcal{abcde \; pqs}</pre>
| <math>\mathcal{5} \; \mathcal{abcde \; pqs}</math>
|}
== Subscripts, superscripts, integrals ==
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;"
!rowspan="2"|Feature!!rowspan="2"|Syntax!!colspan="2"|How it looks rendered
|-
!HTML!!PNG
|-
|-
|Superscript||<pre>a^2</pre>||<math>a^2</math>||<math>a^2 \,\!</math>
|-
|Subscript||<pre>a_2</pre>||<math>a_2</math>||<math>a_2 \,\!</math>
|-
|rowspan=2|Grouping||<pre>a^{2+2}</pre>||<math>a^{2+2}</math>||<math>a^{2+2}\,\!</math>
|-
|<pre>a_{i,j}</pre>||<math>a_{i,j}</math>||<math>a_{i,j}\,\!</math>
|-
|Combining sub & super||<pre>x_2^3</pre>||colspan=2|<math>x_2^3</math>
|-
|Preceding sub & super||<pre>{}_1^2\!X_3^4</pre>||colspan=2|<math>{}_1^2\!X_3^4</math>
|-
|Derivative (forced PNG)||<pre>x', y'', f', f''\!</pre>|| ||<math>x', y'', f', f''\!</math>
|-
|Derivative (f in italics may overlap primes in HTML)||<pre>x', y'', f', f''</pre>||<math>x', y'', f', f''</math>||<math>x', y'', f', f''\!</math>
|-
|Derivative (wrong in HTML)||<pre>x^\prime, y^{\prime\prime}</pre>||<math>x^\prime, y^{\prime\prime}</math>||<math>x^\prime, y^{\prime\prime}\,\!</math>
|-
|Derivative (wrong in PNG)||<pre>x\prime, y\prime\prime</pre>||<math>x\prime, y\prime\prime</math>||<math>x\prime, y\prime\prime\,\!</math>
|-
|Derivative dots||<pre>\dot{x}, \ddot{x}</pre>||colspan=2|<math>\dot{x}, \ddot{x}</math>
|-
|rowspan="3"|Underlines, overlines, vectors||<pre>\hat a \ \bar b \ \vec c</pre>||colspan=2|<math>\hat a \ \bar b \ \vec c</math>
|-
|<pre>\overrightarrow{a b} \ \overleftarrow{c d} \ \widehat{d e f}</pre>||colspan=2|<math>\overrightarrow{a b} \ \overleftarrow{c d} \ \widehat{d e f}</math>
|-
|<pre>\overline{g h i} \ \underline{j k l}</pre>||colspan=2|<math>\overline{g h i} \ \underline{j k l}</math>
|-
|Overbraces||<pre>\begin{matrix} 5050 \\ \overbrace{ 1+2+\cdots+100 } \end{matrix}</pre>||colspan=2|<math>\begin{matrix} 5050 \\ \overbrace{ 1+2+\cdots+100 } \end{matrix}</math>
|-
|Underbraces||<pre>\begin{matrix} \underbrace{ a+b+\cdots+z } \\ 26 \end{matrix}</pre>||colspan=2|<math>\begin{matrix} \underbrace{ a+b+\cdots+z } \\ 26 \end{matrix}</math>
|-
|Sum||<pre>\sum_{k=1}^N k^2</pre>||colspan=2|<math>\sum_{k=1}^N k^2</math>
|-
|Sum (force <tt>\textstyle</tt>)||<pre>\begin{matrix} \sum_{k=1}^N k^2 \end{matrix}</pre>||colspan=2|<math>\begin{matrix} \sum_{k=1}^N k^2 \end{matrix}</math>
|-
|Product||<pre>\prod_{i=1}^N x_i</pre>||colspan=2|<math>\prod_{i=1}^N x_i</math>
|-
|Product (force <tt>\textstyle</tt>)||<pre>\begin{matrix} \prod_{i=1}^N x_i \end{matrix}</pre>||colspan=2|<math>\begin{matrix} \prod_{i=1}^N x_i \end{matrix}</math>
|-
|Coproduct||<pre>\coprod_{i=1}^N x_i</pre>||colspan=2|<math>\coprod_{i=1}^N x_i</math>
|-
|Coproduct (force <tt>\textstyle</tt>)||<pre>\begin{matrix} \coprod_{i=1}^N x_i \end{matrix}</pre>||colspan=2|<math>\begin{matrix} \coprod_{i=1}^N x_i \end{matrix}</math>
|-
|Limit||<pre>\lim_{n \to \infty}x_n</pre>||colspan=2|<math>\lim_{n \to \infty}x_n</math>
|-
|Limit (force <tt>\textstyle</tt>)||<pre>\begin{matrix} \lim_{n \to \infty}x_n \end{matrix}</pre>||colspan=2|<math>\begin{matrix} \lim_{n \to \infty}x_n \end{matrix}</math>
|-
|Integral||<pre>\int_{-N}^{N} e^x\, dx</pre>||colspan=2|<math>\int_{-N}^{N} e^x\, dx</math>
|-
|Integral (force <tt>\textstyle</tt>)||<pre>\begin{matrix} \int_{-N}^{N} e^x\, dx \end{matrix}</pre>||colspan=2|<math>\begin{matrix} \int_{-N}^{N} e^x\, dx \end{matrix}</math>
|-
|Double integral||<pre>\iint_{D}^{W} \, dx\,dy</pre>||colspan=2|<math>\iint_{D}^{W} \, dx\,dy</math>
|-
|Triple integral||<pre>\iiint_{E}^{V} \, dx\,dy\,dz</pre>||colspan=2|<math>\iiint_{E}^{V} \, dx\,dy\,dz</math>
|-
|Quadruple integral||<pre>\iiiint_{F}^{U} \, dx\,dy\,dz\,dt</pre>||colspan=2|<math>\iiiint_{F}^{U} \, dx\,dy\,dz\,dt</math>
|-
|Path integral||<pre>\oint_{C} x^3\, dx + 4y^2\, dy</pre>||colspan=2|<math>\oint_{C} x^3\, dx + 4y^2\, dy</math>
|-
|Intersections||<pre>\bigcap_1^{n} p</pre>||colspan=2|<math>\bigcap_1^{n} p</math>
|-
|Unions||<pre>\bigcup_1^{k} p</pre>||colspan=2|<math>\bigcup_1^{k} p</math>
|}
== Fractions, matrices, multilines ==
<table class="wikitable">
<tr>
<th>Feature</th>
<th>Syntax</th>
<th>How it looks rendered</th>
</tr>
<tr>
<td>Fractions</td>
<td>\frac{2}{4}=0.5 or {2 \over 4}=0.5</td>
<td><math>\frac{2}{4}=0.5</math></td>
</tr>
<tr>
<td>Small Fractions (force <tt>\textstyle</tt>)</td>
<td>\begin{matrix} \frac{2}{4} \end{matrix} = 0.5</td>
<td><math>\begin{matrix} \frac{2}{4} \end{matrix} = 0.5</math></td>
</tr>
<tr>
<td>Binomial coefficients</td>
<td>{n \choose k}</td>
<td><math>{n \choose k}</math></td>
</tr>
<tr>
<td rowspan="6">Matrices</td>
<td>\begin{matrix} x & y \\ z & v \end{matrix}</td>
<td><math>\begin{matrix} x & y \\ z & v
\end{matrix}</math></td>
</tr>
<tr>
<td>\begin{vmatrix} x & y \\ z & v \end{vmatrix}</td>
<td><math>\begin{vmatrix} x & y \\ z & v
\end{vmatrix}</math></td>
</tr>
<tr>
<td>\begin{Vmatrix} x & y \\ z & v \end{Vmatrix}</td>
<td><math>\begin{Vmatrix} x & y \\ z & v
\end{Vmatrix}</math></td>
</tr>
<tr>
<td>\begin{bmatrix} 0 & \cdots & 0 \\ \vdots &
\ddots & \vdots \\ 0 & \cdots &
0\end{bmatrix}</td>
<td><math>\begin{bmatrix} 0 & \cdots & 0 \\ \vdots
& \ddots & \vdots \\ 0 & \cdots &
0\end{bmatrix} </math></td>
</tr>
<tr>
<td>\begin{Bmatrix} x & y \\ z & v \end{Bmatrix}</td>
<td><math>\begin{Bmatrix} x & y \\ z & v
\end{Bmatrix}</math></td>
</tr>
<tr>
<td>\begin{pmatrix} x & y \\ z & v \end{pmatrix}</td>
<td><math>\begin{pmatrix} x & y \\ z & v
\end{pmatrix}</math></td>
</tr>
<tr>
<td>Case distinctions</td>
<td>f(n) = \begin{cases} n/2, & \mbox{if }n\mbox{ is even} \\ 3n+1, & \mbox{if }n\mbox{ is odd} \end{cases}</td>
<td><math>f(n) = \begin{cases} n/2, & \mbox{if }n\mbox{ is even} \\ 3n+1, & \mbox{if }n\mbox{ is odd} \end{cases} </math></td>
</tr>
<tr>
<td>Multiline equations</td>
<td>\begin{matrix}f(n+1) & = & (n+1)^2 \\ \ &
= & n^2 + 2n + 1 \end{matrix}</td>
<td><math>\begin{matrix}f(n+1) & = & (n+1)^2 \\ \ & = & n^2 + 2n + 1 \end{matrix}</math></td>
</tr>
<tr>
<td>Alternative multiline equations (using tables)</td>
<td><pre>
<nowiki>
{| border="0" cellpadding="0" cellspacing="0"
|-
|<math>f(n+1)</math>
|<math>=(n+1)^2</math>
|-
|
|<math>=n^2 + 2n + 1</math>
|}
</nowiki>
</pre>
</td>
<td>
{| border="0" cellpadding="0" cellspacing="0"
|-
|<math>f(n+1) \,\!</math>
|<math>=(n+1)^2 \,\!</math>
|-
|
|<math>=n^2 + 2n + 1 \,\!</math>
|}
</td>
</tr>
<tr>
<td>Breaking up a long expression so that it wraps when necessary</td>
<td><pre>
<nowiki>
<math>f(x) \,\!</math>
<math>= \sum_{n=0}^\infty a_n x^n </math>
<math>= a_0 + a_1 x + a_2 x^2 + a_3 x^3 + \cdots</math>
</nowiki>
</pre>
</td>
<td>
<math>f(x) \,\!</math><math>= \sum_{n=0}^\infty a_n x^n </math><math>= a_0 + a_1 x + a_2 x^2 + a_3 x^3 + \cdots</math>
</td>
</tr>
<tr>
<td>Simultaneous equations</td>
<td>\begin{cases} 3 x + 5 y + z \\ 7 x - 2 y + 4 z \\ -6 x + 3 y + 2 z \end{cases}</td>
<td><math>\begin{cases} 3 x + 5 y + z \\ 7 x - 2 y + 4 z \\ -6 x + 3 y + 2 z \end{cases}</math></td>
</tr>
</table>
== Alphabets and typefaces ==
<table class="wikitable">
<tr>
<th>Feature</th>
<th>Syntax</th>
<th colspan="2">How it looks rendered</th>
</tr>
<tr>
<td>[[w:Greek alphabet|Greek alphabet]]<br/>(Note the lack of omicron; note also that several upper case Greek letters are rendered identically to the corresponding Roman ones)</td>
<td>
\Alpha\ \Beta\ \Gamma\ \Delta\ \Epsilon\ \Zeta\ \Eta\ \Theta\ \Iota\ \Kappa\ \Lambda\ \Mu\ \Nu\ \Xi\ \Pi\ \Rho\ \Sigma\ \Tau\ \Upsilon\ \Phi\ \Chi\ \Psi\ \Omega<br/><br/>
\alpha\ \beta\ \gamma\ \delta\ \epsilon\ \zeta\ \eta\ \theta\ \iota\ \kappa\ \lambda\ \mu\ \nu\ \xi\ \pi\ \rho\ \sigma\ \tau\ \upsilon\ \phi\ \chi\ \psi\ \omega<br/><br/>
\varepsilon\ \digamma\ \vartheta\ \varkappa\ \varpi\ \varrho\ \varsigma\ \varphi
</td>
<td colspan="2">
<math>\Alpha\ \Beta\ \Gamma\ \Delta\ \Epsilon\ \Zeta\ \Eta\ \Theta\ \Iota\ \Kappa\ \Lambda\ \Mu\ \Nu\ \Xi\ \Pi\ \Rho\ \Sigma\ \Tau\ \Upsilon\ \Phi\ \Chi\ \Psi\ \Omega</math><br/><br/>
<math>\alpha\ \beta\ \gamma\ \delta\ \epsilon\ \zeta\ \eta\ \theta\ \iota\ \kappa\ \lambda\ \mu\ \nu\ \xi\ \pi\ \rho\ \sigma\ \tau\ \upsilon\ \phi\ \chi\ \psi\ \omega</math><br/><br/>
<math>\varepsilon\ \digamma\ \vartheta\ \varkappa\ \varpi\ \varrho\ \varsigma\ \varphi</math>
</td>
</tr>
<tr>
<td>[[w:Blackboard bold|blackboard bold]]</td>
<td>\mathbb{N}\ \mathbb{Z}\ \mathbb{D}\ \mathbb{Q}\ \mathbb{R}\ \mathbb{C}\ \mathbb{H}</td>
<td colspan="2"><math>\mathbb{N}\ \mathbb{Z}\ \mathbb{D}\ \mathbb{Q}\ \mathbb{R}\ \mathbb{C}\ \mathbb{H}</math></td>
</tr>
<tr>
<td>[[w:boldface|boldface]] (vectors)</td>
<td>\mathbf{x}\cdot\mathbf{y} = 0</td>
<td colspan="2"><math>\mathbf{x}\cdot\mathbf{y} = 0</math></td>
</tr>
<tr>
<td>boldface (greek)</td>
<td>\boldsymbol{\alpha} + \boldsymbol{\beta} + \boldsymbol{\gamma}</td>
<td colspan="2"><math>\boldsymbol{\alpha} + \boldsymbol{\beta} + \boldsymbol{\gamma}</math></td>
</tr>
<tr>
<td>italics</td>
<td>\mathit{ABCDE abcde 1234}</td>
<td colspan="2"><math>\mathit{ABCDE abcde 1234}\,\!</math></td>
</tr>
<tr>
<td>[[w:Roman typeface|Roman typeface]]</td>
<td>\mathrm{ABCDE abcde 1234}</td>
<td colspan="2"><math>\mathrm{ABCDE abcde 1234}\,\!</math></td>
</tr>
<tr>
<td>[[w:Fraktur (typeface)|Fraktur typeface]]</td>
<td>\mathfrak{ABCDE abcde 1234}</td>
<td colspan="2"><math>\mathfrak{ABCDE abcde 1234}</math></td>
</tr>
<tr>
<td>Calligraphy/Script</td>
<td>\mathcal{ABCDE abcde 1234}</td>
<td colspan="2"><math>\mathcal{ABCDE abcde 1234}</math></td>
</tr>
<tr>
<td>[[w:Hebrew alphabet|Hebrew]]</td>
<td>\aleph \beth \gimel \daleth</td>
<td colspan="2"><math>\aleph\ \beth\ \gimel\ \daleth</math></td>
</tr>
<tr>
<td>non-italicised characters</td>
<td>\mbox{abc}</td>
<td><math>\mbox{abc}</math></td>
<td><math>\mbox{abc} \,\!</math></td>
</tr>
<tr>
<td>mixed italics (bad)</td>
<td>\mbox{if} n \mbox{is even}</td>
<td><math>\mbox{if} n \mbox{is even}</math></td>
<td><math>\mbox{if} n \mbox{is even} \,\!</math></td>
</tr>
<tr>
<td>mixed italics (good)</td>
<td>\mbox{if }n\mbox{ is even}</td>
<td><math>\mbox{if }n\mbox{ is even}</math></td>
<td><math>\mbox{if }n\mbox{ is even} \,\!</math></td>
</tr>
<tr>
<td>mixed italics (more legible: ~ is a non-breaking space, while "\ " forces a space)</td>
<td>\mbox{if}~n\ \mbox{is even}</td>
<td><math>\mbox{if}~n\ \mbox{is even}</math></td>
<td><math>\mbox{if}~n\ \mbox{is even} \,\!</math></td>
</tr>
</table>
== Parenthesizing big expressions, brackets, bars ==
<table border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;">
<tr>
<th>Feature</th>
<th>Syntax</th>
<th>How it looks rendered</th>
</tr>
<tr>
<td>Bad</td>
<td>( \frac{1}{2} )</td>
<td><math>( \frac{1}{2} )</math></td>
</tr>
<tr>
<td>Good</td>
<td>\left ( \frac{1}{2} \right )</td>
<td><math>\left ( \frac{1}{2} \right )</math></td>
</tr>
</table>
You can use various delimiters with \left and \right:
<table border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;">
<tr>
<th>Feature</th>
<th>Syntax</th>
<th>How it looks rendered</th>
</tr>
<tr>
<td>Parentheses</td>
<td>\left ( \frac{a}{b} \right )</td>
<td><math>\left ( \frac{a}{b} \right )</math></td>
</tr>
<tr>
<td>Brackets</td>
<td>\left [ \frac{a}{b} \right ] \quad \left \lbrack \frac{a}{b} \right \rbrack</td>
<td><math>\left [ \frac{a}{b} \right ] \quad \left \lbrack \frac{a}{b} \right \rbrack</math></td>
</tr>
<tr>
<td>Braces</td>
<td>\left \{ \frac{a}{b} \right \} \quad \left \lbrace \frac{a}{b} \right \rbrace</td>
<td><math>\left \{ \frac{a}{b} \right \} \quad \left \lbrace \frac{a}{b} \right \rbrace</math></td>
</tr>
<tr>
<td>Angle brackets</td>
<td>\left \langle \frac{a}{b} \right \rangle</td>
<td><math>\left \langle \frac{a}{b} \right \rangle</math></td>
</tr>
<tr>
<td>Bars and double bars</td>
<td>\left | \frac{a}{b} \right \vert \left \Vert \frac{c}{d} \right \|</td>
<td><math>\left | \frac{a}{b} \right \vert \left \Vert \frac{c}{d} \right \|</math></td>
</tr>
<tr>
<td>Floor and ceiling functions:</td>
<td>\left \lfloor \frac{a}{b} \right \rfloor \left \lceil \frac{c}{d} \right \rceil</td>
<td><math>\left \lfloor \frac{a}{b} \right \rfloor \left \lceil \frac{c}{d} \right \rceil</math></td>
</tr>
<tr>
<td>Slashes and backslashes</td>
<td>\left / \frac{a}{b} \right \backslash</td>
<td><math>\left / \frac{a}{b} \right \backslash</math></td>
</tr>
<tr>
<td>Up, down and up-down arrows</td>
<td>\left \uparrow \frac{a}{b} \right \downarrow \quad \left \Uparrow \frac{a}{b} \right \Downarrow \quad \left \updownarrow \frac{a}{b} \right \Updownarrow</td>
<td><math>\left \uparrow \frac{a}{b} \right \downarrow \quad \left \Uparrow \frac{a}{b} \right \Downarrow \quad \left \updownarrow \frac{a}{b} \right \Updownarrow</math></td>
</tr>
<tr>
<td>
Delimiters can be mixed,<br/>as long as \left and \right match
</td>
<td>
\left [ 0,1 \right )<br/>\left \langle \psi \right |
</td>
<td>
<math>\left [ 0,1 \right )</math><br/><math>\left \langle \psi \right |</math>
</td>
</tr>
<tr>
<td>Use \left. and \right. if you don't<br/>want a delimiter to appear:</td>
<td>\left . \frac{A}{B} \right \} \to X</td>
<td><math>\left . \frac{A}{B} \right \} \to X</math></td>
</tr>
<tr>
<td rowspan="7">Size of the delimiters</td>
<td>\big( \Big( \bigg( \Bigg( ... \Bigg] \bigg] \Big] \big]</td>
<td colspan="2">
<math>\big( \Big( \bigg( \Bigg( ... \Bigg] \bigg] \Big] \big]</math>
</td>
</tr>
<tr>
<td>\big\{ \Big\{ \bigg\{ \Bigg\{ ... \Bigg\rangle \bigg\rangle \Big\rangle \big\rangle</td>
<td colspan="2">
<math>\big\{ \Big\{ \bigg\{ \Bigg\{ ... \Bigg\rangle \bigg\rangle \Big\rangle \big\rangle</math>
</td>
</tr>
<tr>
<td>\big\| \Big\| \bigg\| \Bigg\| ... \Bigg| \bigg| \Big| \big|</td>
<td colspan="2"><math>\big\| \Big\| \bigg\| \Bigg\| ... \Bigg| \bigg| \Big| \big|</math></td>
</tr>
<tr>
<td>\big\lfloor \Big\lfloor \bigg\lfloor \Bigg\lfloor ... \Bigg\rceil \bigg\rceil \Big\rceil \big\rceil</td>
<td colspan="2">
<math>\big\lfloor \Big\lfloor \bigg\lfloor \Bigg\lfloor ... \Bigg\rceil \bigg\rceil \Big\rceil \big\rceil</math>
</td>
</tr>
<tr>
<td>\big\uparrow \Big\uparrow \bigg\uparrow \Bigg\uparrow ... \Bigg\Downarrow \bigg\Downarrow \Big\Downarrow \big\Downarrow</td>
<td colspan="2">
<math>\big\uparrow \Big\uparrow \bigg\uparrow \Bigg\uparrow ... \Bigg\Downarrow \bigg\Downarrow \Big\Downarrow \big\Downarrow</math>
</td>
</tr>
<tr>
<td>\big\updownarrow \Big\updownarrow \bigg\updownarrow \Bigg\updownarrow ... \Bigg\Updownarrow \bigg\Updownarrow \Big\Updownarrow \big\Updownarrow</td>
<td colspan="2">
<math>\big\updownarrow \Big\updownarrow \bigg\updownarrow \Bigg\updownarrow ... \Bigg\Updownarrow \bigg\Updownarrow \Big\Updownarrow \big\Updownarrow</math>
</td>
</tr>
<tr>
<td>\big / \Big / \bigg / \Bigg / ... \Bigg\backslash \bigg\backslash \Big\backslash \big\backslash</td>
<td colspan="2">
<math>\big / \Big / \bigg / \Bigg / ... \Bigg\backslash \bigg\backslash \Big\backslash \big\backslash</math>
</td>
</tr>
</table>
== Spacing ==
Note that TeX handles most spacing automatically, but you may sometimes want manual control.
<table border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;">
<tr>
<th>Feature</th>
<th>Syntax</th>
<th>How it looks rendered</th>
</tr>
<tr>
<td>double quad space</td>
<td>a \qquad b</td>
<td><math>a \qquad b</math></td>
</tr>
<tr>
<td>quad space</td>
<td>a \quad b</td>
<td><math>a \quad b</math></td>
</tr>
<tr>
<td>text space</td>
<td>a\ b</td>
<td><math>a\ b</math></td>
</tr>
<tr>
<td>text space without PNG conversion</td>
<td>a \mbox{ } b</td>
<td><math>a \mbox{ } b</math></td>
</tr>
<tr>
<td>large space</td>
<td>a\;b</td>
<td><math>a\;b</math></td>
</tr>
<tr>
<td>medium space</td>
<td>a\>b</td>
<td>[not supported]</td>
</tr>
<tr>
<td>small space</td>
<td>a\,b</td>
<td><math>a\,b</math></td>
</tr>
<tr>
<td>no space</td>
<td>ab</td>
<td><math>ab\,</math></td>
</tr>
<tr>
<td>small negative space</td>
<td>a\!b</td>
<td><math>a\!b</math></td>
</tr>
</table>
== Align with normal text flow ==
Due to the default css
<pre>img.tex { vertical-align: middle; }</pre>
an inline expression like <math>\int_{-N}^{N} e^x\, dx</math> should look good.
If you need to align it otherwise, use <tt><nowiki><font style="vertical-align:-100%;"><math>...</math></font></nowiki></tt> and play with the <tt>vertical-align</tt> argument until you get it right; however, how it looks may depend on the browser and the browser settings.
Also note that if you rely on this workaround, if/when the rendering on the server gets fixed in future releases, as a result of this extra manual offset your formulae will suddenly be aligned incorrectly. So use it sparingly, if at all.
== Forced PNG rendering ==
To force the formula to render as PNG, add <tt>\,</tt> (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 [[Help:Preferences|preferences]]).
You can also use <tt>\,\!</tt> (small space and negative space, which cancel out) anywhere inside the math tags. This ''does'' force PNG even in "HTML if possible" mode, unlike <tt>\,</tt>.
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:
<table border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;">
<tr>
<th>Syntax</th>
<th>How it looks rendered</th>
</tr>
<tr>
<td>a^{c+2}</td>
<td><math>a^{c+2}</math></td>
</tr>
<tr>
<td>a^{c+2} \,</td>
<td><math>a^{c+2} \,</math></td>
</tr>
<tr>
<td>a^{\,\!c+2}</td>
<td><math>a^{\,\!c+2}</math> </td>
</tr>
<tr>
<td>a^{b^{c+2}}</td>
<td><math>a^{b^{c+2}}</math> (WRONG with option "HTML if possible or else PNG"!)</td>
</tr>
<tr>
<td>a^{b^{c+2}} \,</td>
<td><math>a^{b^{c+2}} \,</math> (WRONG with option "HTML if possible or else PNG"!)</td>
</tr>
<tr>
<td>a^{b^{c+2}}\approx 5</td>
<td><math>a^{b^{c+2}}\approx 5</math> (due to "<math>\approx</math>" correctly displayed, no code "\,\!" needed)</td>
</tr>
<tr>
<td>a^{b^{\,\!c+2}}</td>
<td><math>a^{b^{\,\!c+2}}</math></td>
</tr>
<tr>
<td>\int_{-N}^{N} e^x\, dx</td>
<td><math>\int_{-N}^{N} e^x\, dx</math></td>
</tr>
</table>
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:
:''<nowiki><!-- The \,\! is to keep the formula rendered as PNG instead of HTML. Please don't remove it.--></nowiki>''
== Color ==
Equations can use color:
*<tt>{\color{Blue}x^2}+{\color{Brown}2x}-{\color{OliveGreen}1}</tt>
*:<math>{\color{Blue}x^2}+{\color{Brown}2x}-{\color{OliveGreen}1}</math>
*<tt>x_{1,2}=\frac{-b\pm\sqrt{\color{Red}b^2-4ac}}{2a}</tt>
*:<math>x_{1,2}=\frac{-b\pm\sqrt{\color{Red}b^2-4ac}}{2a}</math>
Note that color should not be used as the ''only'' way to identify something because color blind people may not be able to distinguish between the two colors. See [[en:Wikipedia:Manual of Style#Formatting issues]].
== Examples ==
<center>
===Quadratic Polynomial===
<math>ax^2 + bx + c = 0</math>
<nowiki><math>ax^2 + bx + c = 0</math></nowiki>
===Quadratic Polynomial (Force PNG Rendering)===
<math>ax^2 + bx + c = 0\,</math>
<nowiki><math>ax^2 + bx + c = 0\,</math></nowiki>
===Quadratic Formula===
<math>x_{1,2}=\frac{-b\pm\sqrt{b^2-4ac}}{2a}</math>
<nowiki><math>x_{1,2}=\frac{-b\pm\sqrt{b^2-4ac}}{2a}</math></nowiki>
===Tall Parentheses and Fractions ===
<math>2 = \left( \frac{\left(3-x\right) \times 2}{3-x} \right)</math>
<nowiki><math>2 = \left( \frac{\left(3-x\right) \times 2}{3-x} \right)</math></nowiki>
<math>S_{new} = S_{old} + \frac{ \left( 5-T \right) ^2} {2}</math>
<nowiki><math>S_{new} = S_{old} + \frac{ \left( 5-T \right) ^2} {2}</math></nowiki>
===Integrals===
<math>\int_a^x \int_a^s f(y)\,dy\,ds = \int_a^x f(y)(x-y)\,dy</math>
<nowiki><math>\int_a^x \int_a^s f(y)\,dy\,ds = \int_a^x f(y)(x-y)\,dy</math></nowiki>
===Summation===
<math>\sum_{m=1}^\infty\sum_{n=1}^\infty\frac{m^2\,n}{3^m\left(m\,3^n+n\,3^m\right)}</math>
<nowiki><math>\sum_{m=1}^\infty\sum_{n=1}^\infty\frac{m^2\,n}</nowiki>
<nowiki>{3^m\left(m\,3^n+n\,3^m\right)}</math></nowiki>
=== Differential Equation ===
<math>u'' + p(x)u' + q(x)u=f(x),\quad x>a</math>
<nowiki><math>u'' + p(x)u' + q(x)u=f(x),\quad x>a</math></nowiki>
===Complex numbers===
<math>|\bar{z}| = |z|, |(\bar{z})^n| = |z|^n, \arg(z^n) = n \arg(z)\,</math>
<nowiki><math>|\bar{z}| = |z|, |(\bar{z})^n| = |z|^n, \arg(z^n) = n \arg(z)\,</math></nowiki>
===Limits===
<math>\lim_{z\rightarrow z_0} f(z)=f(z_0)\,</math>
<nowiki><math>\lim_{z\rightarrow z_0} f(z)=f(z_0)\,</math></nowiki>
===Integral Equation===
<math>\phi_n(\kappa) = \frac{1}{4\pi^2\kappa^2} \int_0^\infty \frac{\sin(\kappa R)}{\kappa R} \frac{\partial}{\partial R}\left[R^2\frac{\partial D_n(R)}{\partial R}\right]\,dR</math>
<nowiki><math>\phi_n(\kappa) = \frac{1}{4\pi^2\kappa^2} \int_0^\infty</nowiki>
<nowiki>\frac{\sin(\kappa R)}{\kappa R} \frac{\partial}{\partial R}\left[R^2\frac{\partial</nowiki>
<nowiki>D_n(R)}{\partial R}\right]\,dR</math></nowiki>
===Example===
<math>\phi_n(\kappa) = 0.033C_n^2\kappa^{-11/3},\quad \frac{1}{L_0}\ll\kappa\ll\frac{1}{l_0}\,</math>
<nowiki><math>\phi_n(\kappa) = </nowiki>
<nowiki>0.033C_n^2\kappa^{-11/3},\quad \frac{1}{L_0}\ll\kappa\ll\frac{1}{l_0}\,</math></nowiki>
===Continuation and cases===
<math>f(x) = \begin{cases}1 & -1 \le x < 0 \\
\frac{1}{2} & x = 0 \\ 1 - x^2 & 0 < x \le 1\end{cases}</math>
<nowiki><math>f(x) = \begin{cases}1 & -1 \le x < 0 \\</nowiki>
<nowiki>\frac{1}{2} & x = 0 \\ 1 - x^2 & 0 < x\le 1\end{cases}</math></nowiki>
===Prefixed subscript===
<math>{}_pF_q(a_1,...,a_p;c_1,...,c_q;z) = \sum_{n=0}^\infty \frac{(a_1)_n\cdot\cdot\cdot(a_p)_n}{(c_1)_n\cdot\cdot\cdot(c_q)_n}\frac{z^n}{n!}\,</math>
<nowiki> <math>{}_pF_q(a_1,...,a_p;c_1,...,c_q;z) = \sum_{n=0}^\infty</nowiki>
<nowiki>\frac{(a_1)_n\cdot\cdot\cdot(a_p)_n}{(c_1)_n\cdot\cdot\cdot(c_q)_n}\frac{z^n}{n!}\,</math></nowiki>
</center>
==Bug reports==
Discussions, bug reports and feature requests should go to the [[m:Mailing list#Wikitech|Wikitech-l mailing list]]. These can also be filed on [[Bugzilla:|Mediazilla]] under ''MediaWiki extensions''.
==See also==
*[[w:Wikipedia:How to write a Wikipedia article on Mathematics#Typesetting_of_mathematical_formulas|Typesetting of mathematical formulas]]
* Proposed [[m:GNU LilyPond support]]
*[[w:Table of mathematical symbols|Table of mathematical symbols]]
*[[m:Blahtex]], or [[w:Wikipedia talk:WikiProject Mathematics/Archive10#blahtex: a LaTeX to MathML converter|blahtex: a LaTeX to MathML converter for Wikipedia]]
*[[Help:Editing|General help]] for editing a Wiki page
*[[Mimetex alternative]] for an another way to display mathematics using Mimetex.cgi
== External links ==
* A LaTeX tutorial. http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/
* A [[w:Portable Document Format|PDF]] document introducing TeX -- see page 39 onwards for a good introduction to the maths side of things: http://www.ctan.org/tex-archive/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 AMS-LaTeX. http://www.ctan.org/tex-archive/info/lshort/english/lshort.pdf
* TeX reference card: http://www.csit.fsu.edu/docs/tex/tex-refcard-letter.pdf
* http://www.ams.org/tex/amslatex.html
* A set of public domain fixed-size math symbol bitmaps: http://us.metamath.org/symbols/symbols.html
* [[w:MathML|MathML]] - A product of the [[w:W3C|W3C]] Math working group, is a low-level specification for describing mathematics as a basis for machine to machine communication. [http://www.w3.org/Math/ http://www.w3.org/Math/]
{{H:f|langs=|enname=Formula}}<!--When translating leave this line intact-->
[[w:MediaWiki|MediaWiki]] uses a subset of '''[[w:TeX|TeX]] markup''', including some extensions from LaTeX and AMSLaTeX, for mathematical formulae. It generates either [[w:PNG|PNG]] images or simple [[w:HTML|HTML]] markup, depending on [[Help:Preferences#Rendering_math|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 [[w:MathML|MathML]] in many cases. (See [[blahtex]] for information about current work on adding MathML support.)
More precisely, MediaWiki filters the markup through [[w:Texvc|Texvc]], which in turn passes the commands to TeX for the actual [[w:Rendering (computer graphics)|render]]ing. Thus, only a limited part of the full TeX language is supported; see below for details.
==Syntax==
Math markup goes inside <code><nowiki><math> ... </math></nowiki></code>. The [[Help:Edit toolbar|edit toolbar]] has a button for this.
Similarly to HTML, in TeX extra spaces and newlines are ignored.
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 then and else part of #if, etc. See {{tim|Demo of attempt to use parameters within TeX}}.
==Rendering==
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. Vertical alignment with the surrounding text can also be a problem. The [[Help:User style#CSS_selectors|css selector]] of the images is img.tex.
It should be pointed out that most of these shortcomings have been addressed by [[m:Help talk:Formula#Maynard_Handley.27s_suggestions|Maynard Handley]], but have not been released yet.
The <code>alt</code> attribute of the PNG images (the text that is displayed if your browser can't display images; Internet Explorer shows it up in the hover box) is the wikitext that produced them, excluding the <code><nowiki><math></nowiki></code> and <code><nowiki></math></nowiki></code>.
Apart from function and operator names, as is customary in mathematics for variables, letters are in italics; digits are not. For other text, (like variable labels) to avoid being rendered in italics like variables, use <code>\mbox</code> or <code>\mathrm</code>. For example, <code><nowiki><math>\mbox{abc}</math></nowiki></code> gives <math>\mbox{abc}</math>.
==TeX vs HTML==
Before introducing TeX markup for producing special characters, it should be noted that, as this comparison table shows, sometimes similar results can be achieved in HTML (see [[Help:Special characters]]).
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;"
|-
! TeX Syntax ([[#Forced_PNG_rendering|forcing PNG]])
! TeX Rendering
! HTML Syntax
! HTML Rendering
|-
| <tt><nowiki><math>\alpha\,</math></nowiki></tt>
| <math>\alpha\,</math>
| <tt><nowiki>&alpha;</nowiki></tt>
| α
|-
| <tt><nowiki><math>\sqrt{2}</math></nowiki></tt>
| <math>\sqrt{2}</math>
| <tt><nowiki>&radic;2</nowiki></tt>
| √2
|-
| <tt><nowiki><math>\sqrt{1-e^2}</math></nowiki></tt>
| <math>\sqrt{1-e^2}</math>
| <tt><nowiki>&radic;(1&minus;''e''&sup2;)</nowiki></tt>
| √(1−''e''²)
|}
The use of HTML instead of TeX is still under discussion. The arguments either way can be summarised
as follows.
===Pros of HTML===
# In-line HTML formulae always align properly with the rest of the HTML text.
# The formula's background, font size and face match the rest of HTML contents and the appearance respects CSS and browser settings.
# Pages using HTML will load faster.
===Pros of TeX===
# TeX is semantically superior to HTML. In TeX, "<code><nowiki><math>x</math></nowiki></code>" means "mathematical variable <math>x</math>", whereas in HTML "<code>x</code>" could mean anything. Information has been irrevocably lost.
# TeX has been specifically designed for typesetting formulae, so input is easier and more natural, and output is more aesthetically pleasing.
# One consequence of point 1 is that TeX can be transformed into HTML, but not vice-versa. This means that on the server side we can always transform a formula, based on its complexity and location within the text, user preferences, type of browser, etc. Therefore, where possible, all the benefits of HTML can be retained, together with the benefits of TeX. It's true that the current situation is not ideal, but that's not a good reason to drop information/contents. It's more a reason to [[#Bug_reports|help improve the situation]].
# When writing in TeX, editors need not worry about whether this or that version of this or that browser supports this or that HTML entity. The burden of these decisions is put on the server. This doesn't hold for HTML formulae, which can easily end up being rendered wrongly or differently from the editor's intentions on a different browser.
== Functions, symbols, special characters ==
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;"
|-
! Feature
! Syntax
! How it looks rendered
|-
| Accents/Diacritics
| <pre>\acute{a} \quad \grave{a} \quad \hat{a}
\tilde{a} \quad \breve{a} \quad \check{a} \quad \bar{a}
\ddot{a} \quad \dot{a}</pre>
| <math>\acute{a} \quad \grave{a} \quad \hat{a}</math><br />
<math>\tilde{a} \quad \breve{a} \quad \check{a} \quad \bar{a}</math><br />
<math>\ddot{a} \quad \dot{a}</math>
|-
| Std. functions (good)
| <pre>\sin a \ \cos b \ \tan c \ \cot d
\sec e \ \csc f
\arcsin k \ \arccos l \ \arctan m
\sinh g \ \cosh h \ \tanh i \ \coth j
\operatorname{sh}\,g \ \operatorname{argsh}\,k
\operatorname{ch}\,h \ \operatorname{argch}\,l
\operatorname{th}\,i \ \operatorname{argth}\,m
\lim n \ \limsup o \ \liminf p
\min q \ \max r \ \inf s \ \sup t
\exp u \ \ln v \ \lg w \ \log x \ \log_{10} y
\ker x \ \deg x \ \gcd x \ \Pr x
\det x \ \hom x \ \arg x \ \dim x</pre>
| <math>\sin a \ \cos b \ \tan c \ \cot d</math><br/>
<math>\sec e \ \csc f</math><br/>
<math>\arcsin k \ \arccos l \ \arctan m</math><br/>
<math>\sinh g \ \cosh h \ \tanh i \ \coth j</math><br/>
<math>\operatorname{sh}\,g \ \operatorname{argsh}\,k</math><br/>
<math>\operatorname{ch}\,h \ \operatorname{argch}\,l</math><br/>
<math>\operatorname{th}\,i \ \operatorname{argth}\,m</math><br/>
<math>\lim n \ \limsup o \ \liminf p</math><br/>
<math>\min q \ \max r \ \inf s \ \sup t</math><br/>
<math>\exp u \ \ln v \ \lg w \ \log x \ \log_{10} y</math><br/>
<math>\ker x \ \deg x \ \gcd x \ \Pr x</math><br/>
<math>\det x \ \hom x \ \arg x \ \dim x</math>
|-
| ''Std. functions (wrong)''
| <pre>sin x + ln y + sgn z</pre>
| <math>sin x + ln y + sgn z\,\!</math>
|-
| Modular arithmetic
| <pre>s_k \equiv 0 \pmod{m}
a \bmod b</pre>
| <math>s_k \equiv 0 \pmod{m}</math><br/>
<math>a \bmod b\,\!</math>
|-
| Derivatives
| <pre>\nabla \; \partial x \; dx \; \dot x \; \ddot y</pre>
| <math>\nabla \; \partial x \; dx \; \dot x \; \ddot y</math>
|-
| rowspan="2" | Sets<br/>
(Square symbols may not work for some wikis)
| <pre>\forall \; \exists \; \empty \; \emptyset \; \varnothing
\in \ni \not\in \notin \subset \subseteq
\supset \supseteq \cap \bigcap \cup \bigcup \biguplus
\setminus \; \smallsetminus</pre>
| <math>\forall \; \exists \; \empty \; \emptyset \; \varnothing</math><br/>
<math>\in \ni \not\in \notin \subset \subseteq</math><br/>
<math>\supset \supseteq \cap \bigcap \cup \bigcup \biguplus</math><br/>
<math>\setminus \; \smallsetminus</math>
|-
| <pre>\sqsubset \sqsubseteq \sqsupset \sqsupseteq
\sqcap \sqcup \bigsqcup</pre>
| <math>\sqsubset \sqsubseteq \sqsupset \sqsupseteq</math><br/>
<math>\sqcap \sqcup \bigsqcup</math>
|-
|Operators
| <pre>+ \; \oplus \; \bigoplus \; \pm \; \mp \; -
\times \; \otimes \; \bigotimes
\cdot \; \circ \; \bullet \; \bigodot \; \star \; *
/ \; \div \; \begin{matrix} \frac{1}{2} \end{matrix}</pre>
| <math>+ \; \oplus \; \bigoplus \; \pm \; \mp \; -</math><br/>
<math>\times \; \otimes \; \bigotimes </math><br/>
<math>\cdot \; \circ \; \bullet \; \bigodot \; \star \; *</math><br/>
<math>/ \; \div \; \begin{matrix} \frac{1}{2} \end{matrix}</math>
|-
| Logic
| <pre>p \land \wedge \; \bigwedge \; \bar{q} \to p
\lor \; \vee \; \bigvee \; \lnot \; \neg q</pre>
| <math>p \land \wedge \; \bigwedge \; \bar{q} \to p</math><br/>
<math>\lor \; \vee \; \bigvee \; \lnot \; \neg q</math>
|-
| rowspan="2" | Root
| <pre>\sqrt{2}\approx 1.4</pre>
| <math>\sqrt{2}\approx 1.4</math>
|-
| <pre>\sqrt[n]{x}</pre>
| <math>\sqrt[n]{x}</math>
|-
| Relations
| <pre>\sim \; \approx \; \simeq \; \cong \; \dot=
\le \; < \; \ll \; \gg \; \ge >
\equiv \; \not\equiv \; \ne \mbox{or} \neq \; \propto</pre>
| <math>\sim \; \approx \; \simeq \; \cong \; \dot=</math><br/>
<math>\le \; < \; \ll \; \gg \; \ge \; ></math><br/>
<math>\equiv \; \not\equiv \; \ne \mbox{or} \neq \; \propto</math>
|-
| Geometric
| <pre>\Diamond \; \Box \; \triangle \; \angle \; \perp
\; \mid \; \nmid \; \<nowiki>|</nowiki> \; 45^\circ</pre>
| <math>\Diamond \; \Box \; \triangle \; \angle \; \perp
\; \mid \; \nmid \; \| \; 45^\circ</math>
|-
| rowspan="3" | Arrows<br/>
(Harpoons may not work for some wikis)
| <pre>\leftarrow \; \gets \; \rightarrow \; \to \; \not\to
\leftrightarrow \; \longleftarrow \; \longrightarrow
\mapsto \; \longmapsto
\hookrightarrow \; \hookleftarrow
\nearrow \; \searrow \; \swarrow \; \nwarrow
\uparrow \; \downarrow \; \updownarrow</pre>
| <math>\leftarrow \; \gets \; \rightarrow \; \to \; \not\to</math><br/>
<math>\leftrightarrow \; \longleftarrow \; \longrightarrow</math><br/>
<math>\mapsto \; \longmapsto</math><br/>
<math>\hookrightarrow \; \hookleftarrow</math><br/>
<math>\nearrow \; \searrow \; \swarrow \; \nwarrow</math><br/>
<math>\uparrow \; \downarrow \; \updownarrow</math>
|-
| <pre>\rightharpoonup \; \rightharpoondown
\; \leftharpoonup \; \leftharpoondown
\; \upharpoonleft \; \upharpoonright
\; \downharpoonleft \; \downharpoonright</pre>
| <math>\rightharpoonup \; \rightharpoondown
\; \leftharpoonup \; \leftharpoondown
\; \upharpoonleft \; \upharpoonright
\; \downharpoonleft \; \downharpoonright</math>
|-
| <pre>\Leftarrow \; \Rightarrow \; \Leftrightarrow
\Longleftarrow \; \Longrightarrow
\Longleftrightarrow (or \iff)
\Uparrow \; \Downarrow \; \Updownarrow</pre>
| <math>\Leftarrow \; \Rightarrow \; \Leftrightarrow</math><br/>
<math>\Longleftarrow \; \Longrightarrow</math><br/>
<math>\Longleftrightarrow (or \iff)</math><br/>
<math>\Uparrow \; \Downarrow \; \Updownarrow</math>
|-
|rowspan="4"| Special
| <pre>\eth \; \S \; \P \; \% \; \dagger \; \ddagger
\ldots \smile \frown \wr</pre>
| <math>\eth \; \S \; \P \; \% \; \dagger \; \ddagger</math><br/>
<math>\ldots \; \smile \frown \wr</math>
|-
| <pre>\triangleleft \triangleright \infty \bot \top
\vdash \vDash \Vdash \models \lVert \rVert</pre>
| <math>\triangleleft \triangleright \infty \bot \top</math><br/>
<math>\vdash \vDash \Vdash \models \lVert \rVert</math>
|-
| <pre>\imath \; \hbar \; \ell \; \mho \; \Finv
\Re \; \Im \; \wp \; \complement</pre>
| <math>\imath \; \hbar \; \ell \; \mho \; \Finv</math><br/>
<math>\Re \; \Im \; \wp \; \complement</math>
|-
| <pre>\diamondsuit \; \heartsuit \; \clubsuit \; \spadesuit
\Game \; \flat \; \natural \; \sharp</pre>
| <math>\diamondsuit \; \heartsuit \; \clubsuit \; \spadesuit</math><br/>
<math>\Game \; \flat \; \natural \; \sharp</math>
|-
| Lowercase \mathcal has some extras
| <pre>\mathcal{5} \; \mathcal{abcde \; pqs}</pre>
| <math>\mathcal{5} \; \mathcal{abcde \; pqs}</math>
|}
== Subscripts, superscripts, integrals ==
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;"
!rowspan="2"|Feature!!rowspan="2"|Syntax!!colspan="2"|How it looks rendered
|-
!HTML!!PNG
|-
|-
|Superscript||<pre>a^2</pre>||<math>a^2</math>||<math>a^2 \,\!</math>
|-
|Subscript||<pre>a_2</pre>||<math>a_2</math>||<math>a_2 \,\!</math>
|-
|rowspan=2|Grouping||<pre>a^{2+2}</pre>||<math>a^{2+2}</math>||<math>a^{2+2}\,\!</math>
|-
|<pre>a_{i,j}</pre>||<math>a_{i,j}</math>||<math>a_{i,j}\,\!</math>
|-
|Combining sub & super||<pre>x_2^3</pre>||colspan=2|<math>x_2^3</math>
|-
|Preceding sub & super||<pre>{}_1^2\!X_3^4</pre>||colspan=2|<math>{}_1^2\!X_3^4</math>
|-
|Derivative (forced PNG)||<pre>x', y'', f', f''\!</pre>|| ||<math>x', y'', f', f''\!</math>
|-
|Derivative (f in italics may overlap primes in HTML)||<pre>x', y'', f', f''</pre>||<math>x', y'', f', f''</math>||<math>x', y'', f', f''\!</math>
|-
|Derivative (wrong in HTML)||<pre>x^\prime, y^{\prime\prime}</pre>||<math>x^\prime, y^{\prime\prime}</math>||<math>x^\prime, y^{\prime\prime}\,\!</math>
|-
|Derivative (wrong in PNG)||<pre>x\prime, y\prime\prime</pre>||<math>x\prime, y\prime\prime</math>||<math>x\prime, y\prime\prime\,\!</math>
|-
|Derivative dots||<pre>\dot{x}, \ddot{x}</pre>||colspan=2|<math>\dot{x}, \ddot{x}</math>
|-
|rowspan="3"|Underlines, overlines, vectors||<pre>\hat a \ \bar b \ \vec c</pre>||colspan=2|<math>\hat a \ \bar b \ \vec c</math>
|-
|<pre>\overrightarrow{a b} \ \overleftarrow{c d} \ \widehat{d e f}</pre>||colspan=2|<math>\overrightarrow{a b} \ \overleftarrow{c d} \ \widehat{d e f}</math>
|-
|<pre>\overline{g h i} \ \underline{j k l}</pre>||colspan=2|<math>\overline{g h i} \ \underline{j k l}</math>
|-
|Overbraces||<pre>\begin{matrix} 5050 \\ \overbrace{ 1+2+\cdots+100 } \end{matrix}</pre>||colspan=2|<math>\begin{matrix} 5050 \\ \overbrace{ 1+2+\cdots+100 } \end{matrix}</math>
|-
|Underbraces||<pre>\begin{matrix} \underbrace{ a+b+\cdots+z } \\ 26 \end{matrix}</pre>||colspan=2|<math>\begin{matrix} \underbrace{ a+b+\cdots+z } \\ 26 \end{matrix}</math>
|-
|Sum||<pre>\sum_{k=1}^N k^2</pre>||colspan=2|<math>\sum_{k=1}^N k^2</math>
|-
|Sum (force <tt>\textstyle</tt>)||<pre>\begin{matrix} \sum_{k=1}^N k^2 \end{matrix}</pre>||colspan=2|<math>\begin{matrix} \sum_{k=1}^N k^2 \end{matrix}</math>
|-
|Product||<pre>\prod_{i=1}^N x_i</pre>||colspan=2|<math>\prod_{i=1}^N x_i</math>
|-
|Product (force <tt>\textstyle</tt>)||<pre>\begin{matrix} \prod_{i=1}^N x_i \end{matrix}</pre>||colspan=2|<math>\begin{matrix} \prod_{i=1}^N x_i \end{matrix}</math>
|-
|Coproduct||<pre>\coprod_{i=1}^N x_i</pre>||colspan=2|<math>\coprod_{i=1}^N x_i</math>
|-
|Coproduct (force <tt>\textstyle</tt>)||<pre>\begin{matrix} \coprod_{i=1}^N x_i \end{matrix}</pre>||colspan=2|<math>\begin{matrix} \coprod_{i=1}^N x_i \end{matrix}</math>
|-
|Limit||<pre>\lim_{n \to \infty}x_n</pre>||colspan=2|<math>\lim_{n \to \infty}x_n</math>
|-
|Limit (force <tt>\textstyle</tt>)||<pre>\begin{matrix} \lim_{n \to \infty}x_n \end{matrix}</pre>||colspan=2|<math>\begin{matrix} \lim_{n \to \infty}x_n \end{matrix}</math>
|-
|Integral||<pre>\int_{-N}^{N} e^x\, dx</pre>||colspan=2|<math>\int_{-N}^{N} e^x\, dx</math>
|-
|Integral (force <tt>\textstyle</tt>)||<pre>\begin{matrix} \int_{-N}^{N} e^x\, dx \end{matrix}</pre>||colspan=2|<math>\begin{matrix} \int_{-N}^{N} e^x\, dx \end{matrix}</math>
|-
|Double integral||<pre>\iint_{D}^{W} \, dx\,dy</pre>||colspan=2|<math>\iint_{D}^{W} \, dx\,dy</math>
|-
|Triple integral||<pre>\iiint_{E}^{V} \, dx\,dy\,dz</pre>||colspan=2|<math>\iiint_{E}^{V} \, dx\,dy\,dz</math>
|-
|Quadruple integral||<pre>\iiiint_{F}^{U} \, dx\,dy\,dz\,dt</pre>||colspan=2|<math>\iiiint_{F}^{U} \, dx\,dy\,dz\,dt</math>
|-
|Path integral||<pre>\oint_{C} x^3\, dx + 4y^2\, dy</pre>||colspan=2|<math>\oint_{C} x^3\, dx + 4y^2\, dy</math>
|-
|Intersections||<pre>\bigcap_1^{n} p</pre>||colspan=2|<math>\bigcap_1^{n} p</math>
|-
|Unions||<pre>\bigcup_1^{k} p</pre>||colspan=2|<math>\bigcup_1^{k} p</math>
|}
== Fractions, matrices, multilines ==
<table class="wikitable">
<tr>
<th>Feature</th>
<th>Syntax</th>
<th>How it looks rendered</th>
</tr>
<tr>
<td>Fractions</td>
<td>\frac{2}{4}=0.5 or {2 \over 4}=0.5</td>
<td><math>\frac{2}{4}=0.5</math></td>
</tr>
<tr>
<td>Small Fractions (force <tt>\textstyle</tt>)</td>
<td>\begin{matrix} \frac{2}{4} \end{matrix} = 0.5</td>
<td><math>\begin{matrix} \frac{2}{4} \end{matrix} = 0.5</math></td>
</tr>
<tr>
<td>Binomial coefficients</td>
<td>{n \choose k}</td>
<td><math>{n \choose k}</math></td>
</tr>
<tr>
<td rowspan="6">Matrices</td>
<td>\begin{matrix} x & y \\ z & v \end{matrix}</td>
<td><math>\begin{matrix} x & y \\ z & v
\end{matrix}</math></td>
</tr>
<tr>
<td>\begin{vmatrix} x & y \\ z & v \end{vmatrix}</td>
<td><math>\begin{vmatrix} x & y \\ z & v
\end{vmatrix}</math></td>
</tr>
<tr>
<td>\begin{Vmatrix} x & y \\ z & v \end{Vmatrix}</td>
<td><math>\begin{Vmatrix} x & y \\ z & v
\end{Vmatrix}</math></td>
</tr>
<tr>
<td>\begin{bmatrix} 0 & \cdots & 0 \\ \vdots &
\ddots & \vdots \\ 0 & \cdots &
0\end{bmatrix}</td>
<td><math>\begin{bmatrix} 0 & \cdots & 0 \\ \vdots
& \ddots & \vdots \\ 0 & \cdots &
0\end{bmatrix} </math></td>
</tr>
<tr>
<td>\begin{Bmatrix} x & y \\ z & v \end{Bmatrix}</td>
<td><math>\begin{Bmatrix} x & y \\ z & v
\end{Bmatrix}</math></td>
</tr>
<tr>
<td>\begin{pmatrix} x & y \\ z & v \end{pmatrix}</td>
<td><math>\begin{pmatrix} x & y \\ z & v
\end{pmatrix}</math></td>
</tr>
<tr>
<td>Case distinctions</td>
<td>f(n) = \begin{cases} n/2, & \mbox{if }n\mbox{ is even} \\ 3n+1, & \mbox{if }n\mbox{ is odd} \end{cases}</td>
<td><math>f(n) = \begin{cases} n/2, & \mbox{if }n\mbox{ is even} \\ 3n+1, & \mbox{if }n\mbox{ is odd} \end{cases} </math></td>
</tr>
<tr>
<td>Multiline equations</td>
<td>\begin{matrix}f(n+1) & = & (n+1)^2 \\ \ &
= & n^2 + 2n + 1 \end{matrix}</td>
<td><math>\begin{matrix}f(n+1) & = & (n+1)^2 \\ \ & = & n^2 + 2n + 1 \end{matrix}</math></td>
</tr>
<tr>
<td>Alternative multiline equations (using tables)</td>
<td><pre>
<nowiki>
{| border="0" cellpadding="0" cellspacing="0"
|-
|<math>f(n+1)</math>
|<math>=(n+1)^2</math>
|-
|
|<math>=n^2 + 2n + 1</math>
|}
</nowiki>
</pre>
</td>
<td>
{| border="0" cellpadding="0" cellspacing="0"
|-
|<math>f(n+1) \,\!</math>
|<math>=(n+1)^2 \,\!</math>
|-
|
|<math>=n^2 + 2n + 1 \,\!</math>
|}
</td>
</tr>
<tr>
<td>Breaking up a long expression so that it wraps when necessary</td>
<td><pre>
<nowiki>
<math>f(x) \,\!</math>
<math>= \sum_{n=0}^\infty a_n x^n </math>
<math>= a_0 + a_1 x + a_2 x^2 + a_3 x^3 + \cdots</math>
</nowiki>
</pre>
</td>
<td>
<math>f(x) \,\!</math><math>= \sum_{n=0}^\infty a_n x^n </math><math>= a_0 + a_1 x + a_2 x^2 + a_3 x^3 + \cdots</math>
</td>
</tr>
<tr>
<td>Simultaneous equations</td>
<td>\begin{cases} 3 x + 5 y + z \\ 7 x - 2 y + 4 z \\ -6 x + 3 y + 2 z \end{cases}</td>
<td><math>\begin{cases} 3 x + 5 y + z \\ 7 x - 2 y + 4 z \\ -6 x + 3 y + 2 z \end{cases}</math></td>
</tr>
</table>
== Alphabets and typefaces ==
<table class="wikitable">
<tr>
<th>Feature</th>
<th>Syntax</th>
<th colspan="2">How it looks rendered</th>
</tr>
<tr>
<td>[[w:Greek alphabet|Greek alphabet]]<br/>(Note the lack of omicron; note also that several upper case Greek letters are rendered identically to the corresponding Roman ones)</td>
<td>
\Alpha\ \Beta\ \Gamma\ \Delta\ \Epsilon\ \Zeta\ \Eta\ \Theta\ \Iota\ \Kappa\ \Lambda\ \Mu\ \Nu\ \Xi\ \Pi\ \Rho\ \Sigma\ \Tau\ \Upsilon\ \Phi\ \Chi\ \Psi\ \Omega<br/><br/>
\alpha\ \beta\ \gamma\ \delta\ \epsilon\ \zeta\ \eta\ \theta\ \iota\ \kappa\ \lambda\ \mu\ \nu\ \xi\ \pi\ \rho\ \sigma\ \tau\ \upsilon\ \phi\ \chi\ \psi\ \omega<br/><br/>
\varepsilon\ \digamma\ \vartheta\ \varkappa\ \varpi\ \varrho\ \varsigma\ \varphi
</td>
<td colspan="2">
<math>\Alpha\ \Beta\ \Gamma\ \Delta\ \Epsilon\ \Zeta\ \Eta\ \Theta\ \Iota\ \Kappa\ \Lambda\ \Mu\ \Nu\ \Xi\ \Pi\ \Rho\ \Sigma\ \Tau\ \Upsilon\ \Phi\ \Chi\ \Psi\ \Omega</math><br/><br/>
<math>\alpha\ \beta\ \gamma\ \delta\ \epsilon\ \zeta\ \eta\ \theta\ \iota\ \kappa\ \lambda\ \mu\ \nu\ \xi\ \pi\ \rho\ \sigma\ \tau\ \upsilon\ \phi\ \chi\ \psi\ \omega</math><br/><br/>
<math>\varepsilon\ \digamma\ \vartheta\ \varkappa\ \varpi\ \varrho\ \varsigma\ \varphi</math>
</td>
</tr>
<tr>
<td>[[w:Blackboard bold|blackboard bold]]</td>
<td>\mathbb{N}\ \mathbb{Z}\ \mathbb{D}\ \mathbb{Q}\ \mathbb{R}\ \mathbb{C}\ \mathbb{H}</td>
<td colspan="2"><math>\mathbb{N}\ \mathbb{Z}\ \mathbb{D}\ \mathbb{Q}\ \mathbb{R}\ \mathbb{C}\ \mathbb{H}</math></td>
</tr>
<tr>
<td>[[w:boldface|boldface]] (vectors)</td>
<td>\mathbf{x}\cdot\mathbf{y} = 0</td>
<td colspan="2"><math>\mathbf{x}\cdot\mathbf{y} = 0</math></td>
</tr>
<tr>
<td>boldface (greek)</td>
<td>\boldsymbol{\alpha} + \boldsymbol{\beta} + \boldsymbol{\gamma}</td>
<td colspan="2"><math>\boldsymbol{\alpha} + \boldsymbol{\beta} + \boldsymbol{\gamma}</math></td>
</tr>
<tr>
<td>italics</td>
<td>\mathit{ABCDE abcde 1234}</td>
<td colspan="2"><math>\mathit{ABCDE abcde 1234}\,\!</math></td>
</tr>
<tr>
<td>[[w:Roman typeface|Roman typeface]]</td>
<td>\mathrm{ABCDE abcde 1234}</td>
<td colspan="2"><math>\mathrm{ABCDE abcde 1234}\,\!</math></td>
</tr>
<tr>
<td>[[w:Fraktur (typeface)|Fraktur typeface]]</td>
<td>\mathfrak{ABCDE abcde 1234}</td>
<td colspan="2"><math>\mathfrak{ABCDE abcde 1234}</math></td>
</tr>
<tr>
<td>Calligraphy/Script</td>
<td>\mathcal{ABCDE abcde 1234}</td>
<td colspan="2"><math>\mathcal{ABCDE abcde 1234}</math></td>
</tr>
<tr>
<td>[[w:Hebrew alphabet|Hebrew]]</td>
<td>\aleph \beth \gimel \daleth</td>
<td colspan="2"><math>\aleph\ \beth\ \gimel\ \daleth</math></td>
</tr>
<tr>
<td>non-italicised characters</td>
<td>\mbox{abc}</td>
<td><math>\mbox{abc}</math></td>
<td><math>\mbox{abc} \,\!</math></td>
</tr>
<tr>
<td>mixed italics (bad)</td>
<td>\mbox{if} n \mbox{is even}</td>
<td><math>\mbox{if} n \mbox{is even}</math></td>
<td><math>\mbox{if} n \mbox{is even} \,\!</math></td>
</tr>
<tr>
<td>mixed italics (good)</td>
<td>\mbox{if }n\mbox{ is even}</td>
<td><math>\mbox{if }n\mbox{ is even}</math></td>
<td><math>\mbox{if }n\mbox{ is even} \,\!</math></td>
</tr>
<tr>
<td>mixed italics (more legible: ~ is a non-breaking space, while "\ " forces a space)</td>
<td>\mbox{if}~n\ \mbox{is even}</td>
<td><math>\mbox{if}~n\ \mbox{is even}</math></td>
<td><math>\mbox{if}~n\ \mbox{is even} \,\!</math></td>
</tr>
</table>
== Parenthesizing big expressions, brackets, bars ==
<table border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;">
<tr>
<th>Feature</th>
<th>Syntax</th>
<th>How it looks rendered</th>
</tr>
<tr>
<td>Bad</td>
<td>( \frac{1}{2} )</td>
<td><math>( \frac{1}{2} )</math></td>
</tr>
<tr>
<td>Good</td>
<td>\left ( \frac{1}{2} \right )</td>
<td><math>\left ( \frac{1}{2} \right )</math></td>
</tr>
</table>
You can use various delimiters with \left and \right:
<table border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;">
<tr>
<th>Feature</th>
<th>Syntax</th>
<th>How it looks rendered</th>
</tr>
<tr>
<td>Parentheses</td>
<td>\left ( \frac{a}{b} \right )</td>
<td><math>\left ( \frac{a}{b} \right )</math></td>
</tr>
<tr>
<td>Brackets</td>
<td>\left [ \frac{a}{b} \right ] \quad \left \lbrack \frac{a}{b} \right \rbrack</td>
<td><math>\left [ \frac{a}{b} \right ] \quad \left \lbrack \frac{a}{b} \right \rbrack</math></td>
</tr>
<tr>
<td>Braces</td>
<td>\left \{ \frac{a}{b} \right \} \quad \left \lbrace \frac{a}{b} \right \rbrace</td>
<td><math>\left \{ \frac{a}{b} \right \} \quad \left \lbrace \frac{a}{b} \right \rbrace</math></td>
</tr>
<tr>
<td>Angle brackets</td>
<td>\left \langle \frac{a}{b} \right \rangle</td>
<td><math>\left \langle \frac{a}{b} \right \rangle</math></td>
</tr>
<tr>
<td>Bars and double bars</td>
<td>\left | \frac{a}{b} \right \vert \left \Vert \frac{c}{d} \right \|</td>
<td><math>\left | \frac{a}{b} \right \vert \left \Vert \frac{c}{d} \right \|</math></td>
</tr>
<tr>
<td>Floor and ceiling functions:</td>
<td>\left \lfloor \frac{a}{b} \right \rfloor \left \lceil \frac{c}{d} \right \rceil</td>
<td><math>\left \lfloor \frac{a}{b} \right \rfloor \left \lceil \frac{c}{d} \right \rceil</math></td>
</tr>
<tr>
<td>Slashes and backslashes</td>
<td>\left / \frac{a}{b} \right \backslash</td>
<td><math>\left / \frac{a}{b} \right \backslash</math></td>
</tr>
<tr>
<td>Up, down and up-down arrows</td>
<td>\left \uparrow \frac{a}{b} \right \downarrow \quad \left \Uparrow \frac{a}{b} \right \Downarrow \quad \left \updownarrow \frac{a}{b} \right \Updownarrow</td>
<td><math>\left \uparrow \frac{a}{b} \right \downarrow \quad \left \Uparrow \frac{a}{b} \right \Downarrow \quad \left \updownarrow \frac{a}{b} \right \Updownarrow</math></td>
</tr>
<tr>
<td>
Delimiters can be mixed,<br/>as long as \left and \right match
</td>
<td>
\left [ 0,1 \right )<br/>\left \langle \psi \right |
</td>
<td>
<math>\left [ 0,1 \right )</math><br/><math>\left \langle \psi \right |</math>
</td>
</tr>
<tr>
<td>Use \left. and \right. if you don't<br/>want a delimiter to appear:</td>
<td>\left . \frac{A}{B} \right \} \to X</td>
<td><math>\left . \frac{A}{B} \right \} \to X</math></td>
</tr>
<tr>
<td rowspan="7">Size of the delimiters</td>
<td>\big( \Big( \bigg( \Bigg( ... \Bigg] \bigg] \Big] \big]</td>
<td colspan="2">
<math>\big( \Big( \bigg( \Bigg( ... \Bigg] \bigg] \Big] \big]</math>
</td>
</tr>
<tr>
<td>\big\{ \Big\{ \bigg\{ \Bigg\{ ... \Bigg\rangle \bigg\rangle \Big\rangle \big\rangle</td>
<td colspan="2">
<math>\big\{ \Big\{ \bigg\{ \Bigg\{ ... \Bigg\rangle \bigg\rangle \Big\rangle \big\rangle</math>
</td>
</tr>
<tr>
<td>\big\| \Big\| \bigg\| \Bigg\| ... \Bigg| \bigg| \Big| \big|</td>
<td colspan="2"><math>\big\| \Big\| \bigg\| \Bigg\| ... \Bigg| \bigg| \Big| \big|</math></td>
</tr>
<tr>
<td>\big\lfloor \Big\lfloor \bigg\lfloor \Bigg\lfloor ... \Bigg\rceil \bigg\rceil \Big\rceil \big\rceil</td>
<td colspan="2">
<math>\big\lfloor \Big\lfloor \bigg\lfloor \Bigg\lfloor ... \Bigg\rceil \bigg\rceil \Big\rceil \big\rceil</math>
</td>
</tr>
<tr>
<td>\big\uparrow \Big\uparrow \bigg\uparrow \Bigg\uparrow ... \Bigg\Downarrow \bigg\Downarrow \Big\Downarrow \big\Downarrow</td>
<td colspan="2">
<math>\big\uparrow \Big\uparrow \bigg\uparrow \Bigg\uparrow ... \Bigg\Downarrow \bigg\Downarrow \Big\Downarrow \big\Downarrow</math>
</td>
</tr>
<tr>
<td>\big\updownarrow \Big\updownarrow \bigg\updownarrow \Bigg\updownarrow ... \Bigg\Updownarrow \bigg\Updownarrow \Big\Updownarrow \big\Updownarrow</td>
<td colspan="2">
<math>\big\updownarrow \Big\updownarrow \bigg\updownarrow \Bigg\updownarrow ... \Bigg\Updownarrow \bigg\Updownarrow \Big\Updownarrow \big\Updownarrow</math>
</td>
</tr>
<tr>
<td>\big / \Big / \bigg / \Bigg / ... \Bigg\backslash \bigg\backslash \Big\backslash \big\backslash</td>
<td colspan="2">
<math>\big / \Big / \bigg / \Bigg / ... \Bigg\backslash \bigg\backslash \Big\backslash \big\backslash</math>
</td>
</tr>
</table>
== Spacing ==
Note that TeX handles most spacing automatically, but you may sometimes want manual control.
<table border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;">
<tr>
<th>Feature</th>
<th>Syntax</th>
<th>How it looks rendered</th>
</tr>
<tr>
<td>double quad space</td>
<td>a \qquad b</td>
<td><math>a \qquad b</math></td>
</tr>
<tr>
<td>quad space</td>
<td>a \quad b</td>
<td><math>a \quad b</math></td>
</tr>
<tr>
<td>text space</td>
<td>a\ b</td>
<td><math>a\ b</math></td>
</tr>
<tr>
<td>text space without PNG conversion</td>
<td>a \mbox{ } b</td>
<td><math>a \mbox{ } b</math></td>
</tr>
<tr>
<td>large space</td>
<td>a\;b</td>
<td><math>a\;b</math></td>
</tr>
<tr>
<td>medium space</td>
<td>a\>b</td>
<td>[not supported]</td>
</tr>
<tr>
<td>small space</td>
<td>a\,b</td>
<td><math>a\,b</math></td>
</tr>
<tr>
<td>no space</td>
<td>ab</td>
<td><math>ab\,</math></td>
</tr>
<tr>
<td>small negative space</td>
<td>a\!b</td>
<td><math>a\!b</math></td>
</tr>
</table>
== Align with normal text flow ==
Due to the default css
<pre>img.tex { vertical-align: middle; }</pre>
an inline expression like <math>\int_{-N}^{N} e^x\, dx</math> should look good.
If you need to align it otherwise, use <tt><nowiki><font style="vertical-align:-100%;"><math>...</math></font></nowiki></tt> and play with the <tt>vertical-align</tt> argument until you get it right; however, how it looks may depend on the browser and the browser settings.
Also note that if you rely on this workaround, if/when the rendering on the server gets fixed in future releases, as a result of this extra manual offset your formulae will suddenly be aligned incorrectly. So use it sparingly, if at all.
== Forced PNG rendering ==
To force the formula to render as PNG, add <tt>\,</tt> (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 [[Help:Preferences|preferences]]).
You can also use <tt>\,\!</tt> (small space and negative space, which cancel out) anywhere inside the math tags. This ''does'' force PNG even in "HTML if possible" mode, unlike <tt>\,</tt>.
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:
<table border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;">
<tr>
<th>Syntax</th>
<th>How it looks rendered</th>
</tr>
<tr>
<td>a^{c+2}</td>
<td><math>a^{c+2}</math></td>
</tr>
<tr>
<td>a^{c+2} \,</td>
<td><math>a^{c+2} \,</math></td>
</tr>
<tr>
<td>a^{\,\!c+2}</td>
<td><math>a^{\,\!c+2}</math> </td>
</tr>
<tr>
<td>a^{b^{c+2}}</td>
<td><math>a^{b^{c+2}}</math> (WRONG with option "HTML if possible or else PNG"!)</td>
</tr>
<tr>
<td>a^{b^{c+2}} \,</td>
<td><math>a^{b^{c+2}} \,</math> (WRONG with option "HTML if possible or else PNG"!)</td>
</tr>
<tr>
<td>a^{b^{c+2}}\approx 5</td>
<td><math>a^{b^{c+2}}\approx 5</math> (due to "<math>\approx</math>" correctly displayed, no code "\,\!" needed)</td>
</tr>
<tr>
<td>a^{b^{\,\!c+2}}</td>
<td><math>a^{b^{\,\!c+2}}</math></td>
</tr>
<tr>
<td>\int_{-N}^{N} e^x\, dx</td>
<td><math>\int_{-N}^{N} e^x\, dx</math></td>
</tr>
</table>
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:
:''<nowiki><!-- The \,\! is to keep the formula rendered as PNG instead of HTML. Please don't remove it.--></nowiki>''
== Color ==
Equations can use color:
*<tt>{\color{Blue}x^2}+{\color{Brown}2x}-{\color{OliveGreen}1}</tt>
*:<math>{\color{Blue}x^2}+{\color{Brown}2x}-{\color{OliveGreen}1}</math>
*<tt>x_{1,2}=\frac{-b\pm\sqrt{\color{Red}b^2-4ac}}{2a}</tt>
*:<math>x_{1,2}=\frac{-b\pm\sqrt{\color{Red}b^2-4ac}}{2a}</math>
Note that color should not be used as the ''only'' way to identify something because color blind people may not be able to distinguish between the two colors. See [[en:Wikipedia:Manual of Style#Formatting issues]].
== Examples ==
<center>
===Quadratic Polynomial===
<math>ax^2 + bx + c = 0</math>
<nowiki><math>ax^2 + bx + c = 0</math></nowiki>
===Quadratic Polynomial (Force PNG Rendering)===
<math>ax^2 + bx + c = 0\,</math>
<nowiki><math>ax^2 + bx + c = 0\,</math></nowiki>
===Quadratic Formula===
<math>x_{1,2}=\frac{-b\pm\sqrt{b^2-4ac}}{2a}</math>
<nowiki><math>x_{1,2}=\frac{-b\pm\sqrt{b^2-4ac}}{2a}</math></nowiki>
===Tall Parentheses and Fractions ===
<math>2 = \left( \frac{\left(3-x\right) \times 2}{3-x} \right)</math>
<nowiki><math>2 = \left( \frac{\left(3-x\right) \times 2}{3-x} \right)</math></nowiki>
<math>S_{new} = S_{old} + \frac{ \left( 5-T \right) ^2} {2}</math>
<nowiki><math>S_{new} = S_{old} + \frac{ \left( 5-T \right) ^2} {2}</math></nowiki>
===Integrals===
<math>\int_a^x \int_a^s f(y)\,dy\,ds = \int_a^x f(y)(x-y)\,dy</math>
<nowiki><math>\int_a^x \int_a^s f(y)\,dy\,ds = \int_a^x f(y)(x-y)\,dy</math></nowiki>
===Summation===
<math>\sum_{m=1}^\infty\sum_{n=1}^\infty\frac{m^2\,n}{3^m\left(m\,3^n+n\,3^m\right)}</math>
<nowiki><math>\sum_{m=1}^\infty\sum_{n=1}^\infty\frac{m^2\,n}</nowiki>
<nowiki>{3^m\left(m\,3^n+n\,3^m\right)}</math></nowiki>
=== Differential Equation ===
<math>u'' + p(x)u' + q(x)u=f(x),\quad x>a</math>
<nowiki><math>u'' + p(x)u' + q(x)u=f(x),\quad x>a</math></nowiki>
===Complex numbers===
<math>|\bar{z}| = |z|, |(\bar{z})^n| = |z|^n, \arg(z^n) = n \arg(z)\,</math>
<nowiki><math>|\bar{z}| = |z|, |(\bar{z})^n| = |z|^n, \arg(z^n) = n \arg(z)\,</math></nowiki>
===Limits===
<math>\lim_{z\rightarrow z_0} f(z)=f(z_0)\,</math>
<nowiki><math>\lim_{z\rightarrow z_0} f(z)=f(z_0)\,</math></nowiki>
===Integral Equation===
<math>\phi_n(\kappa) = \frac{1}{4\pi^2\kappa^2} \int_0^\infty \frac{\sin(\kappa R)}{\kappa R} \frac{\partial}{\partial R}\left[R^2\frac{\partial D_n(R)}{\partial R}\right]\,dR</math>
<nowiki><math>\phi_n(\kappa) = \frac{1}{4\pi^2\kappa^2} \int_0^\infty</nowiki>
<nowiki>\frac{\sin(\kappa R)}{\kappa R} \frac{\partial}{\partial R}\left[R^2\frac{\partial</nowiki>
<nowiki>D_n(R)}{\partial R}\right]\,dR</math></nowiki>
===Example===
<math>\phi_n(\kappa) = 0.033C_n^2\kappa^{-11/3},\quad \frac{1}{L_0}\ll\kappa\ll\frac{1}{l_0}\,</math>
<nowiki><math>\phi_n(\kappa) = </nowiki>
<nowiki>0.033C_n^2\kappa^{-11/3},\quad \frac{1}{L_0}\ll\kappa\ll\frac{1}{l_0}\,</math></nowiki>
===Continuation and cases===
<math>f(x) = \begin{cases}1 & -1 \le x < 0 \\
\frac{1}{2} & x = 0 \\ 1 - x^2 & 0 < x \le 1\end{cases}</math>
<nowiki><math>f(x) = \begin{cases}1 & -1 \le x < 0 \\</nowiki>
<nowiki>\frac{1}{2} & x = 0 \\ 1 - x^2 & 0 < x\le 1\end{cases}</math></nowiki>
===Prefixed subscript===
<math>{}_pF_q(a_1,...,a_p;c_1,...,c_q;z) = \sum_{n=0}^\infty \frac{(a_1)_n\cdot\cdot\cdot(a_p)_n}{(c_1)_n\cdot\cdot\cdot(c_q)_n}\frac{z^n}{n!}\,</math>
<nowiki> <math>{}_pF_q(a_1,...,a_p;c_1,...,c_q;z) = \sum_{n=0}^\infty</nowiki>
<nowiki>\frac{(a_1)_n\cdot\cdot\cdot(a_p)_n}{(c_1)_n\cdot\cdot\cdot(c_q)_n}\frac{z^n}{n!}\,</math></nowiki>
</center>
==Bug reports==
Discussions, bug reports and feature requests should go to the [[m:Mailing list#Wikitech|Wikitech-l mailing list]]. These can also be filed on [[Bugzilla:|Mediazilla]] under ''MediaWiki extensions''.
==See also==
*[[w:Wikipedia:How to write a Wikipedia article on Mathematics#Typesetting_of_mathematical_formulas|Typesetting of mathematical formulas]]
* Proposed [[m:GNU LilyPond support]]
*[[w:Table of mathematical symbols|Table of mathematical symbols]]
*[[m:Blahtex]], or [[w:Wikipedia talk:WikiProject Mathematics/Archive10#blahtex: a LaTeX to MathML converter|blahtex: a LaTeX to MathML converter for Wikipedia]]
*[[Help:Editing|General help]] for editing a Wiki page
*[[Mimetex alternative]] for an another way to display mathematics using Mimetex.cgi
== External links ==
* A LaTeX tutorial. http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/
* A [[w:Portable Document Format|PDF]] document introducing TeX -- see page 39 onwards for a good introduction to the maths side of things: http://www.ctan.org/tex-archive/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 AMS-LaTeX. http://www.ctan.org/tex-archive/info/lshort/english/lshort.pdf
* TeX reference card: http://www.csit.fsu.edu/docs/tex/tex-refcard-letter.pdf
* http://www.ams.org/tex/amslatex.html
* A set of public domain fixed-size math symbol bitmaps: http://us.metamath.org/symbols/symbols.html
* [[w:MathML|MathML]] - A product of the [[w:W3C|W3C]] Math working group, is a low-level specification for describing mathematics as a basis for machine to machine communication. [http://www.w3.org/Math/ http://www.w3.org/Math/]
{{H:f|langs=|enname=Formula}}<!--When translating leave this line intact-->