System of equations in LaTeX
Updated:
A system of equations with a brace on the left is written with the cases environment from amsmath. The same environment is used for piecewise functions; put the condition text inside \text.
Two equations
\begin{cases} x + y = 5 \\ 2x - y = 1 \end{cases}cases draws the brace and left-aligns each row; \\ ends a row. In a full document it needs \usepackage{amsmath}.
Copying this from handwritten notes? Snap a photo of the page and CamteX turns the formulas into LaTeX. Try it free
Equals signs lined up
\left\{ \begin{aligned} 2x + y - z &= 1 \\ x - y + 2z &= 3 \\ x + y + z &= 6 \end{aligned} \right.When the equals signs must form a column, put aligned inside \left\{ and \right. instead of using cases. \right. closes the pair with an invisible bracket.
Matrix form
\begin{pmatrix} 1 & 1 \\ 2 & -1 \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} 5 \\ 1 \end{pmatrix}The same system written as matrices, ready for Cramer's rule or Gaussian elimination. Each pmatrix is its own block, placed side by side.
Piecewise function
|x| = \begin{cases} x & \text{if } x \ge 0 \\ -x & \text{if } x < 0 \end{cases}The & separates each value from its condition, so all the conditions line up in a second column. \ge and \le give the greater-or-equal and less-or-equal signs.
Numbered system
\begin{equation}
\begin{cases} x + y = 5 \\ 2x - y = 1 \end{cases}
\label{eq:system}
\end{equation}Wrapping cases in equation gives the whole system one number, so the text can refer to it with \eqref{eq:system}.
Common mistakes
- Gluing a brace together from \{ and array: the brace does not grow with the number of equations.
- The word "if" without \text: it is set in italics as two variables.
- A missing \\ between rows: the equations run together on a single line.
See also
Don't want to memorize commands?
Draw a formula or paste a screenshot, and CamteX turns it into ready LaTeX.