Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following simple code which causes some problems, would be great if someone could point out what is going wrong here:

\begin{compactenum}

\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$
  \]                

 \end{compactenum}     

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
add comment

1 Answer 1

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
2  
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
add comment

Your Answer

 
discard

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.