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.

{2x+3y=7x−y=1\left\{ \begin{aligned} 2x + 3y &= 7 \\ x - y &= 1 \end{aligned} \right.

Open this formula in the editor

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.

{2x+3y=7x−y=1\begin{cases} 2x + 3y = 7 \\ x - y = 1 \end{cases}

Open this formula in the editor

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.

{2x+3y=7x−y=1\left\{ \begin{alignedat}{2} 2x &{}+{}& 3y &= 7 \\ x &{}-{}& y &= 1 \end{alignedat} \right.

Open this formula in the editor

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

Open in the editor

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.

(231−1)(xy)=(71)\begin{pmatrix} 2 & 3 \\ 1 & -1 \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} 7 \\ 1 \end{pmatrix}

Open this formula in the editor

Pitfalls

Compiled with pdfLaTeX from TeX Live 2023.

Related pages