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}
Result
The compiled example

Open in the editor

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.

(a+b)3=(a+b)(a+b)2=(a+b)(a2+2ab+b2)=a3+3a2b+3ab2+b3\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}

Open this formula in the editor

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.

f(x)=a0+a1x+a2x2+a3x3+a4x4+a5x5\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*}

Open this formula in the editor

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.

a+b=cx=y+z+w\begin{gather} a + b = c \\ x = y + z + w \end{gather}

Open this formula in the editor

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.

\allowdisplaybreaks

Open in the editor

Pitfalls

Compiled with pdfLaTeX from TeX Live 2023.

Related pages