# Problem with mbox command

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

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

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