Encyclopedia > Wikipedia:TeX markup

  Article Content

Wikipedia:TeX markup

As of January 2003, we have TeX markup for mathematical formulas on Wikipedia. It generates either PNG images or simple HTML markup, depending on user prefs and the complexity of the expression. In the future, as more browsers are smarter, it will be able to generate enhanced HTML or even MathML in many cases.

Math markup goes inside <math> ... </math>. Line breaks within these tags are fine, and aren't rendered. They're a good idea to keep the raw markup clear (for instance, a line break after each term or row of a matrix).

Discussion, bug reports and feature requests should go to the Wikitech-l mailing list or to Wikipedia:TeX requests.

For style issues regarding the typesetting of math, see Wikipedia:WikiProject Mathematics. In particular, please avoid using this feature as part of a line of regular text, as the formulas don't align properly and the font is too large.

Regarding color, notice that this page is a special page (its name begins with "Wikipedia:") and has therefore a yellow background. Normal Wikipedia pages are white, just like the formulas, so don't worry.

Table of contents

Special characters

Feature Syntax How it looks rendered
std. functions (good) \sin x + \ln y +\operatorname{sgn} z <math>\sin x + \ln y +\operatorname{sgn} z</math>
std. functions (wrong) sin x + ln y + sgn z <math>sin x + ln y + sgn z\,</math>
Derivatives \nabla \partial dx <math>\nabla \partial dx</math>
Sets \forall x\not\in\empty\subseteq A\cap B\cup \exists \{x,y\} \times C <math>\forall x \not\in \empty \subseteq A\cap B\cup \exists \{x,y\} \times C</math>
Logic p\wedge \bar{q} \rightarrow p\vee \bar{q} \Rightarrow \Leftrightarrow <math>p\wedge \bar{q} \rightarrow p\vee \bar{q} \Rightarrow \Leftrightarrow</math>
Root \sqrt{2}\approx 1.4 <math>\sqrt{2}\approx 1.4</math>
\sqrt[n]{x} <math>\sqrt[n]{x}</math>
Relations \sim \simeq \cong \le \ge \equiv \approx \ne <math> \sim \ \simeq \ \cong \ \le \ \ge \ \equiv \ \approx \ \ne</math>
Geometric \angle \perp \| <math>\angle \perp \|</math>
Special \oplus \otimes \pm \mp \hbar \dagger \ddagger \star \circ \cdot \bullet \infty <math>\oplus \otimes \pm \mp \hbar \dagger \ddagger \star \circ \cdot \bullet\ \infty</math>
Subscripts, superscripts
Feature Syntax How it looks rendered
Superscript a^2 <math>a^2</math>
Subscript a_2 <math> a_2 </math>
Grouping a^{2+2} <math>a^{2+2}</math>
a_{i,j} <math>a_{i,j}</math>
Combining sub & super x_2^3 <math>x_2^3</math>
Derivative (good) x' <math>x'</math>
Derivative (wrong in HTML) x^\prime <math>x^\prime</math>
Derivative (wrong in PNG) x\prime <math>x\prime</math>
Sum \sum_{k=1}^N k^2 <math>\sum_{k=1}^N k^2</math>
Product \prod_{i=1}^N x_i <math>\prod_{i=1}^N x_i</math>
Limit \lim_{n \to \infty}x_n <math>\lim_{n \to \infty}x_n</math>
Integral \int_{-N}^{N} e^x\, dx <math>\int_{-N}^{N} e^x\, dx</math>
Line Integral \oint_{C} x^3\, dx + 4y^2\, dy <math>\oint_{C} x^3\, dx + 4y^2\, dy</math>
Fractions, matrices, multilines
Feature Syntax How it looks rendered
Fractions \frac{2}{4} or {2 \over 4} <math>\frac{2}{4}</math>
Binomial coefficients {n \choose k} <math>{n \choose k}</math>
Matrices \begin{pmatrix} x & y \\ z & v \end{pmatrix} <math>\begin{pmatrix} x & y \\ z & v \end{pmatrix}</math>
\begin{bmatrix} 0 & \cdots & 0 \\ \vdots & \ddots & \vdots \\ 0 & \cdots & 0\end{bmatrix} <math>\begin{bmatrix} 0 & \cdots & 0 \\ \vdots & \ddots & \vdots \\ 0 & \cdots & 0\end{bmatrix} </math>
\begin{Bmatrix} x & y \\ z & v \end{Bmatrix} <math>\begin{Bmatrix} x & y \\ z & v \end{Bmatrix}</math>
\begin{vmatrix} x & y \\ z & v \end{vmatrix} <math>\begin{vmatrix} x & y \\ z & v \end{vmatrix}</math>
\begin{Vmatrix} x & y \\ z & v \end{Vmatrix} <math>\begin{Vmatrix} x & y \\ z & v \end{Vmatrix}</math>
\begin{matrix} x & y \\ z & v \end{matrix} <math>\begin{matrix} x & y \\ z & v \end{matrix}</math>
Case distinctions f(n)=\left\{\begin{matrix} n/2, & \mbox{if }n\mbox{ is even} \\ 3n+1, & \mbox{if }n\mbox{ is odd} \end{matrix}\right. <math>f(n)=\left\{\begin{matrix} n/2, & \mbox{if }n\mbox{ is even} \\ 3n+1, & \mbox{if }n\mbox{ is odd} \end{matrix}\right. </math>
Multiline equations \begin{matrix}f(n+1)&=& (n+1)^2 \\ \ & =& n^2 + 2n + 1\end{matrix} <math>\begin{matrix}f(n+1)&=& (n+1)^2 \\ \ & =& n^2 + 2n + 1\end{matrix}</math>
Feature Syntax How it looks rendered
Greek letters \alpha \beta \gamma \Gamma \phi \Phi \Psi\ \tau \Omega <math>\alpha\ \beta\ \gamma\ \Gamma\ \phi\ \Phi\ \Psi\ \tau\ \Omega</math>
Blackboard bold x\in\mathbb{R}\sub\mathbb{C} <math>x\in\mathbb{R}\subset\mathbb{C}</math>
boldface[?] (vectors) \mathbf{x}\cdot\mathbf{y} = 0 <math>\mathbf{x}\cdot\mathbf{y} = 0</math>
boldface (greek) \boldsymbol{\alpha}+\boldsymbol{\beta}+\boldsymbol{\gamma} <math>\boldsymbol{\alpha}+\boldsymbol{\beta}+\boldsymbol{\gamma}</math>
Fraktur typeface \mathfrak{a} \mathfrak{B} <math>\mathfrak{a} \mathfrak{B}</math>
Script \mathcal{ABC} <math>\mathcal{ABC}</math>
Hebrew \aleph \beth \gimel \daleth <math>\aleph\ \beth\ \gimel\ \daleth</math>
non-italicised characters \mbox{abc} <math>\mbox{abc}</math>
Parenthesizing big expressions
Feature Syntax How it looks rendered
Not good ( \frac{1}{2} ) <math>( \frac{1}{2} )</math>
Better \left( \frac{1}{2} \right) <math>\left ( \frac{1}{2} \right )</math>
You can use various delimiters with \left and \right:
Feature Syntax How it looks rendered
Parentheses \left( A \right) <math>\left( A \right)</math>
Brackets \left[ A \right] <math>\left[ A \right]</math>
Braces \left\{ A \right\} <math>\left\{ A \right\}</math>
Angle brackets \left\langle A \right\rangle <math>\left\langle A \right\rangle</math>
Bars \left| A \right| <math>\left| A \right|</math>
Use \left. and \right. if you don't want a delimiter to appear: \left. {A \over B} \right\} \to X <math>\left. {A \over B} \right\} \to X</math>
Spacing Note that TeX handles most spacing automatically, but you may sometimes want manual control.
Feature Syntax How it looks rendered
double quad space a \qquad b <math>a \qquad b</math>
quad space a \quad b <math> a \quad b</math>
text space a\ b <math>a\ b</math>
large space a\;b <math>a\;b</math>
medium space a\>b [not supported]
small space a\,b <math>a\,b</math>
no space ab <math>ab\,</math>
negative space a\!b <math>a\!b</math>

See also:

External Links

All Wikipedia text is available under the terms of the GNU Free Documentation License

  Search Encyclopedia

Search over one million articles, find something about almost anything!
  Featured Article
Wheatley Heights, New York

... a town located in Suffolk County, New York. As of the 2000 census, the town had a total population of 5,013. Geography Wheatley Heights is located at 40°45'43" ...

This page was created in 23.8 ms