# Missing $error in math mode I have the following LaTeX code (beginning from line 80): \begin{definition}$\hat{n}_{v}$= \begin{cases}$n_{v}$& \text{ if }$v \in$\text{connected component of size}$< \frac{2}{\epsilon}$\\$\frac{2}{\epsilon}$& \text{ otherwise } \end{cases} \end{definition}  However, when I want to compile this code, I get the following error: ./lect42.tex:80: Missing$ inserted.
<inserted text>
$l.80$\hat{n}_{v}$= \begin{cases}  I looked at the code carefully, but there are no missing$'s. Why I get this error?

-
The cases environment is defined only for math mode AFAIK, as part of the amsmath bundle. –  Count Zero Sep 8 '12 at 20:30

You have lots of unnecessary dollar symbols, and one missing from the end.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\hat{n}_{v} = \begin{cases} n_{v} & \text{ if } v \in \text{connected component of size} < \frac{2}{\epsilon} \\ \frac{2}{\epsilon} & \text{ otherwise } \end{cases}$
\end{document}


As this is quite a large expression, I would be inclined to use $ and $ instead of the dollar signs, to create a displayed equation, rather than an in-text equation. You could also use \displaystyle to enlarge the fractions.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\hat{n}_{v} = \begin{cases} n_{v} & \text{ if } v \in \text{connected component of size} < \displaystyle\frac{2}{\epsilon} \\ \displaystyle\frac{2}{\epsilon} & \text{ otherwise } \end{cases}$
\end{document}

-
thanks, that worked like a charm! i thought i was being cautious by putting those \$'s everywhere.. –  user39084 Sep 8 '12 at 20:44
I'd use dfrac instead of \displaystyle\frac –  cmhughes Sep 8 '12 at 21:16
@cmhughes In that case it doesn't matter much, because the fractions are the last thing in the cell; but yes, in general \dfrac would be better. –  egreg Sep 17 '12 at 12:50