2

I want only one Horizontal line below the caption in latex algorithm but in my case it gives line below and above the caption as shown. How can I get the desired output ?enter image description here

\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}
3
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – dexteritas
    Jun 1, 2018 at 10:11
  • \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} Jun 1, 2018 at 10:41
  • Please add the code to your post, not in the comments.
    – Bernard
    Jun 1, 2018 at 10:50

1 Answer 1

1

The macro that does the rule above the caption is \@algocf@pre@ruled. You can redefine it to do nothing:

\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}

enter image description here

Also, the \label has to be after the \caption.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .