algomathdisplay
from包的正确用法是什么algorithm2e
?我似乎误解了它的用法,请参见下面的示例。有两种不同的尝试,一种是
\begin{algomathdisplay}
...
\end{algomathdisplay}
%
next line
这会导致下一行出现奇怪的缩进,并进行第二次尝试:
\begin{algomathdisplay}
...
\end{algomathdisplay}\;
%
next line
结果是空的分号行
最后这是完整的代码
\begin{algorithm}
\While{test}{
Some words introducing the following equation
\begin{algomathdisplay}
1+1
\end{algomathdisplay}
Another line\;
Words introducing the second equation
\begin{algomathdisplay}
2+2
\end{algomathdisplay}\;
Last Line;
}
\end{algorithm}
错误的解决方案
建议的宏修复 https://tex.stackexchange.com/a/543384/82917
\makeatletter
\renewenvironment{algomathdisplay}
{\[}
{\@endalgocfline\vspace{-\baselineskip}\]\;}
\makeatother
\begin{algorithm}
\While{test}{
Another line\;
Words introducing the second equation
\begin{algomathdisplay}
2+2
\end{algomathdisplay}
Last Line\;
}
\end{algorithm}
结果是
答案1
这个问题是全球性\DontPrintSemicolon
的https://tex.stackexchange.com/a/543384/82917
可以通过以下方法实现侵入性较小的效果
\makeatletter
\renewenvironment{algomathdisplay}
{\[}
{\@endalgocfline\vspace{-\baselineskip}\]{\DontPrintSemicolon\;}}
\makeatother