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

1
  • 1
    It is always advised to provide a minimal working example (MWE) that replicates the problem, so the community can have something to work with.
    – Werner
    Commented Dec 26, 2013 at 2:42

1 Answer 1

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}
1
  • 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! Commented Dec 26, 2013 at 12:04

You must log in to answer this question.

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