在乳胶算法中,我只希望标题下方有一条水平线,但在我的例子中,它给出了标题下方和上方的线,如图所示。我如何获得所需的输出?
\documentclass[12pt,a4paper, oneside]{Thesis}
\usepackage[ruled, vlined, linesnumbered]{algorithm2e}
\begin{document}
\begin{algorithm}[H]
\label{algo:datapacket}
\caption{Algorithm for selecting the forwarder among PFNs.}
% do something
\end{algorithm}
\end{document}
答案1
执行标题上方规则的宏是\@algocf@pre@ruled
。您可以重新定义它以不执行任何操作:
\documentclass[12pt,a4paper, oneside]{article}
\usepackage[ruled, vlined, linesnumbered]{algorithm2e}
\makeatletter
\def\@algocf@pre@ruled{}%
\makeatother
\begin{document}
\begin{algorithm}[H]
\caption{Algorithm for selecting the forwarder among PFNs.}
\label{algo:datapacket}
\While{Meaning of Life = 42}{
Hello world!
}
\end{algorithm}
\end{document}
此外,\label
必须在 之后\caption
。