Let
X
Lesson 4 of 8

Mathematics: Equations, Symbols, and Alignment

~10 min read

By the end of this lesson you can typeset inline and displayed equations, fractions, powers, Greek letters, and multi-line aligned equations. Math is LaTeX’s superpower: load amsmath and wrap expressions in math mode.

Inline vs. display math

Wrap inline math in $ … $. Use a display environment for centered, prominent equations. Load \usepackage{amsmath} for the best results.

Inline: the identity $e^{i\pi} + 1 = 0$ is famous.

Displayed and numbered:
\begin{equation}
  e^{i\pi} + 1 = 0
\end{equation}

Displayed, unnumbered:
\[ a^2 + b^2 = c^2 \]

Powers, subscripts, fractions, roots

$x^{2}$        % superscript / power
$x_{i}$        % subscript
$x_{i}^{2}$    % both
$\frac{a}{b}$  % fraction
$\sqrt{2}$     % square root
$\sqrt[3]{x}$  % cube root

Here is what those render to — source on the left, output on the right:

\[ x_{i}^{2} + \frac{a}{b} - \sqrt[3]{x} \]
xi2+abx3x_{i}^{2} + \frac{a}{b} - \sqrt[3]{x}

Group multi-character exponents and indices with braces: x^{10} not x^10 (which renders as x¹0).

Greek letters and common symbols

InputMeaningInputMeaning
\alpha \beta \gammaGreek letters\sumSummation
\pi \theta \lambdaGreek letters\intIntegral
\times \cdotMultiplication\inftyInfinity
\leq \geq \neqComparisons\partialPartial derivative
\rightarrowArrow\approxApproximately

Sums, integrals, and limits

\[ \sum_{i=1}^{n} i = \frac{n(n+1)}{2} \]
\[ \int_{0}^{1} x^2 \, dx = \frac{1}{3} \]
\[ \lim_{x \to \infty} \frac{1}{x} = 0 \]
\[ \sum_{i=1}^{n} i = \frac{n(n+1)}{2} \]
i=1ni=n(n+1)2\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
\[ \int_{0}^{1} x^2 \, dx = \frac{1}{3} \]
01x2dx=13\int_{0}^{1} x^2 \, dx = \frac{1}{3}

Aligning multi-line equations

The align environment lines up equations at the & marker — perfect for derivations. Rows end with \\. Use align* to suppress numbering.

\begin{align}
  (a+b)^2 &= a^2 + 2ab + b^2 \\
          &= a^2 + b^2 + 2ab
\end{align}
\[ \begin{aligned} (a+b)^2 &= a^2 + 2ab + b^2 \\ &= a^2 + b^2 + 2ab \end{aligned} \]
(a+b)2=a2+2ab+b2=a2+b2+2ab\begin{aligned} (a+b)^2 &= a^2 + 2ab + b^2 \\ &= a^2 + b^2 + 2ab \end{aligned}

Matrices

amsmath provides matrix environments: pmatrix (parentheses), bmatrix (brackets), vmatrix (determinant bars).

\[
\begin{pmatrix}
  a & b \\
  c & d
\end{pmatrix}
\]
\[ \begin{pmatrix} a & b \\ c & d \end{pmatrix} \]
(abcd)\begin{pmatrix} a & b \\ c & d \end{pmatrix}

Frequently asked questions

What does "Missing $ inserted" mean?

You used a math-only character (like _, ^, or \alpha) in normal text. Wrap it in $...$ or escape it. See the Common Problems entry on this error.

equation vs align — which do I use?

Use equation for a single numbered equation; use align for multiple equations aligned at a chosen point (the &). Add * (equation*/align*) to remove numbering.

How do I write a piecewise function?

Use the cases environment from amsmath: \begin{cases} x & x>0 \\ 0 & \text{otherwise} \end{cases} inside math mode.