我似乎不知道如何在algorithm2e
伪代码的开头放置标题。我知道在环境中可以做到这一点ruled
,但我不想在顶部和底部放置这些行。如何将算法标题移到代码上方?
答案1
plain
您可以调整(默认)样式设置标题的方式(从bottom
到above
或top
):
\documentclass{article}
\usepackage{algorithm2e}% http://ctan.org/pkg/algorithm2e
\makeatletter
\renewcommand{\@algocf@capt@plain}{above}% formerly {bottom}
\makeatother
\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}
\end{document}