Written and maintained by CASRAI Editorial Board
Published · Last updated
On this page
The LaTeX amsmath package is the foundational extension developed by the American Mathematical Society for typesetting complex mathematical formulas, multi-line equation derivations, and structured matrix systems in scientific publications. Maintained as a standard component of the LaTeX distribution by the LaTeX Project, amsmath replaces fragile legacy structures like eqnarray with robust environments such as align, gather, multline, and cases, ensuring standardized typography across peer-reviewed research.
What it is used for in research
In academic writing across mathematics, physics, engineering, statistics, and computer science, mathematical notation communicates the core theoretical models and empirical derivations of a study. Standard base LaTeX provides elementary mathematical typesetting capabilities through inline delimiters and the basic equation display environment. However, when researchers construct complex mathematical proofs, systems of coupled differential equations, or multi-step statistical derivations, base LaTeX encounters severe typographic limitations.
Historically, researchers relied on the standard LaTeX eqnarray environment to format multi-line calculations. The eqnarray command suffers from well-documented flaws: it enforces inconsistent, disproportionately wide horizontal spacing around relational operators, frequently permits equation numbers to collide directly with lengthy formulas without automatic suppression or shifting, and lacks semantic flexibility for grouped systems. To overcome these deficiencies, the American Mathematical Society (AMS) developed AMS-LaTeX in the late 1980s and 1990s, led by Michael Downes and Frank Mittelbach. The core mathematical macros were unified into the amsmath package, which has since been adopted as a mandatory requirement by major academic publishers including Elsevier, Springer Nature, IEEE, and the Society for Industrial and Applied Mathematics (SIAM).
In contemporary research workflows, amsmath is used for several critical typesetting tasks:
- Precise Multi-Line Alignment: The package provides specialized display structures, including
alignfor equations aligned at relation symbols (such as equality or inequality signs),gatherfor consecutive centered equations without horizontal alignment, andmultlinefor long single formulas that span multiple physical lines. - Subordinate and Nested Systems: Researchers can nest inner structures like
split,aligned, andgatheredwithin primary equation environments. This allows authors to maintain a single global equation number for a multi-step algebraic derivation, or cross-reference individual sub-equations using the companion align and aligned environments. - Matrix and Vector Typography: Through built-in matrix environments—including
matrix,pmatrix,bmatrix,vmatrix, andVmatrix—authors produce matrices with appropriate brackets, determinants, and norms without manually coding coordinate arrays. For specialized tabular math structures, see the companion guide to LaTeX matrix environments. - Piecewise Definitions and Conditional Logic: The
casesenvironment formats piecewise functions, boundary conditions, and decision trees using a unified, scalable left brace, detailed further in our overview of the cases environment for piecewise functions. - Semantic Operator Declaration: The
DeclareMathOperatorandoperatornamecommands generate custom mathematical operators with the correct upright font and contextual kerning matching standard operators like sine, limit, and logarithm. - Flexible Equation Cross-Referencing: The package introduces
eqref, which automatically encloses equation references in standardized parentheses, ensuring consistency across journal articles regardless of local punctuation habits.
How to install or access it
The amsmath package is licensed under the LaTeX Project Public License (LPPL 1.3c) and is included as a standard, pre-installed component of the LaTeX required bundle. Consequently, researchers working in modern TeX distributions do not need to execute external downloads or package management operations to access the core software.
The package is universally accessible across the primary TeX ecosystems:
- TeX Live (Linux and Windows): Distributed as part of the core
collection-latexscheme, maintained annually by the TeX Users Group (TUG). - MacTeX (macOS): Included in the default full installation for macOS systems, accessible through TeXShop, VS Code, and terminal engines.
- MiKTeX (Windows and Linux): Packaged in the fundamental MiKTeX installation. If a minimal MiKTeX installation is used, the package manager retrieves
amsmathautomatically from CTAN upon encountering the declaration. - Cloud TeX Platforms (Overleaf): Pre-installed and maintained across all active TeX Live image versions on cloud platforms.
To load the package into a research manuscript, insert the package declaration in the document preamble prior to the begin{document} command:
documentclass[11pt,a4paper]{article}
usepackage{amsmath}
usepackage{amssymb} % Recommended companion for AMS mathematical symbols
When loading amsmath, authors can supply optional parameters to modify global layout, tag alignment, and operator limit rules across the entire document:
fleqn: Left-aligns all displayed equations with a fixed indentation from the left margin, rather than centering them horizontally on the page. While this option can also be declared indocumentclass, passing it toamsmathenforces flush-left alignment across all AMS display structures.leqno: Places all equation numbers and labels on the left margin rather than the standard right margin (reqno).centertags: The default setting, which centers equation numbers vertically relative to the total height of split or multi-line equations.tbtags: “Top-or-bottom tags.” Forces equation numbers to align vertically with the bottom line (when equation numbers are on the right) or with the top line (when equation numbers are on the left) of a multi-line derivation.intlimits: Forces integration limits for single and multiple integrals (int,iint,iiint) to appear directly above and below the integral symbol in display mode, overriding the standard side-subscript convention (nointlimits).sumlimits: Enforces limits above and below summation-type operators (sum,prod,coprod) in display equations (enabled by default).namelimits: Positions subscripts directly beneath named operator limits such aslim,max,min, andinfin displayed equations (enabled by default).
An example preamble utilizing custom layout parameters appears as follows:
usepackage[leqno,intlimits,tbtags]{amsmath}
Step-by-step instructions
To implement amsmath in a scientific research paper, execute the following numbered steps. This workflow covers establishing the preamble, writing aligned derivations, splitting long formulas, formatting piecewise functions, and defining custom mathematical operators.
- Establish the Document Preamble and Load Packages:
Open your LaTeX source file (for example,
manuscript.tex) in your text editor or TeX IDE. At the top of the file, specify the document class and includeamsmathalongside companion symbol packages.documentclass[12pt]{article} usepackage{amsmath} usepackage{amssymb} usepackage{amsthm} - Typeset Single-Line Numbered and Unnumbered Display Equations:
To produce a single-line displayed formula with an automatic reference tag, use the
equationenvironment. To suppress the equation number, use the unstarredequation*environment or insertnonumberprior to the line closure.begin{equation} E = mc^2 label{eq:einstein} end{equation} begin{equation*} F = ma end{equation*} - Format Multi-Line Systems with Aligned Equality Signs:
When presenting multi-step algebraic reductions or simultaneous equations, use the
alignenvironment. Place an ampersand (&) immediately before the alignment anchor (typically the equals sign or inequality symbol), and terminate each line with a double backslash (\). The final line of the environment must not end with a double backslash.begin{align} nabla times mathbf{E} &= -frac{partial mathbf{B}}{partial t} label{eq:faraday} \ nabla times mathbf{B} &= mu_0 mathbf{J} + mu_0 varepsilon_0 frac{partial mathbf{E}}{partial t} label{eq:ampere} end{align}To suppress numbering on a specific row while preserving numbers on subsequent rows, append
nonumberbefore the line break. For extensive algebraic proofs, consult our dedicated guide on multiline equation formatting in LaTeX. - Break Extended Equations Using the Split Environment:
When a single mathematical expression exceeds the text column width, place the
splitenvironment inside a parentequationenvironment. Thesplitstructure aligns subordinate rows while assigning exactly one equation number to the entire composite block.begin{equation} begin{split} f(x) &= a_0 + sum_{n=1}^{infty} left( a_n cosfrac{npi x}{L} + b_n sinfrac{npi x}{L} right) \ &= a_0 + a_1 cosfrac{pi x}{L} + b_1 sinfrac{pi x}{L} + a_2 cosfrac{2pi x}{L} + cdots end{split} label{eq:fourier} end{equation} - Declare Custom Semantic Operators in the Preamble:
Standard mathematical writing requires operators such as “argmin”, “rank”, or “diag” to appear in upright Roman font with proper horizontal spacing. Never typeset these as math variables using
textitor raw text. Declare custom operators in the preamble usingDeclareMathOperator(for standard inline operators) orDeclareMathOperator*(for operators that accept subscript limits directly underneath in display mode).% In the preamble: DeclareMathOperator{rank}{rank} DeclareMathOperator*{argmax}{arg,max} % In the document body: begin{equation} hat{theta} = argmax_{theta in Theta} mathcal{L}(theta; mathbf{y}) end{equation} - Cross-Reference Equations with Standardized Parentheses:
Reference labeled equations in your narrative using the
eqrefmacro. Unlike the standard LaTeXrefcommand,eqrefautomatically wraps the target counter in parentheses, producing “(1)” instead of “1”.As demonstrated in Equation~eqref{eq:einstein} and derived in eqref{eq:fourier}, the energy equivalence holds.
Output and how to read it
When compiling a LaTeX manuscript containing amsmath markup, the underlying TeX engine (such as pdfLaTeX, XeLaTeX, or LuaLaTeX) translates the mathematical macros into precise bounding boxes, baseline calculations, and font glyphs. Verifying the visual and structural output ensures compliance with journal submission criteria.
When inspecting the compiled PDF document, authors should verify four visual and structural characteristics:
- Horizontal Alignment Uniformity: In
alignandalignedblocks, all specified relational markers (such as=,le, orrightarrow) must align along an identical vertical axis. Check that ampersands are positioned immediately preceding the relation symbol rather than after it, preventing asymmetric white space. - Vertical Centering of Equation Numbers: In
splitandgatheredenvironments under the defaultcentertagssetting, confirm that the equation tag sits precisely halfway between the top and bottom lines of the block. Iftbtagswas enabled, confirm that the tag sits flush with the final line (for right-hand tags) or top line (for left-hand tags). - Operator Font Geometry and Kerning: Check that custom operators declared via
DeclareMathOperatorrender in upright Roman type with standardized thin spaces (thinspace) separating them from preceding and succeeding mathematical variables. Verify that limit arguments placed underDeclareMathOperator*shift beneath the operator name in display mode rather than displaying as trailing subscripts. - Equation Number Spacing and Margin Constraints: Verify that lengthy mathematical expressions do not overlap the equation tag in the right margin. If an equation approaches the margin,
amsmathshifts the equation number downward to a separate line to prevent visual collision. If an overfull horizontal box warning (Overfull hbox) is reported in the compilation log, break the line earlier usingsplitormultline.
The companion dataset below systematically compares the structural characteristics, numbering behaviors, and alignment paradigms of all core display environments provided by amsmath.
Troubleshooting
Because amsmath modifies the low-level math parsing mechanisms of LaTeX, syntax discrepancies that pass undetected in plain text environments trigger explicit compilation errors. The following solutions resolve the most frequent issues encountered in research manuscripts:
- Package amsmath Error: Erroneous nesting of equation structures:
Cause: An author placed a top-level display math environment (such as
align,gather, oralignat) inside an existing display math block, such as$$...$$,[...], orbegin{equation}.Fix: Top-level environments manage their own display math mode. Remove the outer
equationor[...]wrapper completely. If an aligned multi-line expression is required inside anequationblock (for example, to share a single equation number), replace the outeralignwith the subordinatealignedorsplitenvironment. - Runaway argument? / Paragraph ended before align* was complete:
Cause: A blank line (paragraph break) was accidentally inserted inside an
amsmathdisplay environment. In LaTeX, display math environments cannot contain empty lines orpartokens.Fix: Remove all empty lines inside the environment. If visual code separation is needed for readability, use TeX comment markers (
%) on otherwise empty lines. - LaTeX Error: Command iint already defined (or iiint):
Cause: A collision occurred between
amsmathand an external symbol package (such astxfonts,pxfonts,wasysym, oresint) that also defines multiple integral symbols.Fix: Ensure that
usepackage{amsmath}is loaded before any other mathematical font or symbol packages. If usingesintfor specialized integral signs, load it afteramsmath, or pass thenointegralsoption to conflicting packages. - Misplaced or Missing Alignment Ampersands:
Cause: Omitting the ampersand (
&) on one row of analignenvironment causes LaTeX to treat the line as unanchored, producing irregular horizontal displacement and unexpected column shifts.Fix: Verify that every line in an
alignblock contains exactly the same number of ampersands. For a single column of aligned equations, ensure each line has exactly one ampersand preceding the relation symbol. - Incorrect Equation Reference Numbers with label:
Cause: Placing the
label{...}command outside the display environment, or placing it after the double backslash (\) on the final line, attaches the label to the following section counter rather than the equation counter.Fix: Always place
label{...}inside the environment immediately preceding the\or immediately beforeend{...}on the final line.
Free alternatives
While amsmath is the established industry standard for mathematical typesetting in LaTeX, several complementary packages, extensions, and modern alternatives exist across the open-source TeX ecosystem. Researchers can select between lightweight built-in tools, modern extensions that build on top of amsmath, and Unicode-native compilation engines.
The table below summarizes the primary free alternatives and companion extensions available for mathematical typesetting in LaTeX:
| Tool or Package | Distribution / Maintainer | Primary Purpose | Key Advantage over Base amsmath | Compatibility Notes |
|---|---|---|---|---|
| mathtools | LaTeX Project / Morten Høgholm | Direct extension and enhancement overlay for amsmath | Provides paired delimiters (DeclarePairedDelimiter), prescript commands, and fine tag adjustments | Loads amsmath automatically; fully backward compatible with all amsmath environments |
| empheq | Morten Høgholm / TeX Live | Visual emphasis and boxing of multi-line equations | Enables color boxing, side-notes, and decorative braces around align and gather blocks | Requires amsmath and mathtools; extends standard AMS display syntax |
| breqn | Will Robertson / LaTeX Project | Automatic line-breaking of complex displayed formulas | Breaks long formulas across multiple lines automatically without manual \ line breaks | Experimental; can conflict with complex AMS sub-environments and packages modifying math codes |
| unicode-math | Will Robertson / CTAN | Native Unicode OpenType mathematical typesetting | Directly accesses thousands of Unicode math symbols using XeLaTeX and LuaLaTeX engines | Replaces traditional TeX font encodings; designed for LuaLaTeX and XeLaTeX workflows |
| Base LaTeX Math | LaTeX Base Distribution | Minimal built-in mathematical notation | Zero package dependencies; built into core TeX format files | Lacks align, gather, and cases; eqnarray produces flawed horizontal spacing |
For most scientific researchers, the recommended best practice is not to replace amsmath, but rather to load mathtools, which transparently imports amsmath while offering refined delimiter controls and structural extensions.
Frequently asked questions
How do I install or load amsmath in LaTeX?
The amsmath package is included by default in all standard TeX distributions, including TeX Live, MacTeX, and MiKTeX. You do not need to install external files. Simply add usepackage{amsmath} to your document preamble before the begin{document} declaration.
What is the difference between align and aligned in amsmath?
The align environment is a top-level display math environment that creates an independent display equation block and automatically numbers each line. The aligned environment is an inner, subordinate environment designed to be nested inside an existing math block, such as an equation environment or matrix brackets, allowing multiple lines to share a single equation number.
Why should I avoid eqnarray in modern LaTeX?
The legacy eqnarray environment produces excessively wide, inconsistent horizontal spacing around equals signs and relation operators. Furthermore, eqnarray frequently allows equation labels to overlap lengthy mathematical formulas without automatic line shifting, whereas amsmath display environments calculate bounding boxes dynamically to prevent collisions.
How do I suppress equation numbers on specific lines in amsmath?
To suppress the equation number on an individual line within an align or gather environment, insert the nonumber command immediately before the double backslash line break. To suppress equation numbers across the entire environment, use the starred variant, such as align* or gather*.
How can I define a custom operator like argmax or trace in amsmath?
Add DeclareMathOperator{operatorname_name}{text} to your preamble, such as DeclareMathOperator{argmax}{arg,max} or DeclareMathOperator{tr}{tr}. This ensures the operator typesets in upright Roman font with correct thin mathematical kerning matching standard functions like sin and log.
Can amsmath handle piecewise functions and conditional brackets?
Yes. The amsmath package provides the cases environment, which automatically renders an appropriately sized left curly brace and establishes a two-column layout for mathematical definitions and their corresponding conditions or constraints.
Sources
- American Mathematical Society and The LaTeX Project. User’s Guide for the amsmath Package (Version 2.1). Comprehensive TeX Archive Network (CTAN). https://ctan.org/pkg/amsmath (accessed 2026-11-16).
- Downes, Michael, and Barbara Beeton. Short Math Guide for LaTeX (Version 2.0). American Mathematical Society and CTAN. https://ctan.org/pkg/short-math-guide (accessed 2026-11-16).
- The LaTeX Project Team. amsmath: AMS Mathematical Facilities for LaTeX. CTAN Package Catalogue. https://ctan.org/pkg/amsmath (accessed 2026-11-16).
- American Mathematical Society. AMS Author Resource Center: AMS-LaTeX Technology and Guidelines. https://www.ams.org/publications/authors/tex/amslatex (accessed 2026-11-16).
- Overleaf. Aligning Equations with amsmath. Overleaf Documentation. https://www.overleaf.com/learn/latex/Aligning_equations_with_amsmath (accessed 2026-11-16).
Data: amsmath Display Environments: Alignment, Numbering, and Syntax Structure
Comparative specifications of display math environments provided by the LaTeX amsmath package, compiled from the AMS User's Guide (amsldoc) and the Short Math Guide for LaTeX.
| Environment Name | Scope Type | Default Numbering | Unnumbered Star Variant | Alignment Syntax | Primary Scientific Use Case |
|---|---|---|---|---|---|
| equation | Top-level display | Single number centered | Yes (equation*) | No alignment point (single centered line) | Single-line standalone formulas and mathematical definitions |
| align | Top-level display | Numbered per row | Yes (align*) | Single ampersand (&) per row at relation symbol | Multi-step mathematical proofs and derivations with aligned equality signs |
| gather | Top-level display | Numbered per row | Yes (gather*) | No alignment point (each line centered independently) | Consecutive related equations requiring no common horizontal anchor |
| multline | Top-level display | Single number on final line | Yes (multline*) | First line left-aligned, middle centered, last right-aligned | Single formulas exceeding text column width that require multi-line breaking |
| flalign | Top-level display | Numbered per row | Yes (flalign*) | Ampersands expand to fill full margin-to-margin width | Parallel equation pairs stretched across the full width of the text column |
| alignat | Top-level display | Numbered per row | Yes (alignat*) | Requires explicit argument specifying number of alignment pairs | Multi-column equation blocks with precise control over horizontal inter-column gaps |
| split | Subordinate (inner) | Inherits parent equation number | No (controlled by parent) | Single ampersand (&) per row at relation symbol | Breaking long expressions across lines within an equation or gather block |
| aligned | Subordinate (inner) | Inherits parent equation number | No (controlled by parent) | Single ampersand (&) per row at relation symbol | Multi-line aligned blocks nested inside matrices, equations, or cases |
| gathered | Subordinate (inner) | Inherits parent equation number | No (controlled by parent) | No alignment point (each line centered independently) | Centered multi-line blocks nested within larger compound formulas or brackets |
| cases | Subordinate (inner) | Inherits parent equation number | No (controlled by parent) | Two columns separated by single ampersand (&) | Piecewise functions, boundary values, and conditional mathematical definitions |
Sources
- User's Guide for the amsmath Package (amsldoc) (accessed 2026-11-16)
- Short Math Guide for LaTeX (accessed 2026-11-16)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







