Break a long equation over several lines in LaTeX (multline, split)
LaTeX does not break a display formula by itself; you choose the break points. amsmath has multline for a break without alignment, split for a break with alignment and gather for several centred equations.
Preamble
The snippets on this page need these lines before \begin{document}:
\usepackage{amsmath}Break without alignment
In multline, \\ ends a line. The first line is set flush left, the last line flush right and every line between them centred. The formula gets one number; multline* has none.
\begin{multline}
p(x) = 3x^6 + 14x^5y + 590x^4y^2 + 19x^3y^3 \\
- 12x^2y^4 - 12xy^5 + 2y^6 - a^3b^3
\end{multline}Break with alignment
split stands inside equation. An & in each line marks the alignment point, and the block gets one number that is centred vertically.
\begin{equation}
\begin{split}
(a + b)^3 &= (a + b)(a + b)^2 \\
&= (a + b)(a^2 + 2ab + b^2) \\
&= a^3 + 3a^2b + 3ab^2 + b^3
\end{split}
\end{equation}Change the formula
The preview is drawn in your browser by KaTeX, which knows the common math commands. The editor compiles the formula with pdfTeX.
Continue a right-hand side on the next line
Break in front of a + or - and indent the continuation with \quad after the &. The second line then starts to the right of the equals sign.
\begin{align*}
f(x) &= a_0 + a_1 x + a_2 x^2 + a_3 x^3 \\
&\quad + a_4 x^4 + a_5 x^5
\end{align*}Change the formula
The preview is drawn in your browser by KaTeX, which knows the common math commands. The editor compiles the formula with pdfTeX.
Several centred equations
gather centres each line on its own and numbers each line. gather* leaves out the numbers.
\begin{gather}
a + b = c \\
x = y + z + w
\end{gather}Change the formula
The preview is drawn in your browser by KaTeX, which knows the common math commands. The editor compiles the formula with pdfTeX.
Allow page breaks inside a long derivation
LaTeX keeps all lines of align, gather or multline on one page. \allowdisplaybreaks in the preamble permits a page break between two lines; \\* forbids it after a single line. split and aligned are never broken.
This goes into the preamble.
\allowdisplaybreaksPitfalls
\\in a plainequationenvironment does nothing: both parts stay on one line and LaTeX reports no error.\left(and\right)cannot span a line break. See the notes in Large brackets in LaTeX.
Compiled with pdfLaTeX from TeX Live 2023.
Related pages
- Package
amsmath - How-to Align equations in LaTeX
- How-to Number equations in LaTeX
- How-to Large brackets in LaTeX
- Error Erroneous nesting of equation structures