TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following LaTeX code (beginning from line 80):

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


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?

share|improve this question
The cases environment is defined only for math mode AFAIK, as part of the amsmath bundle. – Count Zero Sep 8 '12 at 20:30
up vote 6 down vote accepted

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

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

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.

\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 }
share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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