Skip to main content
LaTeX is renowned for its superior mathematical typesetting. This guide will take you from basic equations to advanced mathematical expressions.
Fun fact: LaTeX’s math rendering is so good that even Microsoft Word now uses a LaTeX-like syntax for its equation editor!

Why LaTeX for Math?

Compare these approaches to writing the quadratic formula: Plain text: x = (-b +/- sqrt(b^2 - 4ac)) / 2a LaTeX result: x=−b±b2−4ac2ax = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} The difference is clear – LaTeX produces publication-quality mathematics.

Math Modes

LaTeX has two math modes:

1. Inline Math Mode

For math within text, use $...$ or \(...\):
inline-math.tex

Expected output

The famous equation E=mc2E = mc^2 was discovered by Einstein. We can also write a2+b2=c2a^2 + b^2 = c^2 for the Pythagorean theorem.

2. Display Math Mode

For centered equations on their own line, use \[...\] or equation environment:
display-math.tex

Expected output

The quadratic formula is:x=−b±b2−4ac2ax = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}For numbered equations:\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2} \tag{1}
Use \[...\] for important formulas you want to highlight. Use $...$ for variables and simple expressions within sentences.

Basic Math Elements

Superscripts and Subscripts

super-subscripts.tex

Expected output

Superscripts: x2x^2, x10x^{10}, xn+1x^{n+1}Subscripts: x1x_1, x10x_{10}, xi,jx_{i,j}Combined: x12x_1^2, ank+1a_n^{k+1}Chemical formulas: H2O\text{H}_2\text{O}, CO2\text{CO}_2

Fractions

fractions.tex

Expected output

Simple fractions: 12\frac{1}{2}, ab\frac{a}{b}Nested fractions: 11+12\frac{1}{1 + \frac{1}{2}}Display style: a+bc+d\displaystyle\frac{a+b}{c+d}Alternative notation: a/ba/b or a/b^a/_b

Roots

roots.tex

Expected output

Square root: 2\sqrt{2}, x2+y2\sqrt{x^2 + y^2}nth root: 83\sqrt[3]{8}, xn\sqrt[n]{x}Nested roots: 2+3\sqrt{2 + \sqrt{3}}

Common Math Symbols

Greek Letters

greek-letters.tex

Expected output

Lowercase: α,β,γ,δ,ϵ\alpha, \beta, \gamma, \delta, \epsilon and θ,λ,μ,π,σ,ϕ\theta, \lambda, \mu, \pi, \sigma, \phiUppercase: Γ,Δ,Θ,Λ,Σ,Φ\Gamma, \Delta, \Theta, \Lambda, \Sigma, \PhiVariants: ϵ\epsilon vs ε\varepsilon and ϕ\phi vs φ\varphi

Operators and Relations

operators.tex

Expected output

Basic operators: a+b−c×d÷ea + b - c \times d \div eComparison: a<b≤c=d≥e>fa < b \leq c = d \geq e > f and a≠b≈c≡da \neq b \approx c \equiv dSet operations: A∪B∩C⊂DA \cup B \cap C \subset D and x∈A,y∉Bx \in A, y \notin BLogic: p∧q∨r  ⟹  sp \land q \lor r \implies s and ∀x∃y\forall x \exists y

Arrows

arrows.tex

Expected output

Basic arrows: →,←,↔\rightarrow, \leftarrow, \leftrightarrow and ⇒,⇐,⇔\Rightarrow, \Leftarrow, \LeftrightarrowLong arrows: ⟶,⟵\longrightarrow, \longleftarrowSpecial arrows: ↑,↓,↕\uparrow, \downarrow, \updownarrow and ↗,↘,↙,↖\nearrow, \searrow, \swarrow, \nwarrow

Functions and Operators

Standard Functions

functions.tex

Expected output

Trigonometric: sin⁡θ,cos⁡θ,tan⁡θ\sin\theta, \cos\theta, \tan\thetaLogarithms: log⁡x,ln⁡x,log⁡2x\log x, \ln x, \log_2 xLimits: lim⁡x→0sin⁡xx=1\displaystyle\lim_{x \to 0} \frac{\sin x}{x} = 1Min/Max: min⁡(a,b),max⁡(a,b)\min(a,b), \max(a,b)

Sums and Products

sums-products.tex

Expected output

Summation: ∑i=1ni=n(n+1)2\displaystyle\sum_{i=1}^{n} i = \frac{n(n+1)}{2}Product: ∏i=1ni=n!\displaystyle\prod_{i=1}^{n} i = n!Multiple lines: ∑i=1i≠jnai\displaystyle\sum_{\substack{i=1 \\ i \neq j}}^{n} a_i

Integrals and Derivatives

calculus.tex

Expected output

Derivatives: f′(x),f′′(x),f(n)(x)f'(x), f''(x), f^{(n)}(x) and dfdx,d2fdx2\frac{df}{dx}, \frac{d^2f}{dx^2} and ∂f∂x\frac{\partial f}{\partial x}Integrals: ∫f(x) dx\displaystyle\int f(x)\,dx and ∫abf(x) dx\displaystyle\int_a^b f(x)\,dx and ∬Df(x,y) dx dy\displaystyle\iint_D f(x,y)\,dx\,dySpecial notation: ∮CF⋅dr\displaystyle\oint_C F \cdot dr

Matrices and Arrays

Basic Matrices

matrices.tex

Expected output

pmatrix (parentheses): (abcd)\begin{pmatrix} a & b \\ c & d \end{pmatrix}bmatrix (brackets): [123456789]\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix}vmatrix (determinant): ∣abcd∣=ad−bc\begin{vmatrix} a & b \\ c & d \end{vmatrix} = ad - bc

Advanced Arrays

arrays.tex

Expected output

Custom arrays: [123456]\left[ \begin{array}{cc|c} 1 & 2 & 3 \\ 4 & 5 & 6 \end{array} \right]Cases (piecewise functions): f(x)={x2if x≥0−xif x<0f(x) = \begin{cases} x^2 & \text{if } x \geq 0 \\ -x & \text{if } x < 0 \end{cases}

Spacing in Math Mode

math-spacing.tex

Expected output

Default: aba b vs ababThin space: a ba\,b | Medium space: a ba\:b | Thick space: a  ba\;bQuad space: aba\quad b | Double quad: aba\qquad bNegative space: a ⁣ba\!b
Use \, before differentials in integrals: \int f(x)\,dx looks better than \int f(x)dx.

Advanced Features

Theorem Environments

theorems.tex
Ready to use this syntax? Continue in the browser editor when you want to adapt the example in a real project.Open LaTeX Cloud Studio

Aligning Equations

align.tex

Common Mistakes to Avoid

1. Forgetting braces for multi-character super/subscripts
  • Wrong: $x^10$ → x¹0
  • Right: $x^{10}$ → x¹⁰
2. Using text in math mode
  • Wrong: $x = speed * time$
  • Right: $x = \text{speed} \times \text{time}$
3. Incorrect fraction syntax
  • Wrong: $\frac{1/2}$
  • Right: $\frac{1}{2}$

Math Packages

Essential packages for advanced mathematics:
example.tex

Practice Exercises

Try typesetting these formulas:
  1. Euler’s Identity: eiπ+1=0e^{i\pi} + 1 = 0
  2. Gaussian Integral: ∫−∞∞e−x2dx=π\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
  3. Binomial Theorem: (x+y)n=∑k=0n(nk)xn−kyk(x+y)^n = \sum_{k=0}^{n} \binom{n}{k} x^{n-k} y^k
  4. Maxwell’s Equation: ∇×E=−∂B∂t\nabla \times \mathbf{E} = -\frac{\partial \mathbf{B}}{\partial t}

Quick Reference

Next Steps


Ready to create beautiful mathematical documents? You now have the foundation to typeset any mathematical expression in LaTeX!