对于附录部分,我想重置方程式和算法的编号,并想在数字前添加字母“A”。我确实通过在附录开头添加以下几行来实现方程式的这一目标。我如何对我的算法做同样的事情?我正在使用软件包algorithm2e
。
\setcounter{equation}{0}
\renewcommand{\theequation}{A\arabic{equation}}
答案1
通过检查包源代码,algocf
你\thealgocf
就是你的朋友。
例子:
\documentclass{article}
\usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
\begin{document}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms}
\end{algorithm}
\appendix
\setcounter{algocf}{0}
\renewcommand{\thealgocf}{A\arabic{algocf}}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms}
\end{algorithm}
\end{document}