How to Write Math Equations in LaTeX (Cheat Sheet)
Write math in LaTeX with inline $...$ or display \[...\]; use the align environment for multi-line equations. Full symbol and operator cheat sheet inside.
Write math in LaTeX using inline $...$ for symbols inside text, or display mode \[...\] for standalone equations. Load the amsmath package for the professional environments — align, cases, matrix — that every journal expects. LaTeX then renders mathematics with the spacing rules of a typeset textbook.
1. Inline vs display
The mass-energy relation $E = mc^2$ is inline.
The same equation, displayed and numbered:
\begin{equation}
E = mc^2 \label{eq:emc2}
\end{equation}
Use ^ for superscripts and _ for subscripts. Group multi-character exponents in braces: x^{2n}, not x^2n.
2. The fundamentals
| You want | You type | Renders as |
|---|---|---|
| Fraction | \frac{a}{b} | a over b |
| Square root | \sqrt{x}, \sqrt[3]{x} | √x, cube root |
| Subscript / superscript | x_i, x^2 | xᵢ, x² |
| Sum | \sum_{i=1}^{n} | Σ from i=1 to n |
| Integral | \int_0^\infty | definite integral |
| Greek | \alpha \beta \gamma \pi | α β γ π |
For the full list of symbols, see LaTeX Math Symbols: The Complete Reference.
3. Multi-line equations with align
The align environment lines equations up on the & marker — the standard for derivations.
\begin{align}
(a+b)^2 &= a^2 + 2ab + b^2 \\
&= a^2 + b^2 + 2ab
\end{align}
Use align* to suppress equation numbers, or \nonumber on individual lines. For piecewise functions:
f(x) =
\begin{cases}
x^2 & \text{if } x \ge 0 \\
-x & \text{otherwise}
\end{cases}
4. Matrices and vectors
A =
\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}
pmatrix gives parentheses, bmatrix brackets, vmatrix determinant bars. Full guide: Typeset Matrices & Vectors in LaTeX.
5. Reference equations and avoid errors
Label any displayed equation with \label{eq:key} and cite it as Equation~\eqref{eq:key} (the \eqref from amsmath adds the parentheses). The most common math mistake — using ^ or \frac outside $...$ — triggers "Missing $ inserted"; the fix is here.
→ See equations render the instant you type them in LetX. Chemistry instead? Read chemistry formulas with mhchem.
Written by Shihab Shahriar Antor — AI Engineer & Founder of Shahriar Labs, maker of LetX.
Frequently Asked Questions
What is the difference between inline and display math?
Inline math sits inside a line of text using $...$ (or \(...\)), and LaTeX compresses it to fit the line height, so fractions look small. Display math sits on its own line using \[...\] for an unnumbered equation or the equation environment for a numbered one, and it gets full vertical space. Use inline for short symbols within a sentence and display for any equation you will refer to or that needs room to breathe.
How do I align a series of equations on the equals sign?
Use the align environment from the amsmath package and place an ampersand & immediately before each = sign you want to line up. End each line with \\. align numbers every line; use align* for no numbers, or add \nonumber on a specific line. This is the standard way to typeset a multi-step derivation so every equals sign stacks vertically.
Why do I get 'Missing $ inserted' when writing math?
That error means you used a math-only command — like ^, _, \alpha, or \frac — outside math mode, so LaTeX expected a $ to enter math mode and didn't find one. Wrap the expression in $...$ for inline or \[...\] for display. It also fires if you forget to close a $; check that every opening dollar sign has a matching closing one. Full breakdown in our missing-dollar error guide.