Intermediate 20 min read

LaTeX Math and Equations - Complete Mathematical Typesetting Guide

⭐ Core Tutorial

Master LaTeX mathematical typesetting with this comprehensive guide. Learn inline math, display equations, fractions, matrices, multi-line alignment, equation numbering, and professional mathematical notation for academic papers and technical documents.

⚡ Quick Reference

Inline Math: $E = mc^2$
Display Math: \[ E = mc^2 \]
Numbered Equation: \begin{equation}

Math Mode Basics

LaTeX has two modes for typesetting mathematics: text mode (regular paragraph text) and math mode (mathematical expressions). Math mode uses special formatting rules optimized for mathematical notation.

Entering Math Mode

There are three main ways to enter math mode in LaTeX:

Method Syntax Type Use Case
Dollar signs $...$ Inline Math within text
Brackets \[...\] Display Stand-alone equations
Equation \begin{equation} Display + Number Numbered equations
Parentheses \(...\) Inline (alt) Alternative inline
Display math (old) $$...$$ Display (deprecated) Not recommended

Important: Use \[...\] instead of $$...$$ for display math. The $$ syntax is outdated and can cause spacing issues.

Inline Math vs Display Math

Inline Math Mode

Inline math appears within a line of text, flowing naturally with the surrounding paragraph:

% Inline math with dollar signs
The equation $E = mc^2$ was discovered by Einstein.

% Variables in text
Let $x$ and $y$ be real numbers such that $x < y$.

% Multiple inline expressions
For $a = 2$ and $b = 3$, we have $a + b = 5$.

The equation E = mc² was discovered by Einstein.

Let x and y be real numbers such that x < y.

Display Math Mode

Display math appears centered on its own line, giving equations more prominence:

% Display math with brackets
\[
    E = mc^2
\]

% Longer equation
\[
    x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\]

% With preceding text
The quadratic formula is:
\[
    x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\]

When to use each:

  • Inline ($...$): Simple expressions, variables, small formulas within text
  • Display (\[...\]): Important equations, complex expressions, formulas that need emphasis

Basic Operations and Symbols

Arithmetic Operators

% Addition and subtraction (use symbols directly)
$a + b - c$

% Multiplication
$a \times b$   % Cross symbol
$a \cdot b$    % Dot symbol
$ab$           % Implicit (most common)

% Division
$a \div b$     % Division symbol
$a / b$        % Forward slash
$\frac{a}{b}$  % Fraction (best for display)

% Plus-minus
$x = 5 \pm 2$

Comparison and Relation Symbols

% Equals and inequalities
$a = b$        % Equal
$a \neq b$     % Not equal
$a < b$        % Less than
$a > b$        % Greater than
$a \leq b$     % Less than or equal
$a \geq b$     % Greater than or equal

% Approximation
$\pi \approx 3.14$     % Approximately equal
$x \sim y$             % Similar to

% Much less/greater
$a \ll b$      % Much less than
$a \gg b$      % Much greater than

Fractions and Binomials

Basic Fractions

The \frac{numerator}{denominator} command creates fractions:

% Simple fraction
\[
    \frac{1}{2}
\]

% Fraction with expressions
\[
    \frac{a + b}{c + d}
\]

% Nested fractions
\[
    \frac{1}{1 + \frac{1}{2}}
\]

% Complex fraction
\[
    \frac{x^2 + 2x + 1}{x^2 - 1} = \frac{(x+1)^2}{(x-1)(x+1)}
\]

Inline Fractions

% Regular frac in inline (may look cramped)
The ratio is $\frac{1}{2}$ which equals 0.5.

% Better for inline: use slash
The ratio is $1/2$ which equals 0.5.

% Or use \tfrac for smaller fractions
The ratio is $\tfrac{1}{2}$ which equals 0.5.

Binomial Coefficients

% Binomial coefficient
\[
    \binom{n}{k} = \frac{n!}{k!(n-k)!}
\]

% Pascal's triangle identity
\[
    \binom{n}{k} = \binom{n-1}{k-1} + \binom{n-1}{k}
\]

Exponents and Subscripts

Superscripts (Exponents)

% Simple exponent
$x^2$

% Multiple character exponent (use braces)
$x^{10}$
$e^{-x^2}$

% Nested exponents
$x^{y^z}$
$(x^y)^z = x^{yz}$

% In equations
\[
    a^2 + b^2 = c^2
\]

Subscripts

% Simple subscript
$x_1$

% Multiple character subscript
$x_{10}$
$x_{max}$

% Multiple subscripts
$x_1, x_2, x_3, \ldots, x_n$

% Subscript and superscript together
$x_i^2$
$\sum_{i=1}^{n} x_i^2$

Tip: When combining subscripts and superscripts, order doesn't matter: x_i^2 and x^2_i produce the same result. However, x_i^2 is more conventional.

Greek Letters

Greek letters are essential in mathematics. Lowercase letters use lowercase commands, uppercase use capitalized commands:

Lowercase Command Uppercase Command
α \alpha A A
β \beta B B
γ \gamma Γ \Gamma
δ \delta Δ \Delta
θ \theta Θ \Theta
λ \lambda Λ \Lambda
μ \mu M M
π \pi Π \Pi
σ \sigma Σ \Sigma
φ \phi or \varphi Φ \Phi
ω \omega Ω \Omega
% Common Greek letter usage
$\alpha, \beta, \gamma, \delta$
$\pi \approx 3.14159$
$\theta = 45^\circ$
$\mu = 100, \sigma = 15$ % mean and std deviation
$\lambda = 550$ nm        % wavelength
$\Omega = 100$ $\Omega$   % resistance

Matrices and Arrays

Basic Matrix Environments

LaTeX provides several matrix environments with different bracket styles:

% Plain matrix (no brackets) - requires amsmath
\[
\begin{matrix}
a & b \\
c & d
\end{matrix}
\]

% Parentheses matrix
\[
\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}
\]

% Square brackets matrix
\[
\begin{bmatrix}
a & b \\
c & d
\end{bmatrix}
\]

% Curly braces matrix
\[
\begin{Bmatrix}
a & b \\
c & d
\end{Bmatrix}
\]

% Determinant (vertical bars)
\[
\begin{vmatrix}
a & b \\
c & d
\end{vmatrix}
\]

Larger Matrices

% 3×3 matrix
\[
A = \begin{bmatrix}
a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
a_{31} & a_{32} & a_{33}
\end{bmatrix}
\]

% Identity matrix
\[
I = \begin{pmatrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{pmatrix}
\]

% Matrix with ellipsis
\[
\begin{bmatrix}
a_1 & a_2 & \cdots & a_n \\
b_1 & b_2 & \cdots & b_n \\
\vdots & \vdots & \ddots & \vdots \\
z_1 & z_2 & \cdots & z_n
\end{bmatrix}
\]

Multi-line Equations and Alignment

The align Environment

The align environment (from amsmath package) aligns multiple equations at specified points:

\usepackage{amsmath}  % Required in preamble

\begin{align}
x + y &= 5 \\
2x - y &= 1
\end{align}

% Alignment with explanations
\begin{align}
f(x) &= x^2 + 2x + 1 \\
     &= (x + 1)^2 \\
     &= (x + 1)(x + 1)
\end{align}

The & symbol: Marks the alignment point. Equations align vertically at the &. Typically placed before the equals sign or relation symbol.

Multiple Alignment Points

% Two alignment points
\begin{align}
x &= a + b  &  y &= c + d \\
  &= e + f  &    &= g + h
\end{align}

% Long derivation
\begin{align}
(a + b)^2 &= (a + b)(a + b) \\
          &= a(a + b) + b(a + b) \\
          &= a^2 + ab + ba + b^2 \\
          &= a^2 + 2ab + b^2
\end{align}

Other Multi-line Environments

% gather: centered equations without alignment
\begin{gather}
x + y = 5 \\
x^2 + y^2 = 25
\end{gather}

% multline: first line left, last line right, middle centered
\begin{multline}
a + b + c + d + e + f \\
+ g + h + i + j + k
\end{multline}

% split: for breaking single equation (inside equation)
\begin{equation}
\begin{split}
f(x) = a_0 + a_1 x + a_2 x^2 \\
       + a_3 x^3 + a_4 x^4
\end{split}
\end{equation}

Equation Numbering and Referencing

Automatic Numbering

% equation environment automatically numbers
\begin{equation}
E = mc^2
\end{equation}

% align numbers each line
\begin{align}
x + y &= 5 \\
2x - y &= 1
\end{align}

% Suppress numbering with *
\begin{equation*}
E = mc^2  % No number
\end{equation*}

% Or use \nonumber on specific lines
\begin{align}
x + y &= 5 \\
2x - y &= 1 \nonumber
\end{align}

Labels and Cross-references

% Label an equation
\begin{equation} \label{eq:einstein}
E = mc^2
\end{equation}

% Reference it later
As shown in Equation~\ref{eq:einstein}, energy and mass are equivalent.

% With eqref (adds parentheses automatically)
As shown in Equation~\eqref{eq:einstein}...
% Produces: "Equation (1)"

% Multiple labels
\begin{align}
x + y &= 5   \label{eq:first} \\
2x - y &= 1  \label{eq:second}
\end{align}

From Equations~\eqref{eq:first} and~\eqref{eq:second}, we can solve for $x$ and $y$.

Special Functions and Symbols

Trigonometric Functions

% Use \sin, \cos, etc. (not sin, cos)
$\sin(x), \cos(x), \tan(x)$
$\arcsin(x), \arccos(x), \arctan(x)$
$\sinh(x), \cosh(x), \tanh(x)$  % Hyperbolic

% In equations
\[
\sin^2(x) + \cos^2(x) = 1
\]

Logarithms and Exponentials

% Logarithms
$\log(x), \ln(x), \lg(x)$
$\log_2(x), \log_{10}(x)$

% Exponential
$e^x, \exp(x)$

% Limits
\[
\lim_{x \to \infty} \frac{1}{x} = 0
\]

Sums, Products, and Integrals

% Summation
\[
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
\]

% Product
\[
\prod_{i=1}^{n} i = n!
\]

% Integral
\[
\int_{0}^{1} x^2 \, dx = \frac{1}{3}
\]

% Multiple integral
\[
\iint_D f(x,y) \, dx \, dy
\]

% Limits of integration
\[
\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}
\]

Derivatives and Calculus

% Derivative notation
$f'(x), f''(x), f'''(x)$
$\frac{df}{dx}, \frac{d^2f}{dx^2}$

% Partial derivatives
$\frac{\partial f}{\partial x}$
$\frac{\partial^2 f}{\partial x \partial y}$

% Nabla (del) operator
$\nabla f$
$\nabla \cdot \mathbf{F}$  % Divergence
$\nabla \times \mathbf{F}$  % Curl

Common Mistakes to Avoid

❌ Mistake 1: Not Using Math Mode

% WRONG - variables in text mode look wrong
Let x = 5 and y = 10.

% CORRECT - use math mode for variables
Let $x = 5$ and $y = 10$.

❌ Mistake 2: Using * for Multiplication

% WRONG - * shows as superscript placeholder
$a * b$

% CORRECT - use \times, \cdot, or implicit
$a \times b$  % Cross
$a \cdot b$   % Dot
$ab$          % Implicit (best for variables)

❌ Mistake 3: Forgetting Braces for Multi-character Super/Subscripts

% WRONG - only first character becomes superscript
$x^10$ produces x¹0 instead of x¹⁰

% CORRECT - use braces
$x^{10}$ produces x¹⁰

❌ Mistake 4: Using align Without amsmath

The align, gather, and many other math environments require the amsmath package. Add \usepackage{amsmath} to your preamble!

Frequently Asked Questions

How do I write math equations in LaTeX?

Use dollar signs for inline math: $E = mc^2$, or use \[...\] for display math. For numbered equations, use the equation environment.

What's the difference between $ and \[ in LaTeX?

$...$ creates inline math within text, while \[...\] creates centered display math on its own line. Display math is larger and more prominent.

How do I write fractions in LaTeX?

Use \frac{numerator}{denominator}. Example: $\frac{1}{2}$ produces ½. For inline text, consider using / or \tfrac for better spacing.

How do I align multiple equations in LaTeX?

Use the align environment from the amsmath package. Place & before the alignment point (usually the equals sign) and \\ at the end of each line.

How do I number equations in LaTeX?

Use the equation environment for automatic numbering. Use \label{eq:name} to label and \ref{eq:name} to reference. Add * (like equation*) to suppress numbering.

Why are my Greek letters not showing?

Greek letters only work in math mode. Use $\alpha$ not just \alpha. Make sure you're in math mode with dollar signs or equation environments.

How do I write matrices in LaTeX?

Use matrix environments like pmatrix (parentheses), bmatrix (brackets), or vmatrix (determinant). Separate columns with & and rows with \\. Requires amsmath package.

What package do I need for advanced math in LaTeX?

The amsmath package is essential for advanced math. Add \usepackage{amsmath} to your preamble. For additional symbols, also consider amssymb and amsthm.

Related LaTeX Math Tutorials

Create Professional Mathematical Documents

Now that you've mastered LaTeX math, create professional academic papers, research documents, and technical resumes with perfect mathematical typesetting.

Browse LaTeX Resume Templates More LaTeX Tutorials