Missing $ inserted
我正在用 LaTeX 写一篇论文,当我尝试使用 编译该论文时,出现了一个奇怪的“ ”错误pdflatex
,但前提是它包含以下代码。
\begin{algorithm*}[tbh]
\begin{haskell}
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}
\end{haskell}
\caption{Encoding of Featherweight Java into Feather Sub\label{fig:Encoding-of-Featherweight}}
\end{algorithm*}
\usepackage
我的序言中已经有了用于algorithm*
和haskell
环境的命令,我在本文前面使用了它们。该算法列在附录部分,这会以某种方式改变吗?我该怎么做才能解决这个问题?
我会非常感激任何能帮我解决此问题的帮助,因为提交截止日期是本周五!除了这个之外,论文的其他部分都已准备好提交,因此,再次非常感谢任何帮助。
答案1
这是一个常见问题,正如评论所暗示的那样,这是因为所有字符_
。将它们全部转义是一件很麻烦的事。我处理这个问题的方法是包含下划线包。这_
在正常模式下解决了这个问题。这样,您就可以保持算法文本的原样。