# Why am I getting this “Missing $inserted” error in an algorithm figure just like all my other algorithm figures? I'm writing a paper in LaTeX, and I'm getting a strange "Missing$ inserted" error when I try to compile the paper using pdflatex, but only if it contains the following code.

\begin{algorithm*}[tbh]
translate :: \textsc{Featherweight Java} \Rightarrow \textsc{Feather-Sub terms}\\
translate (class C_1 extends C_2 \{T_i f_i ^ \{i \in 1...n\}\; K M_j ^ \{j \in 1...m\}\}) = \hsbody{\langle C_1 = \{(translate C_2), f_i \: (translate T_i) ^ \{i \in 1...n\}\} \rangle where (translate K) and (translate M_j ^ \{j \in 1...m\}) are emitted as separate translations into the same unit}\\

translate (C(C_i f_i) \{ super(f_i); this.f_i = f_i; \} ^ \{i \in 1...n\}) = \hsbody{\hslet{C = \lambda f_i.\langle C = \{l_i = f_i\} ^ \{i \in 1...n\}}{rest of translation unit}}\\

translate (C' m(C_i x_i ^ \{i \in 1...n\}) \{ return e; \} in class C) = \hslet{ m = \lambda t.case t of \langle C=this \rangle \Rightarrow \lambda x_i.(translate ((C')e)) for each subclass C' of C with overriding method m' \langle C' = this \rangle \Rightarrow m' t x_i}{rest of translation unit}\\

translate x = x

translate t.f \hswhere{t is known to have type C} = case t of \langle C = x \rangle x.f for each subclass C' of C \langle C' = x \rangle x.f\\

translate t_1.m_i ^ \{i \in 1...n\} = m (translate t_1) (translate t_i) ^ \{i \in 1...n \} \\

translate (new C(t_i ^ \{i \in 1...n\})) = C (translate t_i) ^ \{i \in 1...n \} \\

translate ((C)t) = \hslet{t' = (translate t)}{\langle C = \{for each f_i : \tau_i \in (translate C) f_i = t'.f_i\} \rangle}
\caption{Encoding of Featherweight Java into Feather Sub\label{fig:Encoding-of-Featherweight}}
\end{algorithm*}


I already have \usepackage commands in my prelude for the algorithm* and haskell environments, and I use them earlier in the paper. This algorithm is listed in an appendix section, could that change things somehow? What can I do to fix it?

I would really appreciate any help I can get with this, as the submission deadline is this Friday! Everything else about the paper is ready for submission except this, so, once again, would really appreciate any help.

-

## migrated from stackoverflow.comDec 14 '11 at 0:47

This question came from our site for professional and enthusiast programmers.

This usually indicates that you have some mathematical symbol not enclosed in $...$. Such a symbol might be underscore. Try escaping the unserscore like this: \_. – phimuemue Dec 14 '11 at 0:14
Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. – Werner Dec 14 '11 at 0:52
As @phimuemue mentions, TeX interprets the use of _ and ^ as sub-/superscripts in math mode, which is not present. How about publishing an algorithm that did compile in the haskell environment so we can see the difference. Also post what other packages you include, since there may be a conflict. Do so by posting the output in your .log file when adding \listfiles before \documentclass (everything after **File List**). Finally, where can we find this haskell style? – Werner Dec 14 '11 at 0:59
Please complete your code snippet to a proper minimal working example illustrating the problem. Which package provides the haskell environment? – Gonzalo Medina Dec 14 '11 at 1:03

This is a common problem and as the comments suggest, it's because of all the _ characters. It's a pain to escape all of them. The way I handle this is to include the underscore package. That takes care of the _ in the normal mode. This way, you can keep your algo text as it is.