If you are setting serious mathematics, the first package to load is amsmath — the American Mathematical Society’s package, the de facto standard for math typesetting, which substantially reinforces LaTeX’s built-in math facilities, from aligned displays to fine spacing control. This page is not about the alignment environments themselves (those have their own page); it is about why you load amsmath, and the cross-cutting commands that work across environments — \text, \operatorname, \DeclareMathOperator, \intertext, \substack, and \numberwithin. It also introduces amsmath’s companions: amssymb / AMSFonts, which bring blackboard bold, Fraktur, and hundreds of extra symbols, and amsthm for theorem environments.
What amsmath is
amsmath is the math package that the American Mathematical Society (AMS) has developed for setting its own journals. LaTeX’s built-in math facilities are minimal — they do not reach to aligning multi-line formulas, fine control of equation numbers, or setting function names correctly. amsmath fills these gaps in one stroke and is today considered effectively mandatory for documents in mathematics and physics. Loading it takes a single line in the preamble.
\usepackage{amsmath}amsmath is less a single package than a bundle of smaller ones. As its official User’s Guide states plainly, amsmath incorporates amstext (the \text command for text inside math), amsopn (\DeclareMathOperator and friends for defining operators), and amsbsy (bold math via \boldsymbol). So the one line \usepackage{amsmath} brings all of these along with it.
The most conspicuous of amsmath’s offerings are its environments for aligning multi-line formulas — align, gather, multline, split, alignat, and the case-distinction environment cases, among others. These are substantial enough to have their own page, “Displayed, aligned & numbered equations”; here we merely name them and instead focus on the cross-cutting commands that work inside any environment.
amssymb and AMSFonts
The counterpart to amsmath is amssymb (part of AMSFonts), which supplies symbols and fonts. The two have different jobs: amsmath adds typesetting machinery (alignment, spacing, numbering), while amssymb enlarges the stock of symbols and alphabets you can write. Load it in the preamble like this.
\usepackage{amssymb}amssymb defines every symbol contained in the AMS symbol fonts msam and msbm, making available hundreds of extra symbols absent from standard LaTeX — for example \leqslant and \geqslant (slanted inequalities), \nleq and \subsetneq (negated and proper-subset relations), \therefore and \because, \square and \blacksquare, and \varnothing (an alternative empty-set glyph). Because amssymb loads amsfonts internally, you need not name amsfonts separately.
amssymb (more precisely AMSFonts) also adds two math alphabets: blackboard bold via \mathbb{...} and Fraktur (Gothic) via \mathfrak{...}. \mathbb{R}, \mathbb{C}, and \mathbb{Z} give the open-face bold R, C, and Z for the reals, the complex numbers, and the integers. Note, however, that blackboard bold is uppercase only — there are no lowercase letters or digits. Fraktur, by contrast, comes in both cases, so you can write \mathfrak{g} for a Lie algebra g or \mathfrak{p} for a prime ideal p.
\[
\mathbb{R} \subset \mathbb{C}, \qquad
\mathfrak{g} = \operatorname{Lie}(G)
\]This example shows, in open-face bold, that the reals R sit inside the complex numbers C, then writes the Lie algebra of a Lie group G as a Fraktur g. Since \mathbb and \mathfrak are AMSFonts features, \usepackage{amsfonts} suffices if you want only the fonts and not the symbols; but because you usually want the symbols too, loading amssymb is the reliable choice.
Text inside math — `\text`
In math mode every letter is read as a variable, so typing area yields the product of four variables. To put ordinary words, upright and correctly spaced, inside a formula, use \text{...} from amsmath (precisely, from the incorporated amstext). The enclosed string is set in the same font and spacing as body text.
The advantage of \text is that it is size-aware. The older \mbox{...} can also drop upright text into math, but it stays at body size even inside a subscript or superscript, clashing with the smaller type around it. \text shrinks to match its context — to script size inside a subscript, and smaller still in a second-order script. Its name, too, plainly states its purpose.
\[
f(x) = x^2 \quad \text{for all } x \in \mathbb{R},
\qquad v_{\text{max}} = 3.
\]Here \text{for all } is set upright at body size to the right of the formula (the trailing space is honored), while the subscript on v, \text{max}, is set upright but shrunk to script size. With \mbox the latter would come out too large for its surroundings. Note that writing $...$ inside \text{...} switches that part back into math.
Named operators — `\operatorname` and `\DeclareMathOperator`
Function names such as \sin, \log, and \lim are predefined in standard LaTeX, set upright with proper spacing. But operators not on that list — rank, Hom, ess sup, and the like — you must define yourself. Two commands from amsmath (the incorporated amsopn) handle this.
For a one-off upright operator, use \operatorname{...}. Writing \operatorname{rank} A, for instance, sets rank upright with the correct operator spacing after it, so it neither crowds nor drifts from the following A. If you use the same operator repeatedly, it is cleaner to define it once in the preamble with \DeclareMathOperator{\rank}{rank} and then write \rank in the body. \DeclareMathOperator is a preamble-only command; it cannot be used in the document body.
Both commands have a starred form that changes where scripts go. The unstarred \operatorname / \DeclareMathOperator places a subscript at the operator’s lower right (as with \log). The starred \operatorname* / \DeclareMathOperator* places it directly below in display style — the “limits” position, as with \lim, \sup, and \max. Operators with an index underneath, such as argmax and argmin, are defined with the starred form.
% プリアンブル / in the preamble
\DeclareMathOperator{\rank}{rank}
\DeclareMathOperator*{\argmax}{arg\,max}
% 本文 / in the body
\[
\rank A \le n, \qquad
\hat{x} = \argmax_{x \in S} f(x)
\]Here two operators are defined in the preamble. In the body, \rank A sets rank upright, while \argmax, being in a display, places x ∈ S directly under arg max (because it was defined with the star). The \, inside the definition is a thin space between arg and max, keeping them legible as two words.
Text within alignments, and stacked subscripts
The next two commands come into play together with alignment environments and big operators. First, \intertext{...} lets you **insert a line of text in the middle of a multi-line display (such as align) while preserving the alignment**. If you naively close the environment, write the text, and reopen it, the alignment points before and after will no longer match. With \intertext, the & columns of the lines above and below stay aligned across the interjected text.
\begin{align}
A &= B + C \\
\intertext{ここで $C$ を展開すると / expanding $C$ gives}
A &= B + D + E
\end{align}Here a one-line explanation, “expanding C gives,” sits between the two equations, yet the = in A &= stays aligned above and below. \intertext is meaningful only inside alignment environments like align (see the separate page for those environments in detail).
The other, \substack{...}, stacks several lines of conditions under a big operator such as a sum or product, with lines separated by \\. Use it, for example, to place “0 ≤ i ≤ m” and “0 < j < n” on two lines beneath a summation. The subarray environment does much the same and additionally takes an alignment specifier such as l (left).
\[
\sum_{\substack{0 \le i \le m \\ 0 < j < n}} a_{ij}
\]Here two conditions are stacked on two lines beneath the summation sign, denoting the sum of a_{ij} over that range. The inside of \substack is still math mode, so relations like \le work as usual.
Fractions, binomials, and numbering control
The fraction command \frac itself is part of standard LaTeX, but amsmath adds style-fixed variants. \dfrac{...}{...} always sets the fraction in display style (large) regardless of context, and \tfrac{...}{...} always sets it in text style (small). Use \dfrac to enlarge a fraction in running text, or \tfrac to shrink one part inside a display. For continued fractions there is \cfrac{...}{...}, which keeps each level legibly sized no matter how deep the nesting.
For binomial coefficients there is \binom{n}{k}, which sets the choose symbol — n over k inside round brackets. It too has style-fixed forms, \dbinom (always display style) and \tbinom (always text style).
\[
\binom{n}{k} = \dfrac{n!}{k!\,(n-k)!}
\]Here the left side is the binomial coefficient (n over k in round brackets) and the right side is the fraction n!/(k!(n−k)!) set large with \dfrac. The \, in the denominator is a thin space between the factorial and the bracket.
For numbering, \numberwithin{equation}{section} is handy. Written in the preamble, it ties equation numbers to section numbers, resetting the equation counter at each new section. The first equation of Section 2, for instance, is numbered “(2.1).” It is the standard way to keep equation numbers from running into three or four digits in a long document.
amsmath provides much more besides — matrix environments (pmatrix, bmatrix, and so on), auto-sized delimiters, the alignment environments for displays, and bold math via \boldsymbol. Matrices are covered on “Matrices & arrays,” the alignment environments on “Displayed, aligned & numbered equations,” and sums and big operators on “Sums, integrals & big operators.”
What to put in your preamble
In practice, for any document containing mathematics it is standard to put these three lines together in the preamble: amsmath (the typesetting machinery), amssymb (symbols, plus blackboard bold and Fraktur), and amsthm for theorem and proof environments. The loading order is largely free, with the one caution that amsthm should come after amsmath.
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\begin{document}
\[
\zeta(s) = \sum_{n=1}^{\infty} \frac{1}{n^{s}}, \qquad s \in \mathbb{C}
\]
\end{document}This minimal example loads the three packages and then sets the definition of the Riemann zeta function as a display, with n=1 below and ∞ above the summation sign, and \mathbb{C} rendering the complex numbers C in open-face bold. The theorem, proof, and related environments that amsthm provides are a topic of their own, covered on the page “Theorems & proofs (amsthm).”
| Package | Role | What it provides |
|---|---|---|
amsmath | Math typesetting machinery | Alignment environments, \text, \operatorname, \dfrac, \binom, etc. |
amssymb | Symbols and math alphabets | Hundreds of msam/msbm symbols, \mathbb, \mathfrak (loads amsfonts) |
amsfonts | Fonts only | \mathbb and \mathfrak (no extra symbols) |
amsthm | Theorem & proof environments | \newtheorem, the proof environment, \theoremstyle |