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 simple code which causes some problems, would be great if someone could point out what is going wrong here:


\item Perform addition over all bits
  $\mbox{for~} j \in \{0 \ldots 7\} $ \\
  $r_j = 8 \cdot a_j + 4 \cdot b_j + 2 \cdot x_j + 1 \cdot y_j$


LaTeX outputs the following error message:

! Missing $ inserted.
<inserted text> 
l.822       $\mbox{for~} j \in
                           \{0 \ldots 7\} $ \\
share|improve this question
Welcome to TeX.sx! Please always add a full minimal working example (MWE) that illustrates your problem, i.e. with a minimal preamble required to compile the example. – Martin Scharrer Jul 19 '11 at 14:48

Inside \[ ... \] you cannot use the math mode again. If you want two lines then use align* from amsmath or the same without \[...\] :

  $\mbox{for~} j \in \{0 \ldots 7\} $ \\
  $r_j = 8 \cdot a_j + 4 \cdot b_j + 2 \cdot x_j + 1 \cdot y_j$
share|improve this answer
also, rather than \mbox you might consider using \text{for~} if you are using amsmath. this will match the style of the text surrounding the display and also apply the appropriate size if the embedded text occurs in a sub- or superscript. – barbara beeton Jul 19 '11 at 17:14

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.