Getting “! Missing $inserted” error I try to write a math formula but i get many errors and a bad display. Here's the code : \documentclass[a4paper]{article} \usepackage{amsmath} \begin{document} Suite de Syracuse :$\forall U_0\ge 1, u_{n+1} =$\left\{ \begin{array}{lcr}$\dfrac{u_n}{2}$si$u_n$est pair\\$3u_n + 1$si$u_n$est impair \end{array} Suite compressée :$\forall U_0\ge 1, u_{n+1} =$\left\{ \begin{array}{lcr}$\dfrac{u_n}{2}$si$u_n$est pair\\$\dfrac{3u_n + 1}{2}$si$u_n$est impair \end{array} Suite à termes négatifs :$\forall U_0\le -1, u_{n+1} =$\left\{ \begin{array}{lcr}$\dfrac{u_n}{2}$si$u_n$est pair\\$3u_n - 1$si$u_n$est impair \end{array} \end{document}  So i get 29 errors and this display : . Thanks for helping and sorry for my bad english :) 3 Answers First, let me explain what was wrong with the original code. The cells of an array environment are already in math mode, so the first $ typed inside one leaves math mode. In an array, one needs special commands like \text{} or \mbox{} to enclose the non-math portions, but nothing special for the math.

However, given amsmath is being used, the cases environment is better for this task, but the same rules apply. Oddly enough, TeX actually recovers from these errors and produces the correct result (or rather, it produces what it would have had this been entered correctly).

The badness of the display comes from the lines running together and lack of alignment. This can be corrected with some extra space added, or one can typeset the whole thing as a display:

\documentclass[a4paper]{article}
\usepackage{amsmath}
\begin{document}

\begin{align*}
&\text{Suite de Syracuse :} & \forall u_0\ge 1, u_{n+1}
&=
\begin{cases}
\dfrac{u_n}{2} &\text{si $u_n$ est pair,}  \\
3u_n + 1       &\text{si $u_n$ est impair.}
\end{cases}
\\
&\text{Suite compressée :} & \forall u_0\ge 1, u_{n+1}
&=
\begin{cases}
\dfrac{u_n}{2}      &\text{si $u_n$ est pair,}  \\[6.5pt]
\dfrac{3u_n + 1}{2} &\text{si $u_n$ est impair.}
\end{cases}
\\
&\text{Suite à termes négatifs :} & \forall u_0\le -1, u_{n+1}
&=
\begin{cases}
\dfrac{u_n}{2} &\text{si $u_n$ est pair,}  \\
3u_n - 1       &\text{si $u_n$ est impair.}
\end{cases}
\end{align*}

\end{document}


My apologies for losing the accented characters:

• Could be an idea to align the explanatory text to the right as well? – Holene Nov 24 '13 at 19:05
• @Holene It would be difficult (not impossible) to ensure alignment of all six explanatory texts, since each of the three cases environments considers only alignment within itself. However, it seams adding a space in front of the "si"s in the first and third cases seems to give pretty good results for this example. – Dan Nov 25 '13 at 4:40

As noted in the other answers, you should stay in math mode within your equations, nesting text mode inside where text is needed (si $u_n$ est pair/impair). You seem to have some issues with accents, too. This question on How to type special/accented letters in LaTeX? might be useful.

Only one part, to show the idea. Original lines commented, then changed.

\documentclass[a4paper]{article}
\usepackage{amsmath}

\begin{document}
Suite de Syracuse :
%$\forall U_0\ge 1, u_{n+1} =$\left\{
$\forall U_0\ge 1, u_{n+1} =\left\{ \begin{array}{lcr} %$\dfrac{u_n}{2}$si$u_n$est pair\\ \dfrac{u_n}{2} \mbox{ si$u_n$est pair}\\[6pt] 3u_n + 1\mbox{ si$u_n$est impair} \end{array} \right.$

\end{document}


• since amsmath is being used, \text would be better than \mbox. – barbara beeton Nov 23 '13 at 15:13