答案1
有几种方法可以得到纠正,它可能取决于其他用法
我并不是说这些更正确,但最简单的方法是删除第 1 行的 $,但这会使字体变为直立,因此请查看一些带有斜体的替代方案
\documentclass[10pt]{report}
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
\usepackage{algorithm}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath,graphicx,subfigure}
\begin{document}
\begin{algorithm}
\caption{Filtering lexicon file}
\label{algo1}
\begin{algorithmic}[1]
\State $Lex \gets $ read the whole lexicon file.
\State $Lex \gets~read~the~whole~lexicon~file.$
\State $Lex \gets \textit{read the whole lexicon file.}$
\State $Lex \gets $ \textit {read the whole lexicon file.}
\State $Lex \gets $ {\itshape read the whole lexicon file.} % as recommended by Barbara Beeton This switch should be bound
\State $Lex \gets $ read the whole lexicon file. % note none of the above have affected this line
here is another line
\end{algorithmic}
and another
\end{algorithm}
另一个 \end{document}