LaTeX Cheatsheet

LaTeX syntax for maths, physics and chemistry

Quick reference guide for common LaTeX notations. Click on any syntax block to copy it instantly to your clipboard!

43 copy-and-paste snippets, each one rendered so you can see what it produces.

Basics

Inline maths

A formula sitting inside a line of text.

E=mc2E = mc^2
$E = mc^2$
Display maths

A formula on its own centred line.

eiπ+1=0e^{i\pi} + 1 = 0
$$e^{i\pi} + 1 = 0$$
Superscript

Upper index. Wrap in braces when it is more than one character.

x2nx^{2n}
x^{2n}
Subscript

Lower index, for sequences and matrix entries.

ai,ja_{i,j}
a_{i,j}
Fraction

Use \dfrac to keep an inline fraction full size.

ab\frac{a}{b}
\frac{a}{b}
Square root

The radical stretches to fit what is inside it.

x\sqrt{x}
\sqrt{x}
Nth root

The degree goes in square brackets.

xn\sqrt[n]{x}
\sqrt[n]{x}
Auto-sized brackets

\left and \right always pair up, even when one side is a dot.

(ab)\left( \frac{a}{b} \right)
\left( \frac{a}{b} \right)
Words inside maths

Without \text each letter is treated as a variable and set in italics.

với mọi x\text{với mọi } x
\text{với mọi } x

Calculus and operators

Definite integral

\, is the thin space before dx; without it the d runs into the formula.

∫abf(x) dx\int_{a}^{b} f(x) \,dx
\int_{a}^{b} f(x) \,dx
Summation

Limits sit above and below in display, beside it inline.

∑i=1nai\sum_{i=1}^{n} a_i
\sum_{i=1}^{n} a_i
Product

Limits work exactly as they do for a sum.

∏k=1nk\prod_{k=1}^{n} k
\prod_{k=1}^{n} k
Limit

Use \to rather than typing ->.

lim⁡x→0sin⁡xx\lim_{x \to 0} \frac{\sin x}{x}
\lim_{x \to 0} \frac{\sin x}{x}
Partial derivative

\partial is ∂, which is not a plain letter d.

∂f∂x\frac{\partial f}{\partial x}
\frac{\partial f}{\partial x}
Derivative notation

Primes for derivatives; \dot and \ddot for time derivatives.

f′(x),y¨f'(x), \ddot{y}
f'(x), \ddot{y}
Double integral

\iiint for triple, \oint for a closed contour.

∬Dg(x,y) dA\iint_{D} g(x,y) \,dA
\iint_{D} g(x,y) \,dA
Infinity

Usually a limit: \int_{0}^{\infty}.

∞\infty
\infty

Greek letters and symbols

Lowercase Greek

The letter’s English name, with a backslash in front.

α,β,γ,θ,π\alpha, \beta, \gamma, \theta, \pi
\alpha, \beta, \gamma, \theta, \pi
Uppercase Greek

Capitalise the first letter. Ones identical to Latin have no command.

Γ,Δ,Θ,Σ,Ω\Gamma, \Delta, \Theta, \Sigma, \Omega
\Gamma, \Delta, \Theta, \Sigma, \Omega
Comparisons

\neq is ≠; \equiv is ≡, used for congruence.

≤,≥,≠,≈,≡\le, \ge, \neq, \approx, \equiv
\le, \ge, \neq, \approx, \equiv
Logic

\implies and \iff are the long arrows for implication and equivalence.

∧,∨,¬,  ⟹  ,  ⟺  \land, \lor, \neg, \implies, \iff
\land, \lor, \neg, \implies, \iff
Set notation

\mathbb{R} for the reals, \varnothing for the empty set.

∈,∉,⊂,∪,∩\in, \notin, \subset, \cup, \cap
\in, \notin, \subset, \cup, \cap
Arrows

Capitalise for a double arrow: \Rightarrow differs from \rightarrow.

→,←,⇒,↔\to, \gets, \Rightarrow, \leftrightarrow
\to, \gets, \Rightarrow, \leftrightarrow
Angles and degrees

^\circ is the degree sign; do not use a raised letter o.

∠ABC,30∘\angle ABC, 30^\circ
\angle ABC, 30^\circ
Vectors and segments

\overrightarrow{AB} for a vector named by its endpoints.

v⃗,AB‾\vec{v}, \overline{AB}
\vec{v}, \overline{AB}

Matrices and alignment

Round-bracket matrix

& separates columns, \\ starts a new row.

(abcd)\begin{pmatrix} a & b \\ c & d \end{pmatrix}
\begin{pmatrix} a & b \\ c & d \end{pmatrix}
Square-bracket matrix

Change the leading letter for the bracket style: p, b, v, V, B.

[1001]\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}
\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}
Determinant

Vertical bars. \begin{Vmatrix} gives double bars.

∣xyzw∣\begin{vmatrix} x & y \\ z & w \end{vmatrix}
\begin{vmatrix} x & y \\ z & w \end{vmatrix}
Multi-line alignment

Put & immediately before the = so the lines line up.

f(x)=(x+1)2=x2+2x+1\begin{aligned} f(x) &= (x+1)^2 \\ &= x^2 + 2x + 1 \end{aligned}
\begin{aligned} f(x) &= (x+1)^2 \\ &= x^2 + 2x + 1 \end{aligned}
System of equations

The brace sizes itself to the number of rows.

{x+y=1x−y=3\begin{cases} x + y = 1 \\ x - y = 3 \end{cases}
\begin{cases} x + y = 1 \\ x - y = 3 \end{cases}
Binomial coefficient

The n-choose-k notation.

(nk)\binom{n}{k}
\binom{n}{k}

Chemistry

Molecular formula

Subscripts happen automatically; no _ for each number.

HX2O\ce{H2O}
\ce{H2O}
Reaction equation

-> for one direction, <=> for an equilibrium.

2 HX2+OX2→2 HX2O\ce{2H2 + O2 -> 2H2O}
\ce{2H2 + O2 -> 2H2O}
Charged ion

The charge follows ^, number before sign.

SOX4X2−\ce{SO4^2-}
\ce{SO4^2-}
Reaction conditions

Conditions go in square brackets right after the arrow.

CaCOX3→ΔCaO+COX2\ce{CaCO3 ->[\Delta] CaO + CO2}
\ce{CaCO3 ->[\Delta] CaO + CO2}
Precipitate and gas

v is the down arrow (precipitate), ^ the up arrow (gas).

AgCl↓,HX2↑\ce{AgCl v}, \ce{H2 ^}
\ce{AgCl v}, \ce{H2 ^}
Isotope

Mass number above, atomic number below, before the symbol.

X614X26214C\ce{^{14}_{6}C}
\ce{^{14}_{6}C}

Physics and units

Variable with an index

v_0 is initial velocity — the index is a zero, not a letter o.

v=v0+atv = v_0 + at
v = v_0 + at
Formula with a fraction

A product needs no times sign; the spacing is automatic.

F=Gm1m2r2F = G\frac{m_1 m_2}{r^2}
F = G\frac{m_1 m_2}{r^2}
Change and constants

Capital \Delta for a change; \nu is a nu, not a v.

ΔE=hν\Delta E = h\nu
\Delta E = h\nu
Units

\mathrm keeps units upright. {,} stops a decimal comma being read as a separator.

9,8 m/s29{,}8\ \mathrm{m/s^2}
9{,}8\ \mathrm{m/s^2}
Scientific notation

\times for a cross, \cdot for a centred dot.

1,6×10−191{,}6 \times 10^{-19}
1{,}6 \times 10^{-19}
Vector quantity

With an arrow it is a vector; without, a magnitude.

F⃗=ma⃗\vec{F} = m\vec{a}
\vec{F} = m\vec{a}