LatexNotes

Systems of equations in LaTeX

A system of equations is a set of equations solved together; in LaTeX the cases environment braces them into a single block, with & marking the alignment point.

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, draws a single large left brace and stacks its rows. Inside, \\ ends each line and & marks where the lines align, so \begin{cases} x + y = 2 \\ x - y = 0 \end{cases} sets two equations under one brace. It is the standard tool for both a system and a piecewise definition.

For a piecewise function the & separates the value from the condition, as in x for x >= 0 and -x otherwise. Because the condition is prose, wrap words in \text: write & \text{if } x > 0 so the words are upright and correctly spaced. The cases environment supplies only a left brace.

When you want the equations lined up on their equals signs without a brace, use the aligned environment: put an & just before each = and \\ between rows. aligned is meant to sit inside a display, so wrap it in . Both cases and aligned come from amsmath and are supported by KaTeX.

Other forms

\begin{aligned}...\end{aligned}align on the = signs

Examples

$\begin{cases} x + y = 2 \\ x - y = 0 \end{cases}$

a two-equation system under one brace

$|x| = \begin{cases} x & x \geq 0 \\ -x & x < 0 \end{cases}$

a piecewise definition of absolute value

$f(n) = \begin{cases} 1 & \text{if } n = 0 \\ n \cdot f(n-1) & \text{if } n > 0 \end{cases}$

a piecewise definition using \text for conditions

$$\begin{aligned} 2x + y &= 5 \\ x - y &= 1 \end{aligned}$$

equations aligned on the equals sign, no brace

Tips and common mistakes

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 the cases environment: \begin{cases} x + y = 2 \\ x - y = 0 \end{cases}. It draws the left brace automatically and stacks the rows. It needs amsmath.

How do I write a piecewise function?

Use cases with & before each condition: \begin{cases} x & \\ -x & x < 0 \end{cases}. Wrap any words in the condition in \text{...}.

How do I line up several equations on the equals sign?

Use the aligned environment inside a display, placing & just before each =: .

See also