Currently there may be errors shown on top of a page, because of a missing Wiki update (PHP version and extension DPL3).
Navigation
Topics Help • Register • News • History • How to • Sequences statistics • Template prototypes

Help:Math rendering

From Prime-Wiki
Jump to: navigation, search

Math rendering

This is a brief introduction to how to post maths in wiki format.

All maths notation needs to appear between the math tags, <math> and </math>.

Math commands are preceded by a backslash, like this: \sum.

The < math > command

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

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

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

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

Special characters

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

# $ % ^ & _ { } ~ \

These characters can be entered by adding a prefix backslash:

\# \$ \% \textasciicircum{} \& \_ \{ \} \~{} \textbackslash{}

The other symbols and many more can be rendered with special commands in mathematical formulae or as accents.

The backslash character \ can not be entered by adding another backslash in front of it (\\); this sequence is used for line breaking. For introducing a backslash in math mode, you can use \backslash instead.

The command \~ produces a tilde which is placed over the next letter. For example \~n/ gives ñ. To produce just the character ~, use \~{} which places a ~ over an empty box. Alternatively \sim produces a large centred ~ which may be more appropriate in some situations, but may not render properly in simple expressions which are converted to HTML.

Similarly, the command \^ produces a hat over the next character, for example \^{o} produces ô. If you need in text to display the ^ symbol you have to use \textasciicircum.

Accents/diacritics

\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

\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
\left\vert s \right\vert |s|
\min(x,y), \max(x,y) min(x,y),max(x,y)

Bounds

\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

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

Differentials and derivatives

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, f^\prime, f', f, f^{(3)}, \dot y, \ddot y ,f,f,f,f(3),y˙,y¨

Letter-like symbols or constants

\infty, \aleph, \hbar ,,
\Im, \imath, \jmath, \ell, \wp, \Re ,ı,ȷ,,,

Modular arithmetic

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, \not\mid ,

Radicals

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

Operators

+, -, \pm, \mp, \dot+ +,,±,,+˙
\times, \div, /, \backslash ×,÷,/,
\cdot, * \ast, \star, \circ, \bullet ,,,,
\oplus, \ominus, \otimes, \oslash, \odot ,,,,
\bigoplus, \bigotimes, \bigodot ,,

Sets

\{ \}, \emptyset {},
\in, \notin, \ni, \not\ni ,,,
\cap, \sqcap, \bigcap ,,
\cup, \sqcup, \bigcup, \bigsqcup, \uplus, \biguplus ,,,,,
\setminus, \times ,×
\subset, \supset, \subseteq, \not\subseteq, \sqsubseteq, \supseteq, \not\supseteq, \sqsupseteq ,,,,,,,

Relations

=, \ne, \neq, \equiv, \not\equiv =,,,,
\dot=, \overset{\underset{\mathrm{def}}{}}{=}, := =˙,=def,:=
\sim, \simeq, :\sim, \cong, \not\cong ,,:∼,,
\approx, \asymp, \propto ,,
<, \not<, \ll, \not\ll <,,,≪̸
>, \not>, \gg, \not\gg >,,,≫̸
\le, \leq, \not\leq ,,
\ge, \geq, \not\geq ,,
\prec, \not\prec, \preceq, \not\preceq ,,,⪯̸
\succ, \not\succ, \succeq, \not\succeq ,,,⪰̸

Geometric

\parallel, \not\parallel ,
\perp, \angle, 45^\circ ,,45
\bigcirc, \triangle \bigtriangleup, \bigtriangledown ,,

Logic

\forall, \exists, \not\exists ,,
\vee, \bigvee ,
\land, \wedge, \bigwedge ,,
\bar{q}, \bar{abc}, \overline{q}, \overline{abc}, \lnot \neg, \not\operatorname{R}, \bot, \top q¯,abc¯,q,abc,¬¬,,,
\vdash, \dashv, \not\vdash, \not\dashv, \models ,,,⊣̸,

Arrows

\Rightarrow, \not\Rightarrow, \Longrightarrow ,,
\Leftarrow, \not\Leftarrow, \Longleftarrow ,,
\Leftrightarrow, \not\Leftrightarrow, \Longleftrightarrow \iff ,,
\Uparrow, \Downarrow, \Updownarrow ,,
\rightarrow \to, \not\rightarrow, \longrightarrow ,,
\leftarrow \gets, \not\leftarrow, \longleftarrow ←←,,
\leftrightarrow, \not\leftrightarrow, \longleftrightarrow ,,
\uparrow, \downarrow, \updownarrow ,,
\nearrow, \swarrow, \nwarrow, \searrow ,,,
\mapsto, \longmapsto ,
\rightharpoonup \rightharpoondown \leftharpoonup \leftharpoondown \rightleftharpoons ⇀⇁↼↽
\hookrightarrow \hookleftarrow ↪↩

Special

\amalg \S \% \dagger \ddagger \ldots \cdots ⨿§%
\smile \frown \wr \triangleleft \triangleright ⌣⌢
\diamondsuit, \heartsuit, \clubsuit, \spadesuit, \flat, \natural, \sharp ,,,,,,

Subscripts, superscripts, integrals

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} ab cd def^
\overline{g h i} \ \underline{j k l} ghi jkl
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

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
Note does not work with MathJax
workaround: using \not
\cfrac{x}{1 + \cfrac{\not{y}}{\not{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
f(x) =
\sum_{n=0}^\infty a_n x^n =
a_0+a_1x+a_2x^2+\cdots
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

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

Feature Syntax How it looks rendered
Bad ( \frac{1}{2} ) (12)
Good \left ( \frac{1}{2} \right ) (12)
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 (add "l" or "r" to indicate the side for proper spacing) ( \bigl( \Bigl( \biggl( \Biggl( \dots \Biggr] \biggr] \Bigr] \bigr] ] (((((]]]]]
\{ \bigl\{ \Bigl\{ \biggl\{ \Biggl\{ \dots \Biggr\rangle \biggr\rangle \Bigr\rangle \bigr\rangle \rangle {{{{{
\big\| \Big\| \bigg\| \Bigg\| \dots \Bigg| \bigg| \Big| \big| | |||||
\lfloor \bigl\lfloor \Bigl\lfloor \biggl\lfloor \Biggl\lfloor \dots \Biggr\rceil \biggr\rceil \Bigr\rceil \bigr\rceil \ceil
\uparrow \big\uparrow \Big\uparrow \bigg\uparrow \Bigg\uparrow \dots \Bigg\Downarrow \bigg\Downarrow \Big\Downarrow \big\Downarrow \Downarrow
\updownarrow \big\updownarrow \Big\updownarrow \bigg\updownarrow \Bigg\updownarrow \dots \Bigg\Updownarrow \bigg\Updownarrow \Big\Updownarrow \big\Updownarrow \Updownarrow
/ \big/ \Big/ \bigg/ \Bigg/ \dots \Bigg\backslash \bigg\backslash \Big\backslash \big\backslash \backslash /////\\\\

Alphabets and typefaces

Greek alphabet
\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega ΓΔΘΛΞΠΣΥΦΨΩ
\alpha \beta \gamma \delta \epsilon \zeta \eta \theta αβγδϵζηθ
\iota \kappa \lambda \mu \nu \xi \pi \rho ικλμνξπρ
\sigma \tau \upsilon \phi \chi \psi \omega στυϕχψω
\varepsilon \varpi \varrho \varsigma \vartheta \varphi εϖϱςϑφ
Hebrew symbols
\aleph
Blackboard bold/scripts
\mathbb{ABCDEFGHI} ABCDEFGHI
\mathbb{JKLMNOPQR} JKLMNOPQR
\mathbb{STUVWXYZ} STUVWXYZ
Boldface
\mathbf{ABCDEFGHI} ABCDEFGHI
\mathbf{JKLMNOPQR} JKLMNOPQR
\mathbf{STUVWXYZ} STUVWXYZ
\mathbf{abcdefghijklm} abcdefghijklm
\mathbf{nopqrstuvwxyz} nopqrstuvwxyz
\mathbf{0123456789} 0123456789
Boldface (Greek)
\boldsymbol{\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega} ΓΔΘΛΞΠΣΥΦΨΩ
\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 \varpi \varrho \varsigma \vartheta \varphi} εϖϱςϑφ
Italics (default for Latin alphabet)
\mathit{0123456789} 0123456789
Greek italics
\mathit{\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega} ΓΔΘΛΞΠΣΥΦΨΩ
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
\mathsf{\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega} ΓΔΘΛΞΠΣΥΦΨΩ
Calligraphy/script
\mathcal{ABCDEFGHI} ABCDEFGHI
\mathcal{JKLMNOPQR} JKLMNOPQR
\mathcal{STUVWXYZ} STUVWXYZ
Fraktur typeface
\mathfrak{ABCDEFGHI} ABCDEFGHI
\mathfrak{JKLMNOPQR} JKLMNOPQR
\mathfrak{STUVWXYZ} STUVWXYZ
\mathfrak{abcdefghijklm} abcdefghijklm
\mathfrak{nopqrstuvwxyz} nopqrstuvwxyz
\mathfrak{0123456789} 01234567890
Small scriptstyle text
{\scriptstyle\text{abcdefghijklm}} abcdefghijklm

Mixed text faces

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} if n is even

Color

Equations can use color with the \color command.

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

There are several alternate notations styles

  • {\color{Blue}x^2}+{\color{Orange}2x}-{\color{LimeGreen}1}
    x2+2x1
  • \color{Blue}x^2\color{Black}+\color{Orange}2x\color{Black}-\color{LimeGreen}1
    x2+2x1
  • \color{Blue}{x^2}+\color{Orange}{2x}-\color{LimeGreen}{1}
    x2+2x1

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 (black ones not supported)
Blue BlueGreen BlueViolet BrickRed
Brown BurntOrange CadetBlue CarnationPink
DarkOrchid Emerald ForestGreen Fuchsia
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

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.

Spacing

Note that <math></math> 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 a b
large space a\;b ab
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
Help