Remove the rule below the algorithm title - using Algorithm2e

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!

• 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 Dec 26 '13 at 2:42

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:

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

• 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