I'd like to use similar styles for pseudocode/algorithms and listings using the algorithm2e
package. Therefore I need a line above and below the algorithm but not above the caption. Haven't found any solution so far.
Adjusted several configurations like the style of the line numbers and the caption, but yeah.. cannot getting rid off the line above:
\setlength{\algoheightrule}{0.4pt}
\renewcommand\AlCapFnt{\normalfont}
\SetAlgoCaptionLayout{centerline}
\SetNlSty{ttfamily}{}{}
\SetAlgoNlRelativeSize{-3}
Thanks a lot!
MWE:
\documentclass[a4paper, 11pt]{book}
\usepackage[ruled]{algorithm2e}
\begin{document}
\begin{algorithm}
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX}
\caption{How to write algorithms}
\end{algorithm}
\end{document}