如何使用 Latex 编写算法通讯录《计算机杂志》的文件?
这comjnl.cls
定义算法环境如下(第 347 行):
\newtheorem{algorithm}{Algorithm}
这与algorithm2e
环境冲突。最小(不)工作示例:
\documentclass{comjnl}
\usepackage{amsmath}
\usepackage{algorithm2e}
\begin{document}
\begin{algorithm}
\SetAlgoLined
\KwResult{Write here the result }
initialization
\While{While condition}{
instructions
}
\caption{How to write algorithms}
\end{algorithm}
\end{document}
谢谢!
答案1
您可以algorithm
在加载之前删除环境algorithm2e
:
\documentclass{comjnl}
\makeatletter
\let\algorithm\@undefined
\let\endalgorithm\@undefined
\makeatother
\usepackage{algorithm2e}
\begin{document}
\begin{algorithm}
\SetAlgoLined
\KwResult{Write here the result }
initialization
\While{While condition}{
instructions
}
\caption{How to write algorithms}
\end{algorithm}
\end{document}