3

I am new to TeX and I am trying to write the following

\begin{equation}
N_{a,0}\begin{cases}
R_{0,0} & a=0\\
N_{a-1,0}e^{-m} & 1\leq a\leq a_{max}-1\\
N_{a-1,0}e^{-m}/1-e^{-m} & a=a_{max}
\end{cases}
\end{equation}

but I get an error because & is not being recognized as a command, it does not even have the green color as the rest of the commands do. Any ideas on how to fix it?

4
  • Please tell us which error it is. And indent your code by 4 spaces so we can see the syntax highlighting.
    – Turion
    Dec 18, 2015 at 17:10
  • 3
    Welcome to TeX.SX! Do you have \usepackage{amsmath} in your document?
    – egreg
    Dec 18, 2015 at 17:11
  • I did't... I've added it and now it works!!! Thanks!!!
    – Biologist
    Dec 18, 2015 at 17:13
  • @egreg would you add this as an answer? :)
    – Rico
    Dec 18, 2015 at 17:26

1 Answer 1

3

Whether & is recognized as a command as far as syntax coloring is concerned depends on the editor you're using.

In any case, in order to use the cases environment you need to load amsmath.

Minimal example:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
N_{a,0}=
\begin{cases}
  R_{0,0} & a=0\\
  N_{a-1,0}e^{-m} & 1\leq a\leq a_{\max}-1\\
  N_{a-1,0}e^{-m}/1-e^{-m} & a=a_{\max}
\end{cases}
\end{equation}

\end{document}

Note \max to get the letters upright.

enter image description here

Here's what I get in the editor I use most commonly (Aquamacs)

enter image description here

This is how TeXStudio colorizes the same input:

enter image description here

0

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.