I am trying to put a line in algorithm2e:
\documentclass{IEEEtran}
\usepackage[ruled,linesnumbered]{algorithm2e}
\begin{document}
\IncMargin{1.5em}
\begin{algorithm}
algorithm here\;
\hrule
algorithm here\;
\caption{Caption}
\end{algorithm}
\DecMargin{1.5em}
\end{document}
There is a gap at the start and end of the line (indicated by the red arrows). I tried the code from here but it also contains gap. I also tried \moveleft with \vbox which although removes the gap but I have to hardcode the measurements, and it doesn't work with different \IncMargin values in different algorithms.
How to remove this gap? The gap is also affected by \IncMargin, I don't want it to be affected by \IncMargin.


