![latex 中算法标题下方只有一条水平线](https://linux22.com/image/377083/latex%20%E4%B8%AD%E7%AE%97%E6%B3%95%E6%A0%87%E9%A2%98%E4%B8%8B%E6%96%B9%E5%8F%AA%E6%9C%89%E4%B8%80%E6%9D%A1%E6%B0%B4%E5%B9%B3%E7%BA%BF.png)
在乳胶算法中,我只希望标题下方有一条水平线,但在我的例子中,它给出了标题下方和上方的线,如图所示。我如何获得所需的输出?
\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
。