Multi-line Equations in LaTeX: align, split, multline, gather

The equation environment holds exactly one line. The moment a derivation needs a second line, or a formula runs past the margin, you need one of the amsmath display environments. This guide shows which one to pick: align for a stack of equations lined up on their equals signs, split for one long equation with one number, multline for a long expression with no alignment point, gather for centred lines, and the aligned and gathered building blocks that nest inside other environments. It also covers numbering, text between lines, brackets that span a break, page breaks, cases, the automatic breqn package, and why eqnarray should be retired.

Every environment below needs \usepackage{amsmath}. Basic math syntax is covered in the mathematical expressions guide; labels, \eqref and numbering styles have their own equation numbering guide.

Which Environment Do I Need?

SituationEnvironmentNumbers
Several equations, aligned on =alignOne per line
One equation too long for a line, aligned continuationsplit inside equationOne for the group
One long equation, no alignment pointmultlineOne, on the last line
Several equations, each centredgatherOne per line
Aligned block inside a larger formula or beside anotheraligned, gatheredFrom the outer environment
Several alignment columns with controlled spacingalignatOne per line
Piecewise definitioncases inside equationOne

The display environments have starred forms (align*, gather*, multline*, alignat*, equation*) that print no numbers at all; split, aligned and gathered have none, because their numbering comes from the environment around them.

align: Equations Aligned on a Symbol

& marks the alignment point on each line, usually just before the relation symbol, and \\ ends a line. Every line gets its own number unless you suppress it:

\begin{align}
  f(x) &= (x + 1)^2 \\
       &= x^2 + 2x + 1 \label{eq:expanded}
\end{align}

\begin{align*}
  f(x) &= (x + 1)^2 \\
       &= x^2 + 2x + 1
\end{align*}

Put & before the =, not after it. The material to the left of & is set flush right and the material to the right flush left, so &= keeps the equals signs in a column with correct spacing. Do not end the last line with \\: it creates an empty extra line that still receives an equation number.

Removing the number from some lines

\notag (or the older \nonumber) before the \\ suppresses the number on that line only. The usual pattern numbers just the final result:

\begin{align}
  a &= b + c \notag \\
    &= d + e \notag \\
    &= f \label{eq:result}
\end{align}

Several equations side by side

Each extra pair of & adds a column. Odd-numbered ampersands align; even-numbered ones separate the columns, and amsmath spreads the columns evenly across the line:

\begin{align}
  x  &= 1,  & y  &= 2,  & z  &= 3 \\
  x' &= 10, & y' &= 20, & z' &= 30
\end{align}

split: One Equation, One Number

When a single equation is too long, split inside equation gives aligned continuation lines and a single number centred vertically on the group. split cannot stand alone; it must be wrapped in equation, align or gather, and the \label belongs to the outer environment:

\begin{equation}
  \begin{split}
    (a + b)^2 &= (a + b)(a + b) \\
              &= a^2 + ab + ba + b^2 \\
              &= a^2 + 2ab + b^2
  \end{split}
  \label{eq:square}
\end{equation}

For an unnumbered version use equation* (or \[ ... \], which amsmath makes equivalent) around the split.

multline: A Long Expression With No Alignment Point

Some expressions are just long: a sum of many terms, a polynomial, a product. There is nothing to align on, so multline sets the first line flush left, the last line flush right and anything in between centred, with one number on the last line. Break before an operator so each continuation line starts with it:

\begin{multline}
  a + b + c + d + e + f + g + h \\
  + i + j + k + l + m + n \\
  = p + q + r + s + t + u \label{eq:long}
\end{multline}

\shoveleft{...} and \shoveright{...} push a middle line to one side, and the length \multlinegap (default 10pt) controls the indentation of the first and last lines from the margins.

gather: Centred Lines

gather stacks equations without aligning them; each line is centred and numbered. It is the right choice for a list of unrelated results or a system of equations of very different shapes:

\begin{gather}
  a_1 = b_1 + c_1 \\
  a_2 = b_2 + c_2 - d_2 + e_2 \label{eq:second}
\end{gather}

There are no & in gather; using one gives Extra alignment tab has been changed to \cr.

aligned and gathered: Blocks Inside Other Math

aligned and gathered produce the same layouts as align and gather but as a box that can be placed inside any math, including beside a brace or next to another block. They take an optional position argument ([t], [b]) and leave numbering to the surrounding environment:

\begin{equation}
  \left.
  \begin{aligned}
    a &= b + c \\
    d &= e
  \end{aligned}
  \right\} \quad \text{(both hold)}
\end{equation}

\[
  \begin{aligned}
    x &= r \cos\theta \\
    y &= r \sin\theta
  \end{aligned}
  \qquad
  \begin{gathered}
    u = 1 \\ v = 2
  \end{gathered}
\]

Nesting a full align inside equation is an error (Erroneous nesting of equation structures); aligned is the environment designed for that position.

alignat: Alignment Columns With Fixed Spacing

align decides the space between columns itself. alignat{n} takes the number of alignment columns and adds no space of its own, so you control the gaps. It is ideal for annotating steps and for lining up a system of linear equations term by term:

\begin{alignat}{2}
  x &= 2y + 1  &\qquad& \text{(by definition)} \\
  y &= 3       &      & \text{(given)}
\end{alignat}

\begin{alignat*}{3}
  10x &+ 3y &{}={}& 2 \\
   3x &- 6y &{}={}& -1
\end{alignat*}

The {}={} idiom keeps the spacing around a symbol that sits in a cell by itself. TeX only puts space beside a relation or operator when something else is next to it in the same cell; an = written as &=& has nothing after it in its cell, so the gap between the = and the next column disappears. The empty groups act as invisible neighbours on both sides. alignat{n} allows at most 2n − 1 ampersands per line; one more gives Extra & on this line.

Text Between Lines: \intertext and \shortintertext

To insert a sentence between the lines of an align without losing the alignment, use \intertext. The alignment columns continue across the text. mathtools' \shortintertext is the same with less vertical space around the text:

\usepackage{mathtools}   % loads amsmath; needed for \shortintertext

\begin{align}
  a &= b + c \\
  \intertext{and, substituting into the second equation,}
  d &= e \\
  \shortintertext{so}
  f &= g
\end{align}

Brackets That Span a Line Break

A \left ... \right pair cannot cross \\; inside align the error is Extra }, or forgotten \right. The cleanest fix is the manual sizes \bigl, \Bigl and so on, which need no partner. The alternative is to close the first line with the invisible delimiter \right. and reopen with \left.; this works but the two halves are sized independently. Sizing is covered in depth in the brackets guide.

\begin{align}
  f(x) &= \Bigl( a + b + c \\
       &\qquad + d + e \Bigr) \\[6pt]
  g(x) &= \left( \frac{a}{b} \right. \\
       &\qquad \left. + c \right)
\end{align}

The \\[6pt] on the second line adds 6pt of extra vertical space before the next line, a convenient way to separate groups of lines inside one environment.

Piecewise Functions: cases

A definition by cases is a multi-line formula with one number. cases draws the brace and aligns the conditions in a second column; dcases from mathtools is the same in display style, so fractions in the cases are full size:

\begin{equation}
  |x| = \begin{cases}
    x  & \text{if } x \ge 0 \\
    -x & \text{if } x < 0
  \end{cases}
\end{equation}

\begin{equation}
  f(n) = \begin{dcases}
    \frac{n}{2}    & n \text{ even} \\
    \frac{3n+1}{2} & n \text{ odd}
  \end{dcases}
\end{equation}

Page Breaks Inside Displays

amsmath never breaks a page inside a display by default, so a long align near the bottom of a page is pushed whole onto the next one, leaving a gap. \allowdisplaybreaks in the preamble lifts the ban for align, gather, alignat and multline. An optional argument from 1 to 4 sets how willing TeX should be. Inside such a display, \\* forbids a break after that line and \displaybreak before a \\ encourages one. split, aligned and gathered are single boxes and never break:

\allowdisplaybreaks        % preamble

\begin{align}
  a &= b \\*                % no page break after this line
  c &= d \\
  e &= f \displaybreak[0] \\  % a break is acceptable here
  g &= h
\end{align}

Labels and Custom Tags per Line

In align and gather, every numbered line can carry its own \label, placed anywhere on the line before the \\. A second \label on the same line gives Multiple \label's: label will be lost, and a \label on a \notag line has no number to refer to. \tag{...} replaces the automatic number on one line; \tag* drops the parentheses:

\begin{align}
  x &= y \tag{A} \label{eq:a} \\
  z &= w \tag*{(star)}
\end{align}

See \eqref{eq:a}.

For numbering by section, \numberwithin, cleveref and subequations, see the equation numbering guide.

Automatic Line Breaking: breqn

The breqn package breaks long equations by itself. Its dmath environment replaces equation and needs no \\ at all:

\usepackage{amsmath}
\usepackage{breqn}       % load after amsmath and other math packages

\begin{dmath}
  f(x) = a_0 + a_1 x + a_2 x^2 + a_3 x^3 + a_4 x^4 + a_5 x^5
       + a_6 x^6 + a_7 x^7 + a_8 x^8 + a_9 x^9 + a_{10} x^{10}
\end{dmath}

It is convenient for drafts and for generated formulas, with caveats. breqn re-implements a large part of math typesetting, so it must be loaded last and it conflicts with some packages; its line breaks are chosen mechanically and rarely match what an author would pick; and most journals do not accept it. For a final document, break lines by hand with the environments above.

Why Not eqnarray

Older tutorials use eqnarray, which predates amsmath. It compiles, but it has three real defects: the space around the middle column is wider than the standard spacing around =, so its equations look different from every other formula in the document; a long line overprints the equation number instead of moving it; and \nonumber and labels behave inconsistently. align is a drop-in replacement with &= instead of &=&:

% old
\begin{eqnarray}
  a & = & b + c \\
  d & = & e
\end{eqnarray}

% replacement
\begin{align}
  a &= b + c \\
  d &= e
\end{align}

Common Errors and Fixes

Message or symptomCauseFix
Misplaced alignment tab character && inside equation or \[ ... \], which have no alignmentUse align, or wrap the lines in split
Extra alignment tab has been changed to \cr& inside gather, or more columns than a table/array declaresRemove the &, or switch to align
Package amsmath Error: Extra & on this lineMore than 2n−1 ampersands in alignat{n}Increase n or remove the extra &
Package amsmath Error: \begin{split} won't work heresplit used outside a display environmentWrap it in equation, align or gather
Package amsmath Error: Erroneous nesting of equation structuresalign or gather inside equationUse aligned, gathered or split inside
LaTeX Error: Environment align undefinedamsmath not loaded\usepackage{amsmath}
Extra }, or forgotten \right / Missing \right. inserted\left and \right on different lines or across an &Use \bigl/\bigr, or \right. and \left.
An empty numbered line at the end of the display\\ after the last lineDelete the trailing \\
Package amsmath Error: Multiple \label's: label will be lostTwo \label commands on one line, or a \label inside split plus one outsideKeep one label per numbered line
Equation number printed on a line by itselfThe line is too wide for the number to fit beside it (amsmath moves it rather than overprint)Break the line earlier, or accept it
Lines refuse to break across pages, leaving a gapamsmath's default no-break rule\allowdisplaybreaks in the preamble
Missing space on one side of a symbol written alone between two &, as in &=&Nothing follows the symbol in its cell, so TeX inserts no space there (amsmath already handles the usual &= case)Write &{}={}&

Complete Example

\documentclass{article}
\usepackage{amsmath, mathtools}
\allowdisplaybreaks

\begin{document}

\section{A derivation}
\begin{align}
  (a + b)^2 &= (a + b)(a + b) \notag \\
            &= a^2 + ab + ba + b^2 \notag \\
            &= a^2 + 2ab + b^2 \label{eq:binomial}
\end{align}

\section{One long equation}
\begin{equation}
  \begin{split}
    I &= \int_0^1 \Bigl( x^3 + 3x^2 \\
      &\qquad + 3x + 1 \Bigr) \, dx = \frac{15}{4}
  \end{split}
  \label{eq:integral}
\end{equation}

\begin{multline}
  (x + y + z)^3 = x^3 + y^3 + z^3 + 3x^2 y + 3x^2 z \\
  + 3y^2 x + 3y^2 z + 3z^2 x + 3z^2 y + 6xyz
\end{multline}

\section{A system and a piecewise function}
\begin{alignat*}{3}
  2x &+ 3y &{}={}& 7 \\
   x &- 4y &{}={}& -2
\end{alignat*}
\begin{equation}
  H(x) = \begin{cases}
    1 & \text{if } x \ge 0 \\
    0 & \text{otherwise}
  \end{cases}
\end{equation}

\section{With commentary}
\begin{align}
  y' &= 2x \\
  \intertext{Integrating both sides gives}
  y  &= x^2 + C.
\end{align}

Equations \eqref{eq:binomial} and \eqref{eq:integral} are referenced here.

\end{document}

Quick Reference

TaskCode
New line in an equation\\ inside align, split, multline or gather
Align on =&= on each line of align
No numbersalign*, gather*, multline*
No number on one line\notag before \\
One number for several lines\begin{equation}\begin{split} ... \end{split}\end{equation}
Long equation, no alignmentmultline; \shoveleft, \shoveright
Centred linesgather
Aligned block inside mathaligned, gathered
Side-by-side columnsalign with extra & pairs, or alignat{n}
Text between lines\intertext{...}, \shortintertext{...} (mathtools)
Bracket across lines\Bigl( ... \\ ... \Bigr)
Extra space between lines\\[6pt]
Allow page breaks\allowdisplaybreaks; \\* to forbid one
Piecewisecases, dcases (mathtools)
Automatic breakingdmath from breqn

Frequently Asked Questions

How do I start a new line inside an equation in LaTeX?

The equation environment is single-line. Use an amsmath environment that allows \\: align or align* for several aligned equations, split inside equation for one equation with one number, or multline for one long equation with no alignment point.

What is the difference between align and split?

align is a complete display that numbers every line (suppress a number with \notag). split is used inside equation, align or gather and treats its lines as one equation with a single number centred on the group. Use align for a sequence of equations and split for one derivation that happens to be long.

How do I break a long equation that has no equals sign to align on?

Use multline. Its first line is set flush left, its last line flush right, and any lines between are centred, with one equation number on the last line. Break before an operator (+, −, =) so the next line starts with it.

Why does align give me “Misplaced alignment tab character &”?

That message means an & was found where no alignment is active, usually in a plain equation or \[ ... \] environment. Switch to align, or wrap the lines in split. Inside gather, which has no alignment points, the same mistake reports “Extra alignment tab has been changed to \cr”.

Should I use eqnarray?

No. eqnarray is a pre-amsmath environment with wrong spacing around the = column, no way to stop long lines from overprinting the equation number, and inconsistent handling of \nonumber. amsmath's align does the same job correctly and every modern document should use it.

How do I allow a page break inside a long align?

amsmath forbids page breaks inside displays by default. Put \allowdisplaybreaks in the preamble to allow them in align, gather, alignat and multline, and use \\* on a specific line to forbid a break after it. aligned, gathered and split are single boxes and never break.

Next Steps

Lines breaking where you want them? These guides cover the rest of display math:

Free LaTeX Tools

Break long equations faster with AI

Octree's AI editor converts a runaway equation into a clean align or split, explains amsmath errors in plain language, and compiles your document in seconds.

Try Octree Free →