Jump to content

Help:MathTest

From Wikipedia, the free encyclopedia

This page aims to cover a wide range of mathematical expressions and was generated from the documentation of the English Wikipedia [1]. Please refer to phab:T346795 for further information and to Help:MathTestNative for a version of this page that forces the new layout independent of the selected rendering mode.


Formatting using TeX

[edit]

Functions, symbols, special characters

[edit]

Accents/diacritics

[edit]
\dot{a}, \ddot{a}, \acute{a}, \grave{a} a˙,a¨,a´,a`
\check{a}, \breve{a}, \tilde{a}, \bar{a} aˇ,a˘,a~,a¯
\hat{a}, \widehat{a}, \vec{a} a^,a^,a

Standard numerical functions

[edit]
\exp_a b = a^b, \exp b = e^b, 10^m expab=ab,expb=eb,10m
\ln c, \lg d = \log e, \log_{10} f lnc,lgd=loge,log10f
\sin a, \cos b, \tan c, \cot d, \sec e, \csc f sina,cosb,tanc,cotd,sece,cscf
\arcsin h, \arccos i, \arctan j arcsinh,arccosi,arctanj
\sinh k, \cosh l, \tanh m, \coth n sinhk,coshl,tanhm,cothn
\operatorname{sh}\,k, \operatorname{ch}\,l, \operatorname{th}\,m, \operatorname{coth}\,n shk,chl,thm,cothn
\operatorname{argsh}\,o, \operatorname{argch}\,p, \operatorname{argth}\,q argsho,argchp,argthq
\sgn r, \left\vert s \right\vert sgnr,|s|
\min(x,y), \max(x,y) min(x,y),max(x,y)

Bounds

[edit]
\min x, \max y, \inf s, \sup t minx,maxy,infs,supt
\lim u, \liminf v, \limsup w limu,lim infv,lim supw
\dim p, \deg q, \det m, \ker\phi dimp,degq,detm,kerϕ

Projections

[edit]
\Pr j, \hom l, \lVert z \rVert, \arg z Prj,homl,z,argz

Differentials and derivatives

[edit]
dt, \operatorname{d}\!t, \partial t, \nabla\psi dt,dt,t,ψ
dy/dx, \operatorname{d}\!y/\operatorname{d}\!x, {dy \over dx}, {\operatorname{d}\!y\over\operatorname{d}\!x}, {\partial^2\over\partial x_1\partial x_2}y dy/dx,dy/dx,dydx,dydx,2x1x2y
\prime, \backprime, f^\prime, f', f'', f^{(3)}, \dot y, \ddot y ,,f,f,f,f(3),y˙,y¨

Letter-like symbols or constants

[edit]
\infty, \aleph, \complement, \backepsilon, \eth, \Finv, \hbar ,,,,ð,,
\Im, \imath, \jmath, \Bbbk, \ell, \mho, \wp, \Re, \circledS ,ı,ȷ,k,,,,,

Modular arithmetic

[edit]
s_k \equiv 0 \pmod{m} sk0(modm)
a\,\bmod\,b amodb
\gcd(m, n), \operatorname{lcm}(m, n) gcd(m,n),lcm(m,n)
\mid, \nmid, \shortmid, \nshortmid ,,,

Radicals

[edit]
\surd, \sqrt{2}, \sqrt[n]{}, \sqrt[3]{x^3+y^3 \over 2} ,2,n,x3+y323

Operators

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

Sets

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

Relations

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

Geometric

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

Logic

[edit]
\forall, \exists, \nexists ,,
\therefore, \because, \And ,,&
\or \lor \vee, \curlyvee, \bigvee ,,
\and \land \wedge, \curlywedge, \bigwedge ,,
\bar{q}, \bar{abc}, \overline{q}, \overline{abc},

\lnot \neg, \not\operatorname{R}, \bot, \top

q¯,abc¯,q,abc,

¬¬,R,,

\vdash \dashv, \vDash, \Vdash, \models ,,,
\Vvdash \nvdash \nVdash \nvDash \nVDash
\ulcorner \urcorner \llcorner \lrcorner

Arrows

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

Special

[edit]
\amalg \P \S \% \dagger \ddagger \ldots \cdots ⨿§%
\smile \frown \wr \triangleleft \triangleright
\diamondsuit, \heartsuit, \clubsuit, \spadesuit, \Game, \flat, \natural, \sharp ,,,,,,,

Unsorted (new stuff)

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

For a little more semantics on these symbols, see the brief TeX Cookbook.

Larger expressions

[edit]

Subscripts, superscripts, integrals

[edit]
Feature Syntax How it looks rendered
Superscript a^2 a2
Subscript a_2 a2
Grouping 10^{30} a^{2+2} 1030a2+2
a_{i,j} b_{f'} ai,jbf
Combining sub & super without and with horizontal separation x_2^3 x23
{x_2}^3 x23
Super super 10^{10^{8}} 10108
Preceding and/or additional sub & super \sideset{_1^2}{_3^4}\prod_a^b 3412ab
{}_1^2\!\Omega_3^4 12Ω34
Stacking \overset{\alpha}{\omega} ωα
\underset{\alpha}{\omega} ωα
\overset{\alpha}{\underset{\gamma}{\omega}} ωγα
\stackrel{\alpha}{\omega} ωα
Derivatives x', y'', f', f'' x,y,f,f
x^\prime, y^{\prime\prime} x,y
Derivative dots \dot{x}, \ddot{x} x˙,x¨
Underlines, overlines, vectors \hat a \ \bar b \ \vec c a^b¯c
\overrightarrow{a b} \ \overleftarrow{c d} \ \widehat{d e f} abcddef^
\overline{g h i} \ \underline{j k l} ghijkl_
Arc (workaround) \overset{\frown} {AB} AB
Arrows A \xleftarrow{n+\mu-1} B \xrightarrow[T]{n\pm i-1} C An+μ1BTn±i1C
Overbraces \overbrace{ 1+2+\cdots+100 }^{5050} 1+2++1005050
Underbraces \underbrace{ a+b+\cdots+z }_{26} a+b++z26
Sum \sum_{k=1}^N k^2 k=1Nk2
Sum (force \textstyle) \textstyle \sum_{k=1}^N k^2 k=1Nk2
Sum in a fraction (default \textstyle) \frac{\sum_{k=1}^N k^2}{a} k=1Nk2a
Sum in a fraction (force \displaystyle) \frac{\displaystyle \sum_{k=1}^N k^2}{a} k=1Nk2a
Sum in a fraction (alternative limits style) \frac{\sum\limits^{^N}_{k=1} k^2}{a} k=1Nk2a
Product \prod_{i=1}^N x_i i=1Nxi
Product (force \textstyle) \textstyle \prod_{i=1}^N x_i i=1Nxi
Coproduct \coprod_{i=1}^N x_i i=1Nxi
Coproduct (force \textstyle) \textstyle \coprod_{i=1}^N x_i i=1Nxi
Limit \lim_{n \to \infty}x_n limnxn
Limit (force \textstyle) \textstyle \lim_{n \to \infty}x_n limnxn
Integral \int\limits_{1}^{3}\frac{e^3/x}{x^2}\, dx 13e3/xx2dx
Integral (alternative limits style) \int_{1}^{3}\frac{e^3/x}{x^2}\, dx 13e3/xx2dx
Integral (force \textstyle) \textstyle \int\limits_{-N}^{N} e^x\, dx NNexdx
Integral (force \textstyle, alternative limits style) \textstyle \int_{-N}^{N} e^x\, dx NNexdx
Double integral \iint\limits_D \, dx\,dy Ddxdy
Triple integral \iiint\limits_E \, dx\,dy\,dz Edxdydz
Quadruple integral \iiiint\limits_F \, dx\,dy\,dz\,dt Fdxdydzdt
Line or path integral \int_{(x,y)\in C} x^3\, dx + 4y^2\, dy (x,y)Cx3dx+4y2dy
Closed line or path integral \oint_{(x,y)\in C} x^3\, dx + 4y^2\, dy (x,y)Cx3dx+4y2dy
Intersections \bigcap_{i=_1}^n E_i i=1nEi
Unions \bigcup_{i=_1}^n E_i i=1nEi

Fractions, matrices, multilines

[edit]
Feature Syntax How it looks rendered
Fractions \frac{2}{4}=0.5 or {2 \over 4}=0.5 24=0.5
Small fractions \tfrac{2}{4} = 0.5 24=0.5
Large (normal) fractions \dfrac{2}{4} = 0.5 \qquad \dfrac{2}{c + \dfrac{2}{d + \dfrac{2}{4}}} = a 24=0.52c+2d+24=a
Large (nested) fractions \cfrac{2}{c + \cfrac{2}{d + \cfrac{2}{4}}} = a 2c+2d+24=a
Cancellations in fractions \cfrac{x}{1 + \cfrac{\cancel{y}}{\cancel{y}}} = \cfrac{x}{2} x1+yy=x2
Binomial coefficients \binom{n}{k} (nk)
Small binomial coefficients \tbinom{n}{k} (nk)
Large (normal) binomial coefficients \dbinom{n}{k} (nk)
Matrices
\begin{matrix}
x & y \\
z & v
\end{matrix}
xyzv
\begin{vmatrix}
x & y \\
z & v
\end{vmatrix}
|xyzv|
\begin{Vmatrix}
x & y \\
z & v
\end{Vmatrix}
xyzv
\begin{bmatrix}
0 & \cdots & 0 \\
\vdots & \ddots & \vdots \\
0 & \cdots & 0
\end{bmatrix}
[0000]
\begin{Bmatrix}
x & y \\
z & v
\end{Bmatrix}
{xyzv}
\begin{pmatrix}
x & y \\
z & v
\end{pmatrix}
(xyzv)
\bigl( \begin{smallmatrix}
a&b\\ c&d
\end{smallmatrix} \bigr)
(abcd)
Case distinctions
f(n) =
\begin{cases}
n/2, & \text{if }n\text{ is even} \\
3n+1, & \text{if }n\text{ is odd}
\end{cases}
f(n)={n/2,if n is even3n+1,if n is odd
Multiline equations
\begin{align}
f(x) & = (a+b)^2 \\
& = a^2+2ab+b^2 \\
\end{align}
f(x)=(a+b)2=a2+2ab+b2
\begin{alignat}{2}
f(x) & = (a-b)^2 \\
& = a^2-2ab+b^2 \\
\end{alignat}
f(x)=(ab)2=a22ab+b2
Multiline equations (must define number of columns used ({lcr}) (should not be used unless needed)
\begin{array}{lcl}
z & = & a \\
f(x,y,z) & = & x + y + z
\end{array}
z=af(x,y,z)=x+y+z
Multiline equations (more)
\begin{array}{lcr}
z & = & a \\
f(x,y,z) & = & x + y + z
\end{array}
z=af(x,y,z)=x+y+z
Breaking up a long expression so that it wraps when necessary, at the expense of destroying correct spacing
<nowiki>
<math>f(x) \,\!</math>
<math>= \sum_{n=0}^\infty a_n x^n </math>
<math>= a_0+a_1x+a_2x^2+\cdots</math>
</nowiki>
f(x)=n=0anxn=a0+a1x+a2x2+
Simultaneous equations
\begin{cases}
3x + 5y + z \\
7x - 2y + 4z \\
-6x + 3y + 2z
\end{cases}
{3x+5y+z7x2y+4z6x+3y+2z
Arrays
\begin{array}{|c|c||c|} a & b & S \\
\hline
0&0&1\\
0&1&1\\
1&0&1\\
1&1&0\\
\end{array}
abS001011101110

Parenthesizing big expressions, brackets, bars

[edit]
Feature Syntax How it looks rendered
Bad ( \frac{1}{2} ) (12)
Good \left ( \frac{1}{2} \right ) (12)

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

Feature Syntax How it looks rendered
Parentheses \left ( \frac{a}{b} \right ) (ab)
Brackets \left [ \frac{a}{b} \right ] \quad
\left \lbrack \frac{a}{b} \right \rbrack
[ab][ab]
Braces \left \{ \frac{a}{b} \right \} \quad
\left \lbrace \frac{a}{b} \right \rbrace
{ab}{ab}
Angle brackets \left \langle \frac{a}{b} \right \rangle ab
Bars and double bars \left | \frac{a}{b} \right \vert \quad
\left \Vert \frac{c}{d} \right \|
|ab|cd
Floor and ceiling functions: \left \lfloor \frac{a}{b} \right \rfloor \quad
\left \lceil \frac{c}{d} \right \rceil
abcd
Slashes and backslashes \left / \frac{a}{b} \right \backslash /ab\
Up, down, and up-down arrows \left \uparrow \frac{a}{b} \right \downarrow \quad
\left \Uparrow \frac{a}{b} \right \Downarrow \quad
\left \updownarrow \frac{a}{b} \right \Updownarrow
ababab
Delimiters can be mixed,
as long as \left and \right match
\left [ 0,1 \right )
\left \langle \psi \right |
[0,1)
ψ|
Use \left. and \right. if you
do not want a delimiter to appear
\left . \frac{A}{B} \right \} \to X AB}X
Size of the delimiters \big( \Big( \bigg( \Bigg( \dots \Bigg] \bigg] \Big] \big] ((((]]]]
\big\{ \Big\{ \bigg\{ \Bigg\{ \dots
\Bigg\rangle \bigg\rangle \Big\rangle \big\rangle
{{{{
\big\| \Big\| \bigg\| \Bigg\| \dots \Bigg| \bigg| \Big| \big| ||||
\big\lfloor \Big\lfloor \bigg\lfloor \Bigg\lfloor \dots
\Bigg\rceil \bigg\rceil \Big\rceil \big\rceil
\big\uparrow \Big\uparrow \bigg\uparrow \Bigg\uparrow \dots
\Bigg\Downarrow \bigg\Downarrow \Big\Downarrow \big\Downarrow
\big\updownarrow \Big\updownarrow \bigg\updownarrow \Bigg\updownarrow \dots
\Bigg\Updownarrow \bigg\Updownarrow \Big\Updownarrow \big\Updownarrow
\big / \Big / \bigg / \Bigg / \dots
\Bigg\backslash \bigg\backslash \Big\backslash \big\backslash
////\\\\

Equation numbering

[edit]

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

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

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

x2+y2+z2=1

 

 

 

 

(1)

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

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

The result looks like this:

As seen in equation (1), blah blah blah...

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

Alphabets and typefaces

[edit]

Texvc 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.

Greek alphabet
\Alpha \Beta \Gamma \Delta \Epsilon \Zeta \Eta \Theta ABΓΔEZHΘ
\Iota \Kappa \Lambda \Mu \Nu \Xi \Pi \Rho IKΛMNΞΠP
\Sigma \Tau \Upsilon \Phi \Chi \Psi \Omega ΣTΥΦXΨΩ
\alpha \beta \gamma \delta \epsilon \zeta \eta \theta αβγδϵζηθ
\iota \kappa \lambda \mu \nu \xi \pi \rho ικλμνξπρ
\sigma \tau \upsilon \phi \chi \psi \omega στυϕχψω
\varepsilon \digamma \varkappa \varpi εϝϰϖ
\varrho \varsigma \vartheta \varphi ϱςϑφ
Hebrew symbols
\aleph \beth \gimel \daleth
Blackboard bold/scripts
\mathbb{ABCDEFGHI} 𝔸𝔹𝔻𝔼𝔽𝔾𝕀
\mathbb{JKLMNOPQR} 𝕁𝕂𝕃𝕄𝕆
\mathbb{STUVWXYZ} 𝕊𝕋𝕌𝕍𝕎𝕏𝕐
Boldface
\mathbf{ABCDEFGHI} ABCDEFGHI
\mathbf{JKLMNOPQR} JKLMNOPQR
\mathbf{STUVWXYZ} STUVWXYZ
\mathbf{abcdefghijklm} abcdefghijklm
\mathbf{nopqrstuvwxyz} nopqrstuvwxyz
\mathbf{0123456789} 0123456789
Boldface (Greek)
\boldsymbol{\Alpha\Beta\Gamma\Delta\Epsilon\Zeta\Eta\Theta} ABΓΔEZHΘ
\boldsymbol{\Iota\Kappa\Lambda\Mu\Nu\Xi\Pi\Rho} IKΛMNΞΠP
\boldsymbol{\Sigma\Tau\Upsilon\Phi\Chi\Psi\Omega} ΣTΥΦXΨΩ
\boldsymbol{\alpha\beta\gamma\delta\epsilon\zeta\eta\theta} αβγδϵζηθ
\boldsymbol{\iota\kappa\lambda\mu\nu\xi\pi\rho} ικλμνξπρ
\boldsymbol{\sigma\tau\upsilon\phi\chi\psi\omega} στυϕχψω
\boldsymbol{\varepsilon\digamma\varkappa\varpi} εϝϰϖ
\boldsymbol{\varrho\varsigma\vartheta\varphi} ϱςϑφ
Italics (default for Latin alphabet)
\mathit{0123456789} 0123456789
Greek italics (default for lowercase Greek)
\mathit{\Alpha\Beta\Gamma\Delta\Epsilon\Zeta\Eta\Theta} ABΓΔEZHΘ
\mathit{\Iota\Kappa\Lambda\Mu\Nu\Xi\Pi\Rho} IKΛMNΞΠP
\mathit{\Sigma\Tau\Upsilon\Phi\Chi\Psi\Omega} ΣTΥΦXΨΩ
Roman typeface
\mathrm{ABCDEFGHI} ABCDEFGHI
\mathrm{JKLMNOPQR} JKLMNOPQR
\mathrm{STUVWXYZ} STUVWXYZ
\mathrm{abcdefghijklm} abcdefghijklm
\mathrm{nopqrstuvwxyz} nopqrstuvwxyz
\mathrm{0123456789} 0123456789
Sans serif
\mathsf{ABCDEFGHI} ABCDEFGHI
\mathsf{JKLMNOPQR} JKLMNOPQR
\mathsf{STUVWXYZ} STUVWXYZ
\mathsf{abcdefghijklm} abcdefghijklm
\mathsf{nopqrstuvwxyz} nopqrstuvwxyz
\mathsf{0123456789} 0123456789
Sans serif Greek (capital only)
\mathsf{\Alpha \Beta \Gamma \Delta \Epsilon \Zeta \Eta \Theta} ABΓΔEZHΘ
\mathsf{\Iota \Kappa \Lambda \Mu \Nu \Xi \Pi \Rho} IKΛMNΞΠP
\mathsf{\Sigma \Tau \Upsilon \Phi \Chi \Psi \Omega} ΣTΥΦXΨΩ
Calligraphy/script
\mathcal{ABCDEFGHI} 𝒜𝒞𝒟𝒢
\mathcal{JKLMNOPQR} 𝒥𝒦𝒩𝒪𝒫𝒬
\mathcal{STUVWXYZ} 𝒮𝒯𝒰𝒱𝒲𝒳𝒴𝒵
Fraktur typeface
\mathfrak{ABCDEFGHI} ABCDEFGHI
\mathfrak{JKLMNOPQR} 𝔍𝔎𝔏𝔐𝔑𝔒𝔓𝔔
\mathfrak{STUVWXYZ} STUVWXYZ
\mathfrak{abcdefghijklm} abcdefghijklm
\mathfrak{nopqrstuvwxyz} nopqrstuvwxyz
\mathfrak{0123456789} 0123456789

Mixed text faces

[edit]
Feature Syntax How it looks rendered
Italicised characters (spaces are ignored) x y z xyz
Non-italicised characters \text{x y z} x y z
Mixed italics (bad) \text{if} n \text{is even} ifnis even
Mixed italics (good) \text{if }n\text{ is even} if n is even
Mixed italics (alternative: ~ or "\ " forces a space) \text{if}~n\ \text{is even} ifnis even

Color

[edit]

Equations can use color:

  • {\color{Blue}x^2}+{\color{YellowOrange}2x}-{\color{OliveGreen}1}
    x2+2x1
  • x_{1,2}=\frac{-b\pm\sqrt{\color{Red}b^2-4ac}}{2a}
    x1,2=b±b24ac2a


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.

Colors supported
Apricot Aquamarine Bittersweet Black
Blue BlueGreen BlueViolet BrickRed
Brown BurntOrange CadetBlue CarnationPink
Cerulean CornflowerBlue Cyan Dandelion
DarkOrchid Emerald ForestGreen Fuchsia
Goldenrod Gray Green GreenYellow
JungleGreen Lavender LimeGreen Magenta
Mahogany Maroon Melon MidnightBlue
Mulberry NavyBlue OliveGreen Orange
OrangeRed Orchid Peach Periwinkle
PineGreen Plum ProcessBlue Purple
RawSienna Red RedOrange RedViolet
Rhodamine RoyalBlue RoyalPurple RubineRed
Salmon SeaGreen Sepia SkyBlue
SpringGreen Tan TealBlue Thistle

Note that 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 Wikipedia:Manual of Style (accessibility)#Color.

Formatting issues

[edit]

Spacing

[edit]

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 ab
quad space a \quad b ab
text space a\ b ab
text space without PNG conversion a \mbox{ } b a b
large space a\;b ab
medium space a\&gt;b [not supported]
small space a\,b ab
tiny space (use for multiplication of factors) ab ab
no space (use for multi-letter variables) \mathit{ab} ab
small negative space a\!b ab

Automatic spacing may be broken in very long expressions (because they produce an overfull hbox in TeX):

0+1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+\cdots
0+1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+

This can be remedied by putting a pair of braces { } around the whole expression:

{0+1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+\cdots}
0+1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+

Alignment with normal text flow

[edit]

Due to the default CSS

img.tex { vertical-align: middle; }

an inline expression like NNexdx should look good.

If you need to align it otherwise, use style="vertical-align:-100%;">... 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.

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.

Centering

[edit]

We introduce the new attribute display with the two options "inline" and "block".

Inline

[edit]

If the the value of the display attribute is inline the render will render math in inline mode, i.e. there will be no new paragraph for the equation and the operators will be rendered consuming only little vertical space.

Example
[edit]

The sum i=02i converges to 2.

The next line-width is not disturbed by large operators.

The code for the math example reads:

<math display="inline">\sum_{i=0}^\infty 2^{-i}</math>
Technical implementation
[edit]

Technically it will add 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 by outputting the image or MathMLelement to the page.

Remark
[edit]

The convention https://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style_(mathematics)#Using_HTML is really annoying. I'd prefer to use inline math for that, since it helps to differentiate between math and other elements.

Block

[edit]

In block-style the equation is rendered in its own paragraph and the operator are rendered consuming less horizontal space.

Example
[edit]

The equation geometric series:i=02i=2 is used in a joke about mathematicians entering a bar and ordering beer.

It was entered as

<math display="block">\text{geometric series:}\quad \sum_{i=0}^\infty 2^{-i}=2 </math>
Technical implementation
[edit]

Technically it will add the command \displaystyle will be added to the user input, if the user input does not 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

Discussion
[edit]

Fréderic Wang would prefer that displaystyle is always added in depended of the fact if \displaystlye is already in the equation. He remarks that it has to be checked if that works if the equation starts with \begin.

Not specified

[edit]

If nothing is specified the current behavior is preserved. That means all equation are rendered in display style but not using a new paragraph.

Example
[edit]

The sum i=02i converges to 2.

The next line-width is disturbed by large operators.

The code for the math example reads:

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


The equation

geometric series:i=02i=2

is used in a joke about mathematicians entering a bar and ordering beer.

It was entered as

<math>\text{geometric series:}\quad \sum_{i=0}^\infty 2^{-i}=2 </math>

Commutative diagrams

[edit]

To make a commutative diagram, there are three steps:

  1. write the diagram in TeX
  2. convert to SVG
  3. upload the file to Wikimedia Commons

Diagrams in TeX

[edit]

Xy-pic (online manual) is the most powerful and general-purpose diagram package in TeX. Diagrams created using it can be found at Commons: Category:Xy-pic diagrams.

Simpler packages include:

The following is a template for Xy-pic, together with a hack to increase the margins in dvips, so that the diagram is not truncated by over-eager cropping (suggested in TUGboat: TUGboat, Volume 17 1996, No. 3):

\documentclass{amsart}
\usepackage[all, ps, dvips]{xy}  % Loading the XY-Pic package
                                 % Using postscript driver for smoother curves
\usepackage{color}  % For invisible frame
\begin{document}
\thispagestyle{empty}  % No page numbers
\SelectTips{eu}{}  % Euler arrowheads (tips)
\setlength{\fboxsep}{0pt}  % Frame box margin
{\color{white}\framebox{{\color{black}$$  % Frame for margin

\xymatrix{
%%% Diagram goes here %%%
}

$$}}} % end math, end frame
\end{document}

Convert to SVG

[edit]

Once you have produced your diagram in LaTeX (or TeX), you can convert it to an SVG file using the following sequence of commands:

pdflatex file.tex
pdfcrop --clip file.pdf tmp.pdf
pdf2svg tmp.pdf file.svg
rm tmp.pdf

The pdfcrop and pdf2svg utilities are needed for this procedure. You can alternatively use pdf2svg 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):

latex file.tex
dvipdfm file.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.

These programs are:

Upload the file

[edit]

Template:See also

Template:See also

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.
Name
Make sure the file has a meaningful name.
Upload
Login to Wikimedia Commons, then upload the file; for the Summary, give a brief description.

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 other license)
    |author = [[User:YourUserName|Your Real Name]]}}
}}

==TeX source== <source lang=latex> % TeX source here </source> [[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}}/{{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]]

Examples

[edit]

A sample conforming diagram is commons:Image:PSU-PU.svg.

Unimplemented elements and workarounds

[edit]

\oiint and \oiiint

[edit]

Elements which are not yet implemented are \oiint, 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:
  • SDdA, which uses \iint along with \subset and \supset (overdrawn after backspacing):
\iint\limits_{S}\!\!\!\!\!\!\!\!\!\!\!\subset\!\supset \mathbf D \cdot \mathrm{d}\mathbf A
  • VDdA, 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:

  • VDdA 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
  • VDdA, 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

[edit]

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
Examples
[edit]
  • Stokes' theorem: {{oiint | intsubscpt = <math>{\scriptstyle S}</math> | integrand=<math>( \nabla \times \bold{F} ) \cdot {\rm d}\bold{S} = \oint_{\partial S} \bold{F} \cdot {\rm d}\boldsymbol{\ell} </math> }}
\oiintS(×F)dS=SFd
  • Ampère's law + correction: {{oiint | preintegral=<math>\oint_C \bold{B} \cdot {\rm d} \boldsymbol{\ell} = \mu_0 </math> | intsubscpt = <math>{\scriptstyle S}</math> | integrand = <math>\left ( \bold{J} + \epsilon_0\frac{\partial \bold{E}}{\partial t} \right ) \cdot {\rm d}\bold{S}</math> }}
SBd=μ0\oiintS(J+ϵ0Et)dS
  • Continuity of 4-momentum flux (in general relativity):[1] {{oiiint | preintegral=<math>\bold{P} = </math> | intsubscpt = <math>{\scriptstyle \partial \Omega}</math> | integrand = <math>\bold{T} \cdot {\rm d}^3\boldsymbol{\Sigma} = 0</math> }}
P=\oiintΩTd3Σ=0

Oriented \oiint and \oiiint as PNG images

[edit]

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.

\overarc

[edit]

\overarc is not yet implemented to display the arc notation. However, there exists a workaround: use \overset{\frown}{AB}, which gives AB

Examples of implemented TeX formulas

[edit]

Quadratic polynomial

[edit]

ax2+bx+c=0

<math>ax^2 + bx + c = 0</math>

Quadratic formula

[edit]

x=b±b24ac2a

<math>x={-b\pm\sqrt{b^2-4ac} \over 2a}</math>

Tall parentheses and fractions

[edit]

2=((3x)×23x)

<math>2 = \left(
\frac{\left(3-x\right) \times 2}{3-x}
\right)</math>

Snew=Sold(5T)22

<math>S_{\text{new}} = S_{\text{old}} - \frac{ \left( 5-T \right) ^2} {2}</math>

Integrals

[edit]

axasf(y)dyds=axf(y)(xy)dy

<math>\int_a^x \!\!\!\int_a^s f(y)\,dy\,ds
= \int_a^x f(y)(x-y)\,dy</math>

Matrices and determinants

[edit]

det(AλI)=0

<math>\det(\mathsf{A}-\lambda\mathsf{I}) = 0</math>

Summation

[edit]

i=0n1i

<math>\sum_{i=0}^{n-1} i</math>

m=1n=1m2n3m(m3n+n3m)

<math>\sum_{m=1}^\infty\sum_{n=1}^\infty\frac{m^2\,n}
{3^m\left(m\,3^n+n\,3^m\right)}</math>

Differential equation

[edit]

u+p(x)u+q(x)u=f(x),x>a

<math>u'' + p(x)u' + q(x)u=f(x),\quad x>a</math>

Complex numbers

[edit]

|z¯|=|z|,|(z¯)n|=|z|n,arg(zn)=narg(z)

<math>|\bar{z}| = |z|,
|(\bar{z})^n| = |z|^n,
\arg(z^n) = n \arg(z)</math>

Limits

[edit]

limzz0f(z)=f(z0)

<math>\lim_{z\rightarrow z_0} f(z)=f(z_0)</math>

Integral equation

[edit]

ϕn(κ)=14π2κ20sin(κR)κRR[R2Dn(R)R]dR

<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>

Example

[edit]

ϕn(κ)=0.033Cn2κ11/3,1L0κ1l0

<math>\phi_n(\kappa) =
0.033C_n^2\kappa^{-11/3},\quad
\frac{1}{L_0}\ll\kappa\ll\frac{1}{l_0}</math>

Continuation and cases

[edit]

f(x)={11x<012x=01x2otherwise

<math>
f(x) =
\begin{cases}
1 & -1 \le x < 0 \\
\frac{1}{2} & x = 0 \\
1 - x^2 & \text{otherwise}
\end{cases}
</math>

Prefixed subscript

[edit]

pFq(a1,,ap;c1,,cq;z)=n=0(a1)n(ap)n(c1)n(cq)nznn!

 <math>{}_pF_q(a_1,\dots,a_p;c_1,\dots,c_q;z)
= \sum_{n=0}^\infty
\frac{(a_1)_n\cdots(a_p)_n}{(c_1)_n\cdots(c_q)_n}
\frac{z^n}{n!}</math>

Fraction and small fraction

[edit]

abab

<math>\frac{a}{b}\ \tfrac{a}{b}</math>

Area of a quadrilateral

[edit]

S=dDsinα

<math>S=dD\,\sin\alpha\!</math>

Volume of a sphere-stand

[edit]

V=16πh[3(r12+r22)+h2]

<math>V=\frac16\pi h\left[3\left(r_1^2+r_2^2\right)+h^2\right]</math>

Multiple equations

[edit]

u=12(x+y)x=12(u+v)v=12(xy)y=12(uv)  

<math>\begin{align}
u & = \tfrac{1}{\sqrt{2}}(x+y) \qquad & x &= \tfrac{1}{\sqrt{2}}(u+v) \\
v & = \tfrac{1}{\sqrt{2}}(x-y) \qquad & y &= \tfrac{1}{\sqrt{2}}(u-v)
\end{align}</math>

See also

[edit]

Test cases from parserTests

[edit]
  • pre-save transform: comment containing math
  • BUG 1887: A ‎<math> with a thumbnail- we don't render math in the parsertests by default, so math is not stripped and turns up as escaped <math> tags.
    2+2
  • BUG 1887, part 2: A ‎<math> with a thumbnail- math enabled
    2+2
  • Math section safety when disabled <script>alert(document.cookies);</script>
  • BUG 26380: Add \widetilde support to match \widehat
    • x^
    • x~
  • BUG 27324: Euro symbol for math
    • 200
  • BUG 27754: Archaic Greek letters for math (may require texlive-lang-greek)
    • ϝ
    • Ϙϙϙ
    • Ϝ
    • Ϟϟ
    • Ϡϡ
    • Ϛϛϛ
  • BUG 19547: Apostrophe / single quotes in math \text{...}
    • next years
    • next year's
    • `next' year
  • BUG 6722: Spacing fix for functions in math HTML output:
    • sinx
    • sin(x)
    • sinx
    • sinx
    • sin(x)
    • sinx
  • BUG 18912: Add \sen function for Spanish sin to math
    • senx
    • senx)
    • senx
    • senx
    • sen(x)
    • senx
  • BUG 18912: \operatorname{sen} x gets wrong spacing in math: sen
  • BUG 31442: Multiple math accents without braces fails to parse: B˙
  • BUG 31442: Math accents with math font fail to parse if braces not used:~
  • BUG 31824: Empty math tag returns uniq:
  • BUG 31824: Empty math tag returns uniq:

Additional tests

[edit]

(abcd) Å

[edit]

Template:Side box

  • A LaTeX tutorial
  • Doob, Michael, A Gentle Introduction to TeX: A Manual for Self-study (PDF). A paper introducing TeX — see page 39 onwards for a good introduction to the maths side of things.
  • Oetiker, Tobias; Partl, Hubert; Hyna, Irene; Schlegl, Elisabeth (December 13, 2009), The Not So Short Introduction to LaTeX 2ε (PDF) (4.27 ed.){{citation}}: CS1 maint: date and year (link). 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.
  1. ^ J. A. Wheeler, C. Misner, K. S. Thorne (1973). Gravitation (2nd ed.). W. H. Freeman & Co. ISBN 0-7167-0344-0.{{cite book}}: CS1 maint: multiple names: authors list (link)