Write inline and display mathematics
Choose the right math mode and write clear equations inside sentences or on separate lines.
On this page
Mathematics belongs in a sentence, even when it appears on a separate line. Choose a math environment according to whether readers need an equation number, and keep punctuation in the source so the surrounding prose remains grammatical.
Choose inline, displayed, or numbered math#
The example assumes independent observations with the same finite population
variance σ². An estimated variance of the sample mean would instead
use an estimate of that population variance.
Use \(...\) for a short expression inside prose and \[...\] for an unnumbered display. Use equation when later prose refers to a numbered result.
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\Var}{Var}
\begin{document}
For independent observations \(x_1,\ldots,x_n\) with common finite variance
\(\sigma^2\), let \(\bar{x}\) denote the sample mean. Its variance is
\begin{equation}
\Var(\bar{x}) = \frac{\sigma^2}{n},
\label{eq:mean-variance}
\end{equation}
where \(\sigma^2\) is the population variance. Equation~\eqref{eq:mean-variance}
shows that uncertainty decreases as the sample size grows.
\end{document}The output should contain inline symbols within two sentences and one numbered equation cited as “Equation (1).” The comma belongs to the equation because the sentence continues with “where.” \DeclareMathOperator gives the multi-letter operator Var upright letters and operator spacing; typing $Var$ would produce three multiplied variables.
Put text and references in the right mode#
Load amsmath when you need equation*, align, \text, or \eqref. Use \text{...} for a short explanation inside math, for example x=0 \text{ when the sensor is inactive}. Longer explanations belong in ordinary prose before or after the display.
Place \label inside the numbered environment and cite it by name rather than typing (1). CorTeX performs normal reruns, so references settle after compilation. The cross-reference lesson develops this pattern.
Avoid ambiguous boundaries#
Keep ordinary prose outside math mode, and put mathematical _ and ^
inside it. Escape a literal underscore in prose as \_. Do not nest \[...\] inside equation or align. Prefer \(...\) and \[...\] in new source because their opening and closing roles are explicit; a stray $ is harder to diagnose. Use equation* or \[...\] for a display that the paper never cites—unnecessary numbers make later review harder.
As an exercise, change the example to a standard error, \sigma/\sqrt{n}, and update the following sentence without typing an equation number. You are done when the citation still resolves after inserting another displayed equation above it. Continue with subscripts, fractions, and roots.
