4

I'm using algorithm2e package. One of my algorithm does NOT need a title. If I simply do not type in \caption, there are still three rules.! I want to remove the second rule.

Is there any way to do this? Thanks!

enter image description here

Werner
  • 603,163
user2477759
  • 63
  • 1
  • 5

1 Answers1

11

One could probably detect whether the caption is empty. However, a quick/dirty way is to merely condense the gap (so that the two horizontal rules are drawn overtop of one another). Below two possibilities are presented:

enter image description here

\documentclass{article}
\usepackage[ruled]{algorithm2e}% http://ctan.org/pkg/algorithm2e
\begin{document}

\begin{algorithm}
  \caption{An algorithm}
  aaa\;
  bbb\;
  ccc\;
\end{algorithm}

{
\setlength{\interspacetitleruled}{-.4pt}%
\begin{algorithm}
  aaa\;
  bbb\;
  ccc\;
\end{algorithm}
}

{
\setlength{\interspacetitleruled}{0pt}%
\setlength{\algotitleheightrule}{0pt}%
\begin{algorithm}
  aaa\;
  bbb\;
  ccc\;
\end{algorithm}
}

\end{document}
Werner
  • 603,163
  • Many thanks, I'm currently using the third one. Seems it works well as the top and bottom margins look the same. Dont know if there's other standard ways to do this... Anyway, the ways you provided work well. Thanks! – user2477759 Dec 26 '13 at 12:04