0

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}

1 Answer 1

0

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.