Systems of equations in LaTeX (brace, aligned, cases)
A system of equations with a brace on the left is an aligned block between \left\{ and \right., or a cases environment. Without a brace, align lines the equations up and numbers them. All of these come from amsmath.
Preamble
The snippets on this page need these lines before \begin{document}:
\usepackage{amsmath}Brace on the left, aligned at the equals sign
aligned aligns the lines at the &. \left\{ draws a brace as tall as the block, and \right. closes it without printing anything.
\[
\left\{
\begin{aligned}
2x + 3y &= 7 \\
x - y &= 1
\end{aligned}
\right.
\]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.
The short way with cases
cases draws the brace itself. The lines are left-aligned, not aligned at the equals sign.
\[
\begin{cases}
2x + 3y = 7 \\
x - y = 1
\end{cases}
\]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.
Line up the variables in columns
alignedat{2} has two pairs of columns, each pair right-aligned then left-aligned, and adds no space between them. Here the x terms are right-aligned, the operators stand in a column of their own, the y terms are right-aligned and the last column starts at the =. The empty groups in {}+{} keep the normal space around the operator.
\[
\left\{
\begin{alignedat}{2}
2x &{}+{}& 3y &= 7 \\
x &{}-{}& y &= 1
\end{alignedat}
\right.
\]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.
Numbered equations without a brace
align gives every equation a number, and each one can carry a \label for a later \eqref.
\begin{align}
2x + 3y &= 7 \label{eq:first} \\
x - y &= 1 \label{eq:second}
\end{align}Matrix form
The same system as a product of a coefficient matrix and a column vector, written with pmatrix.
\[
\begin{pmatrix} 2 & 3 \\ 1 & -1 \end{pmatrix}
\begin{pmatrix} x \\ y \end{pmatrix}
=
\begin{pmatrix} 7 \\ 1 \end{pmatrix}
\]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.
Pitfalls
- The
systemepackage aligns variables and signs automatically from a short input:\systeme{2x+3y=7, x-y=1}. - A brace on the left together with one number per line needs the
empheqpackage:\begin{empheq}[left=\empheqlbrace]{align}.
Compiled with pdfLaTeX from TeX Live 2023.
Related pages
- Package
amsmath - How-to Piecewise functions in LaTeX
- How-to Align equations in LaTeX
- How-to Matrices in LaTeX
- How-to Number equations in LaTeX