Master LaTeX mathematical typesetting with this comprehensive guide covering inline math, display equations, advanced formatting, professional typography, and collaboration techniques.
Mathematics is the language of science, and LaTeX is its typesetting champion. Whether you’re proving theorems or presenting experimental results, mastering LaTeX’s math modes will elevate your documents from amateur hour to publication-ready precision. Let’s dive into the mathematical deep end – the water’s fine, and the equations are beautiful.
LaTeX offers two primary math modes, each with its own purpose and syntax. Understanding when to use each is like knowing when to use a fork versus a spoon – technically you could eat soup with a fork, but why would you?
For mathematical expressions that flow within your text:
The famous equation $E = mc^2$ revolutionized physics.
% Alternative syntax (less common):
The quadratic formula is \(x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\).
For equations that deserve their own spotlight:
% Using double dollars (common but not recommended):
$$\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}$$
% Using \[ \] (recommended):
\[\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}\]
% Using equation environment (for numbering):
\begin{equation}
\nabla \cdot \mathbf{E} = \frac{\rho}{\epsilon_0}
\end{equation}
Every physicist’s best friends:
% Lowercase Greek
$\alpha, \beta, \gamma, \delta, \epsilon, \zeta, \eta, \theta$
% Uppercase Greek
$\Gamma, \Delta, \Theta, \Lambda, \Xi, \Pi, \Sigma, \Phi, \Psi, \Omega$
% Common mathematical symbols
$\infty, \partial, \nabla, \forall, \exists, \in, \subset, \cup, \cap$
The building blocks of complex notation:
% Simple sub/superscripts
$x^2, x_i, x^{2n}, x_{i,j}$
% Combined
$x_i^2, x_{min}^{max}$
% Pre-scripts (requires amsmath)
${}_2^4He$ % Helium-4
Because nobody likes writing 1/2 when you can have proper fractions:
% Basic fractions
$\frac{a}{b}$
% Nested fractions
$\frac{1}{1 + \frac{1}{x}}$
% Display vs inline fractions
Text mode: $\frac{a}{b}$ vs $\tfrac{a}{b}$ (tiny)
Display: $\dfrac{a}{b}$ (display style in text)
% Binomial coefficients
$\binom{n}{k} = \frac{n!}{k!(n-k)!}$
For when one line just isn’t enough:
\begin{align}
f(x) &= (x+a)(x+b) \\
&= x^2 + (a+b)x + ab \\
&= x^2 + bx + ax + ab \\
&= x^2 + (a+b)x + ab
\end{align}
% Without alignment
\begin{gather}
a = b + c \\
x = y - z \\
p = q \cdot r
\end{gather}
For functions with conditions:
f(x) = \begin{cases}
x^2 & \text{if } x \geq 0 \\
-x^2 & \text{if } x < 0
\end{cases}
Linear algebra made beautiful:
% Basic matrix
\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}
% Different delimiters
\begin{bmatrix} % Square brackets
1 & 2 & 3 \\
4 & 5 & 6
\end{bmatrix}
% Determinant
\begin{vmatrix}
a & b \\
c & d
\end{vmatrix} = ad - bc
% Custom arrays
\left[
\begin{array}{c|c}
A & B \\
\hline
C & D
\end{array}
\right]
LaTeX handles most spacing automatically, but sometimes you need manual control:
% Spacing commands (smallest to largest)
$a\!b$ % Negative thin space
$ab$ % Normal
$a\,b$ % Thin space
$a\:b$ % Medium space
$a\;b$ % Thick space
$a\ b$ % Normal space
$a\quad b$ % Quad space
$a\qquad b$ % Double quad
% Common uses
$\int f(x)\,dx$ % Thin space before dx
$\{x \mid x > 0\}$ % Spaces around condition
Make your custom operators look professional:
% Declare operators
\DeclareMathOperator{\sgn}{sgn}
\DeclareMathOperator*{\argmax}{arg\,max}
% Usage
$\sgn(x)$ % Proper spacing
$\argmax_{x \in X} f(x)$ % Limits below in display mode
When words crash the equation party:
% Wrong: $x > 0 for all x$
% Right:
$x > 0 \text{ for all } x$
$x > 0 \quad \forall x$ % Using symbol
% With amsmath
\begin{equation}
E = mc^2 \qquad \text{(Einstein's equation)}
\end{equation}
Problem: “Missing $ inserted”
Solution: Check for:
_
or ^
in text% Wrong: The value x_1 is important
% Right: The value $x_1$ is important
Problem: Brackets don’t match content height
Solution: Use \left
and \right
:
% Wrong:
$(\frac{a}{b})$
% Right:
$\left(\frac{a}{b}\right)$
% Manual sizing when needed:
$\big( \Big( \bigg( \Bigg($
Problem: Equations won’t align properly
Solution: Use &
strategically:
\begin{align}
2x + 3y &= 7 \\
x - y &= 1
\end{align}
Save time and ensure consistency:
% In preamble
\newcommand{\R}{\mathbb{R}}
\newcommand{\E}[1]{\mathbb{E}\left[#1\right]}
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
% Usage
$f: \R \to \R$
$\E{X} = \mu$
$\norm{x} \leq 1$
For mathematical rigor:
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\begin{theorem}[Fermat's Last Theorem]
No three positive integers $a$, $b$, and $c$ satisfy
$a^n + b^n = c^n$ for any integer $n > 2$.
\end{theorem}
When equations need visual support:
\begin{tikzpicture}
\draw[->] (-2,0) -- (2,0) node[right] {$x$};
\draw[->] (0,-2) -- (0,2) node[above] {$y$};
\draw[domain=-1.5:1.5,smooth,variable=\x,blue]
plot ({\x},{\x*\x});
\node at (1.5,2) {$y = x^2$};
\end{tikzpicture}
% Vectors
\newcommand{\vect}[1]{\boldsymbol{#1}}
$\vect{F} = m\vect{a}$
% Derivatives
$\frac{d}{dt}\left(\frac{\partial L}{\partial \dot{q}_i}\right)
- \frac{\partial L}{\partial q_i} = 0$
% Bra-ket notation
$\langle \psi | \hat{H} | \psi \rangle = E$
% Complexity notation
$O(n\log n)$, $\Theta(n^2)$, $\Omega(n)$
% Logic
$\forall x \in S : P(x) \implies Q(x)$
% Algorithms
\begin{algorithmic}
\State $sum \gets 0$
\For{$i = 1$ to $n$}
\State $sum \gets sum + a_i$
\EndFor
\end{algorithmic}
% Probability
$P(A \mid B) = \frac{P(B \mid A)P(A)}{P(B)}$
% Distributions
$X \sim \mathcal{N}(\mu, \sigma^2)$
% Expectation and variance
$\mathrm{Var}(X) = \mathbb{E}[X^2] - (\mathbb{E}[X])^2$
For documents with heavy math:
\includeonly
for partial compilation\tikzexternalize
Choose fonts that complement your equations:
% Modern look
\usepackage{unicode-math}
\setmathfont{XITS Math}
% Classic look
\usepackage{mathpazo} % Palatino-based
% Sans-serif math
\usepackage{sfmath}
When using platforms like inscrive.io:
Create a project-specific math preamble:
% project-math.sty
\ProvidesPackage{project-math}
% Common notation
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\prob}[1]{\Pr\left[#1\right]}
% Ensure everyone uses the same symbols
Track equation changes effectively:
% Use labels for important equations
\begin{equation}\label{eq:main-result}
E = mc^2
\end{equation}
% Reference by label, not number
As shown in \eqref{eq:main-result}...
For comprehensive collaboration strategies, see our guide on LaTeX Collaboration Best Practices.
Error | Cause | Solution |
---|---|---|
“Missing $ inserted” | Math outside math mode | Add $ or check for stray _/^ |
“Extra }, or forgotten $” | Mismatched braces | Count your braces |
“Undefined control sequence” | Unknown command | Check spelling or load package |
“Double subscript” | Multiple subscripts | Use braces: x_{i_j} |
% Show math boundaries
\usepackage{showframe}
% Highlight overfull boxes
\overfullrule=2cm
% Check alignment points
\usepackage{mathtools}
\mathtoolsset{showonlyrefs}
Mastering LaTeX math mode is a journey, not a destination. Each equation you typeset makes you better at the craft. Remember these key principles:
With modern tools like inscrive.io, mathematical collaboration has never been easier. Real-time preview means you see your beautiful equations as you type them, and collaborative editing ensures your notation stays consistent across authors.
Now stop reading about math mode and go write those equations. That theorem won’t prove itself!
Master LaTeX mathematical typesetting with this comprehensive guide covering inline math, display equations, advanced formatting, professional typography, and collaboration techniques.
Read in 18 minutesCompare LaTeX and Microsoft Word for academic writing, exploring their strengths, weaknesses, mathematical capabilities, citation management, and when to use each tool for maximum productivity.
Read in 15 minutesMaster the basics of LaTeX with this comprehensive beginner guide. Learn essential commands, document structure, mathematical expressions, citations, and best practices for academic writing.
Read in 20 minutesDiscover the top alternatives to Overleaf for LaTeX editing. Compare features, pricing, and collaboration tools of inscrive.io, Crixet, TeXPage, and other powerful online LaTeX editors for academic writing.
Read in 12 minutesStay up to date with the roadmap progress, announcements and exclusive discounts feel free to sign up with your email.
We care about the protection of your data. Read our Privacy Policy.