LaTeX New Line in Equation: align, split and cases
November 11, 2026 · 12 min read
LaTeX New Line in Equation: align, split, gather and cases
To get a LaTeX new line in equation blocks, you need an environment that has rows. Typing \\ inside a plain equation won't do it. Use align to line up equal signs, split or multline for one long formula, gather for centered rows, and cases for piecewise functions. All of them come from the amsmath package.
Looking for a line break in ordinary paragraph text instead? That's a different problem, covered in our guide to Markdown line breaks. This page is only about \\ inside math. For breaks in LaTeX body text, see our guide to LaTeX new line commands.
What Does \\ Do Inside a LaTeX Equation?
In LaTeX, \\ ends a row. It only does that inside an environment built from rows, such as align, gather, cases or array. The equation environment holds exactly one row, so there's nothing for \\ to end.
Here's the snippet almost everyone tries first:
\begin{equation}
a = b + c \\
d = e + f
\end{equation}
In a LaTeX document, you get one line. The two equations sit side by side, and the \\ doesn't start a second row. KaTeX's own strict-mode warning says it plainly: in LaTeX, \\ "does nothing in display mode".
The fix is to swap the wrapper for an environment that understands rows. Load amsmath in the preamble, too.
\usepackage{amsmath}
\begin{gather}
a = b + c \\
d = e + f
\end{gather}
Now each equation gets its own centered line and its own number. One more rule from the amsmath user guide: don't put \\ after the last row, because it adds unwanted space below the display.
Why you should stop using eqnarray
Older university handouts still teach eqnarray. The amsmath guide says it's better to use align or equation plus split, because the spacing around = in eqnarray is inconsistent and long lines can overprint the equation number. The conversion is mechanical: change a &=& b to a &= b and rename the environment.
How Do You Line Up Equal Signs in LaTeX?
Use align. Put & immediately before the symbol you want lined up (usually =) and end every row except the last with \\. The & goes before the relation, not after it, or the spacing breaks.
\begin{align}
(a+b)^2 &= (a+b)(a+b) \\
&= a^2 + ab + ba + b^2 \\
&= a^2 + 2ab + b^2
\end{align}
That renders three rows with the equal signs stacked in one column. Each row gets its own number on the right.
Three variants round out the align family:
align*is the same layout with no numbers.alignedis a building block for use inside another display, such asequationor a$$block in Markdown. It has no numbers of its own.alignatlets you set how many alignment columns you need, which helps with systems of equations (more on that below).
To drop the number from one row, end that row with \nonumber or \notag. To replace it with your own label, use \tag{...}.
Left-aligning equations: fleqn and the ampersand trick
To left-align every display in a document, add the fleqn class option: \documentclass[fleqn]{article}. The amsmath guide describes it as placing equations at a fixed indent from the left margin instead of centering them. To left-align or right-align ordinary text instead, see our LaTeX text alignment guide.
For one block only, start every row of align* with &. The rows then line up on their left edge, while the block itself stays centered.
\begin{align*}
&x + y = 10 \\
&2x - 3y + z = 4
\end{align*}
LaTeX Split Equation: split vs multline
When a LaTeX multiline equation is really one long formula, use split or multline. They look quite different on the page.
split goes inside equation. You mark an alignment point with & on each line. The whole block gets one equation number, vertically centered by default.
\begin{equation}
\begin{split}
f(x) &= (x+1)^3 - (x-1)^3 \\
&= 6x^2 + 2
\end{split}
\end{equation}
That renders as two lines with the = signs aligned and a single number. Per the amsmath guide, split supports only one & column, so use aligned if you need more.
multline doesn't align anything. Its first line sits at the left margin and its last line at the right margin. Any middle lines are centered.
\begin{multline}
a + b + c + d + e + f + g \\
+ h + i + j + k + l \\
+ m + n + o + p
\end{multline}
Start each continuation line with the operator (+, -, =), so the reader knows the formula carries on.
If a bracket opens on one line and closes on another, \left( and \right) can't span the \\. Close the first line with \right. and open the next with \left., which are invisible delimiters:
\begin{equation}
\begin{split}
f(x) &= \left( a + b + c \right. \\
&\qquad \left. + d + e \right)
\end{split}
\end{equation}
The two halves can end up with different bracket heights. Manual sizes such as \bigl( and \bigr) fix that.
Stacking Equations Without Alignment Using gather
gather is the right choice when you have several separate equations and nothing needs to line up. Each row is centered on its own line and numbered.
\begin{gather}
E = mc^2 \\
F = ma \\
p = mv
\end{gather}
That renders as three centered equations, numbered (1) to (3). gather* drops the numbers. gathered is the building-block form for use inside another display, just like aligned. For more worked examples of align, split, multline and gather, see Overleaf's page on aligning equations with amsmath.
Writing a System of Equations in LaTeX
A system of equations in LaTeX is usually a set of aligned rows with a single brace on the left. Wrap aligned in \left\{ and close it with the invisible \right.:
\left\{
\begin{aligned}
2x + 3y &= 5 \\
x - y &= 0
\end{aligned}
\right.
That renders one tall curly brace on the left, with both equal signs lined up in a single column.
A quicker version is \begin{cases} 2x + 3y = 5 \\ x - y = 0 \end{cases}. It adds the brace for you and left-aligns each row.
When you want the variables themselves in columns, use alignat. The {2} asks for two pairs of columns, each pair right-aligned then left-aligned. The empty braces around + keep its spacing as a binary operator.
\begin{alignat*}{2}
2x &{}+{}& 3y &= 5 \\
x &{}-{}& y &= 0
\end{alignat*}
The x terms, the y terms and the equal signs each line up vertically.
You'll also see the older array approach, \begin{array}{rcl} with &=& in the middle. It works, but the spacing around = comes from column padding, not from TeX's relation spacing, so it looks looser than align. For bracketed grids of numbers, see our Markdown matrix guide instead.
Piecewise Functions with the cases Environment
In a LaTeX equation, cases is the standard way to write a piecewise function. Each row has a value, then &, then the condition. Wrap words in \text so they're set upright with normal spaces.
f(x) =
\begin{cases}
x^2 & \text{if } x \ge 0 \\
-x & \text{otherwise}
\end{cases}
That renders a brace after f(x) =, with the values in one column and the conditions in a second, left-aligned column. The space inside \text{if } matters, since math mode ignores spaces you type. You can add a gap before the condition with \quad if the columns feel cramped.
cases sets its rows in text style, so fractions come out small. The dcases environment from the mathtools package sets them in display style. Load \usepackage{mathtools} in LaTeX to use it.
Every LaTeX New Line in Equation Option, Side by Side
Pick the row that matches what you're building. The KaTeX columns tell you whether it'll render in KaTeX-based Markdown math, which is what our editor uses. MathJax-based sites accept more of these environments.
| Environment | Use it for | Numbering | Aligns on & | KaTeX in $$ | KaTeX in $ |
|---|---|---|---|---|---|
align / align* | Steps of a derivation | Per row / none | Yes | Yes | No |
aligned | Aligned rows inside another display | None | Yes | Yes | Yes |
alignat | Systems with column-aligned terms | Per row | Yes, several columns | Yes | No |
split (in equation) | One long equation, aligned | One for the block | Yes, one column | Yes | No |
multline | One long equation, no alignment | One for the block | No | No | No |
gather / gather* | Unrelated equations, centered | Per row / none | No | Yes | No |
gathered | Centered rows inside another display | None | No | Yes | Yes |
cases | Piecewise functions | None | Value and condition | Yes | Yes |
array | Custom column layouts | None | Yes | Yes | Yes |
eqnarray | Old documents only | Per row | Yes | No | No |
We prefer aligned inside $$ for anything that has to work both in a paper and on the web. It renders the same in a LaTeX document and in KaTeX, and the only thing you give up is automatic numbering.
Which Environments Work in Markdown Math (KaTeX)?
Most web Markdown renders math with KaTeX or MathJax, and KaTeX supports fewer environments. We tested every environment above in KaTeX 0.16, the version our editor ships. Here's what matters:
align,gather,alignat,splitandequationwork only in display math. In inline$...$, KaTeX reports that they can be used only in display mode.aligned,gatheredandcaseswork in both inline and display math.multlineandeqnarrayaren't supported at all. KaTeX reports "No such environment". Neither isflalign.- A bare
\\inside$$does break the line in KaTeX, unlike real LaTeX. It doesn't align anything, though, so usealignedinstead.
That last point catches people out: a snippet that looks fine in a browser can collapse to one line when you paste it into a LaTeX document. The full list lives on the KaTeX supported functions page.
The reverse happens on GitHub, where the Markdown parser can eat a backslash before the math renderer sees it. The row separator section of our matrix guide shows the fenced fix. For the basics of $ versus $$ and how KaTeX compares with MathJax, read our Markdown equation guide.
Our editor renders math with KaTeX, using inline $...$ and display $$...$$. It doesn't support the \(...\) and \[...\] delimiters. An unsupported environment shows an error in the preview instead of breaking the page. Edit the demo below and watch the preview update:
The limitation to keep in mind is numbering. KaTeX does number align and gather rows, but its support table lists \label and \eqref as not supported, so you can't cross-reference rows the way you can in a LaTeX document. If you need a single formula as an image, the LaTeX equation editor renders it with KaTeX in your browser and exports PNG or SVG.
Once you know which environment owns the rows, adding a LaTeX new line in equation blocks stops being guesswork. Use align to line up signs, split or multline for one long formula, gather for centered rows and cases for piecewise definitions. On the web, stick to the KaTeX-safe set. Paste any environment from this page into the editor inside $$ and the preview shows you right away whether it renders.