# Cases error is added I have read all the posts on this error that I can find. None of the solutions end up with the correct layout that this code does (left aligned, a=1 in rear). My issue is that it throws a added error.

\documentclass[12pt]{exam}

\usepackage{amsmath}

\begin{document}

$f(x)=$
\begin{cases}
x+2,&  \text{if}\ x\geq 1 \\
x-2,&  \text{if}\ x<1
\end{cases}, \ \ $a=1$

\end{document}


The cases environment should be in math mode. (It doesn't start math mode itself.)

\documentclass[12pt]{exam}

\usepackage{amsmath}

\begin{document}

$$f(x)= \begin{cases} x+2,& \text{if } x\geq 1 \\ x-2,& \text{if } x<1 \end{cases}, \quad a=1$$

\end{document}


Switch $$ and $$ to $ and $ if you want display math.

• Thanks Frabjous, this is perfect. Jun 18 at 23:54