LaTeX is the standard for writing mathematical formulas. This guide covers the basics: math modes, fractions, roots, sums, integrals, matrices, and common symbols.
\usepackage{amsmath, amssymb, amsfonts} in your preamble to access all advanced math features. Math modes
LaTeX distinguishes two modes for mathematics: inline mode and display mode.
Inline mode
To insert a formula within a paragraph, surround it with $...$ or \(...\):
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath, amssymb}
\begin{document}
The equation $E = mc^2$ is famous.
We also have \(a^2 + b^2 = c^2\) for a right triangle.
\end{document}
Display mode
To display an equation centered on its own line, use \[...\] or the equation environment:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath, amssymb}
\begin{document}
% Without numbering
\[
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\]
% With automatic numbering
\begin{equation}
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\end{equation}
\end{document}
Fractions and roots
Fractions
Use \frac{numerator}{denominator}:
\documentclass{article}
\usepackage{amsmath, amssymb}
\begin{document}
\[ \frac{1}{2} + \frac{3}{4} = \frac{5}{4} \]
\[ \frac{a+b}{c+d} \]
% Nested fractions
\[ \frac{1}{1 + \frac{1}{x}} \]
\end{document}
Roots
Use \sqrt{} for the square root and \sqrt[n]{} for the nth root:
\documentclass{article}
\usepackage{amsmath, amssymb}
\begin{document}
\[ \sqrt{2} \qquad \sqrt{x^2 + y^2} \]
\[ \sqrt[3]{8} = 2 \qquad \sqrt[n]{a} \]
\end{document}
Superscripts and subscripts
Use ^ for superscripts and _ for subscripts:
\documentclass{article}
\usepackage{amsmath, amssymb}
\begin{document}
$x^2$ --- simple superscript
$x^{10}$ --- multiple superscript (braces required)
$x_i$ --- simple subscript, $x_{ij}$ --- multiple subscript
$a_n^2$ --- both combined, $x_1^{(k)}$ --- advanced notation
% Limits\[ \lim_{n \to \infty} a_n \]
\end{document}
Sums, products and integrals
Sums and products
\documentclass{article}
\usepackage{amsmath, amssymb}
\begin{document}
% Sum
\[ \sum_{i=1}^{n} i = \frac{n(n+1)}{2} \]
% Product
\[ \prod_{i=1}^{n} i = n! \]
% Double sum
\[ \sum_{i=1}^{n} \sum_{j=1}^{m} a_{ij} \]
\end{document}
Integrals
\documentclass{article}
\usepackage{amsmath, amssymb}
\begin{document}
% Simple integral
\[ \int_0^1 x^2 \, dx \]
% Double integral
\[ \iint_D f(x,y) \, dx \, dy \]
% Triple integral
\[ \iiint_V f(x,y,z) \, dx \, dy \, dz \]
% Contour integral
\[ \oint_C f(z) \, dz \]
\end{document}
\, for a thin space before dx. This improves the readability of integrals. Matrices
The matrix environment (with the amsmath package) allows you to create matrices:
\documentclass{article}
\usepackage{amsmath, amssymb}
\begin{document}
% Matrix with parentheses
\[ \begin{pmatrix}
a & b \\
c & d
\end{pmatrix} \]
% Matrix with brackets
\[ \begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6
\end{bmatrix} \]
% Matrix with bars (determinant)
\[ \begin{vmatrix}
a & b \\
c & d
\end{vmatrix} = ad - bc \]
\end{document}
| Environment | Delimiters | Usage |
|---|---|---|
matrix |
None | Matrix without delimiters |
pmatrix |
( ) | Parentheses |
bmatrix |
[ ] | Brackets |
vmatrix |
| | | Determinant |
Vmatrix |
|| || | Norm |
Common symbols
Greek letters
| Command | Output | Command | Output |
|---|---|---|---|
\alpha |
\(\alpha\) | \beta |
\(\beta\) |
\gamma |
\(\gamma\) | \delta |
\(\delta\) |
\epsilon |
\(\epsilon\) | \theta |
\(\theta\) |
\lambda |
\(\lambda\) | \mu |
\(\mu\) |
\pi |
\(\pi\) | \sigma |
\(\sigma\) |
\omega |
\(\omega\) | \Omega |
\(\Omega\) |
Operators and relations
| Command | Output | Command | Output |
|---|---|---|---|
\times |
\(\times\) | \div |
\(\div\) |
\pm |
\(\pm\) | \mp |
\(\mp\) |
\leq |
\(\leq\) | \geq |
\(\geq\) |
\neq |
\(\neq\) | \approx |
\(\approx\) |
\in |
\(\in\) | \notin |
\(\notin\) |
\subset |
\(\subset\) | \supset |
\(\supset\) |
\cup |
\(\cup\) | \cap |
\(\cap\) |
\infty |
\(\infty\) | \partial |
\(\partial\) |
Number sets (with amssymb)
\documentclass{article}
\usepackage{amsmath, amssymb}
\begin{document}
$\mathbb{N}$ --- Natural numbers,
$\mathbb{Z}$ --- Integers,
$\mathbb{Q}$ --- Rationals,
$\mathbb{R}$ --- Reals,
$\mathbb{C}$ --- Complex numbers
\[ \mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R} \subset \mathbb{C} \]
\end{document}
Aligned equations
The align environment lets you align multiple equations on a common point (usually the = sign):
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath, amssymb}
\begin{document}
\begin{align}
(a+b)^2 &= (a+b)(a+b) \\
&= a^2 + ab + ba + b^2 \\
&= a^2 + 2ab + b^2
\end{align}
% Without numbering
\begin{align*}
f(x) &= x^2 + 2x + 1 \\
&= (x+1)^2
\end{align*}
\end{document}
Mathematical functions
Standard functions must be written in roman (not italic). Use the dedicated commands:
\documentclass{article}
\usepackage{amsmath, amssymb}
\begin{document}
$\sin(x)$ \quad $\cos(x)$ \quad $\tan(x)$
$\log(x)$ \quad $\ln(x)$ \quad $\exp(x)$
\[ \lim_{x \to 0} f(x) \qquad \max(a,b) \qquad \min(a,b) \]
\end{document}
$sin(x)$ which gives \(sin(x)\) (italic). Use $\sin(x)$ which gives \(\sin(x)\) (roman). Complete example
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath, amssymb}
\title{Mathematical Formulas}
\author{Your name}
\begin{document}
\maketitle
\section{Quadratic equation}
The equation $ax^2 + bx + c = 0$ has solutions:
\[
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\]
\section{Notable identities}
\begin{align*}
(a+b)^2 &= a^2 + 2ab + b^2 \\
(a-b)^2 &= a^2 - 2ab + b^2 \\
(a+b)(a-b) &= a^2 - b^2
\end{align*}
\section{Calculus}
The derivative of $f(x) = x^n$ is:
\[
f'(x) = nx^{n-1}
\]
The integral of $\sin(x)$:
\[
\int \sin(x) \, dx = -\cos(x) + C
\]
\end{document}