Systems of equations in LaTeX
A system of equations is written in LaTeX with one brace and one equation per line. \begin{cases} ... \end{cases} is the quickest; alignedat or the systeme package lines the variables up in columns, and empheq numbers each line.
LaTeX command
\begin{cases} x + y = 2 \\ x - y = 0 \end{cases}Not the symbol you meant? Draw it to find the command →
Typing up handwritten notes? Convert a whole page of handwriting to LaTeX →
The cases environment from amsmath is the quickest way: it draws one large left brace and stacks the equations, with \\ ending each line. The brace grows to fit, so three or four equations need nothing extra.
cases sets each line flush left, so when the coefficients differ in width the x, y and z drift out of line. That is fine for two short equations; for a larger system, or one you will solve by elimination, line the variables up in columns (below).
Without amsmath, \begin{cases} gives no error but draws a small brace around the first letter only and breaks the lines apart, so load amsmath first (\usepackage{amsmath}). cases, aligned, alignedat and rcases also work in KaTeX; systeme and empheq are LaTeX packages that KaTeX does not have.
A system with a brace: cases
Write one equation per line inside cases and end each line with \\. Here is a system of three equations in three unknowns. The same brace with a condition after & on each line makes a piecewise function.
\begin{cases} 2x + 3y - z = 5 \\ x - y + 2z = 1 \\ 3x + 2y + z = 4 \end{cases}More on this: Piecewise functions in LaTeX
Equals signs lined up: aligned inside a brace
cases cannot line up the equals signs. For that, put an aligned environment between \left\{ and \right., with & just before each =. \right. closes the pair without drawing a second brace.
\left\{ \begin{aligned} 2x + 3y &= 7 \\ x - 4y &= -2 \end{aligned} \right.More on this: Aligning equations in LaTeX
Variables in columns: alignedat
To give every x, y and z its own column, use alignedat from amsmath. The {3} is the number of unknowns. On each line every sign sits between two &, written {}+{} or {}-{} so it keeps the spacing of a plus or minus, and a last & comes before the =.
\left\{ \begin{alignedat}{3} 2x &{}+{}& 3y &{}-{}& z &= 5 \\ x &{}-{}& y &{}+{}& 2z &= 1 \\ 3x &{}+{}& 2y &{}+{}& z &= 4 \end{alignedat} \right.The systeme package: columns done for you
The systeme package does the lining up itself. Load it with \usepackage{systeme}, then list the equations separated by commas: it adds the brace, puts each unknown in its own column and leaves a gap where an unknown is missing.
\systeme works in LaTeX and Overleaf; KaTeX does not have it, so on a web page use alignedat. The result looks like the system above.
\usepackage{systeme}\systeme{2x+3y-z=5, x-y+2z=1, 3x+2y+z=4}\systeme{x+z=3, y-z=1}Numbering the equations: equation, subequations and empheq
For one number for the whole system, put cases inside an equation environment.
To number every line, (1a) and (1b), and keep the brace, wrap an align in subequations and draw the brace with the empheq package. Each line can then take its own \label for \eqref.
\begin{equation} \begin{cases} x + y = 3 \\ x - y = 1 \end{cases} \end{equation}\usepackage{empheq}\begin{subequations} \begin{empheq}[left=\empheqlbrace]{align} x + y &= 3 \\ x - y &= 1 \end{empheq} \end{subequations}A brace on the right
For a brace after the equations, for example to label the system, use rcases from the mathtools package, or end an aligned with \right\} after an empty \left. at the start.
\usepackage{mathtools}\begin{rcases} x + y = 3 \\ x - y = 1 \end{rcases}\left. \begin{aligned} x + y &= 3 \\ x - y &= 1 \end{aligned} \right\}As a matrix: the augmented matrix
To solve the system by row reduction, write its coefficients as an augmented matrix, with a bar before the column of constants.
\left[\begin{array}{ccc|c} 2 & 3 & -1 & 5 \\ 1 & -1 & 2 & 1 \\ 3 & 2 & 1 & 4 \end{array}\right]More on this: Augmented matrices in LaTeX, Matrices in LaTeX
Other forms
\begin{aligned}...\end{aligned}align on the = signsExamples
$\begin{cases} x + y = 2 \\ x - y = 0 \end{cases}$two equations under one brace
$\begin{cases} 2x + 3y - z = 5 \\ x - y + 2z = 1 \\ 3x + 2y + z = 4 \end{cases}$three equations in three unknowns
$$\left\{ \begin{alignedat}{3} 2x &{}+{}& 3y &{}-{}& z &= 5 \\ x &{}-{}& y &{}+{}& 2z &= 1 \\ 3x &{}+{}& 2y &{}+{}& z &= 4 \end{alignedat} \right.$$the same system with the variables in columns
$$\begin{aligned} 2x + y &= 5 \\ x - y &= 1 \end{aligned}$$lined up on the equals signs, no brace
$\begin{cases} x^2 + y^2 = 25 \\ y = x + 1 \end{cases}$a system with a circle and a line
Tips and common mistakes
- cases, aligned and alignedat need amsmath: without it, cases gives no error but a broken brace.
- cases sets each line flush left; to line up the = signs, put aligned between
\left\{and\right.instead. - In alignedat, write the signs as {}+{} and {}-{} so they keep the spacing of a plus or minus.
- Every
\leftneeds a partner, and a dot draws nothing:\left....\right\}gives a brace on the right only. - systeme and empheq work in LaTeX and Overleaf but not in KaTeX; on web pages use cases, aligned or alignedat.
Working from handwritten notes?
LatexNotes turns a photo or PDF of handwritten mathematics into LaTeX, graphs and all. It is built with real pdflatex before you see it, and the .tex file is yours to edit or take to Overleaf. Free to try, no sign-up.
See how handwriting to LaTeX works, step by step, or go from GoodNotes to LaTeX if you write on an iPad (Notability works the same way).
Convert your maths to LaTeX →FAQ
How do I write a system of equations with a big brace?
Use cases: \begin{cases} x + y = 2 \\ x - y = 0 \end{cases}. It draws the left brace and stacks the lines. It needs amsmath.
How do I line up the variables in columns?
Use alignedat inside \left\{ ... \right., with each sign between two & signs, or load the systeme package and write \systeme{x+y=3, x-y=1}.
How do I number each equation in a system?
Wrap an align in subequations and add the brace with the empheq package; the lines are numbered (1a), (1b). For a single number, put cases inside an equation environment.
How do I put the brace on the right?
Use rcases from mathtools, or \left. \begin{aligned} ... \end{aligned} \right\}.
How do I line up several equations on the equals sign?
Use the aligned environment inside a display, placing & just before each =: .