This is a follow-up question to: https://tex.stackexchange.com/a/33869/173478
The breakablealgorithm
environment, as proposed by Werner, splits algorithms perfectly. However, for me the breakable algorithms have different vertical padding from the regular algorithms. The following is a minimal example for reproducing the behavior:
\documentclass[a4paper]{article}
\usepackage{algorithm,algpseudocode}
\makeatletter
\newenvironment{breakablealgorithm}
{% \begin{breakablealgorithm}
\begin{center}
\refstepcounter{algorithm}% New algorithm
\hrule height.8pt depth0pt \kern2pt% \@fs@pre for \@fs@ruled
\renewcommand{\caption}[2][\relax]{% Make a new \caption
{\raggedright\textbf{\fname@algorithm~\thealgorithm} ##2\par}%
\ifx\relax##1\relax % #1 is \relax
\addcontentsline{loa}{algorithm}{\protect\numberline{\thealgorithm}##2}%
\else % #1 is not \relax
\addcontentsline{loa}{algorithm}{\protect\numberline{\thealgorithm}##1}%
\fi
\kern2pt\hrule\kern2pt
}
}{% \end{breakablealgorithm}
\kern2pt\hrule\relax% \@fs@post for \@fs@ruled
\end{center}
}
\makeatother
% DOCUMENT
\begin{document}
This is some text.
\begin{algorithm}[H]
\caption{Regular Algorithm}
\begin{algorithmic}
\State Start
\end{algorithmic}
\end{algorithm}
And some more text.
\begin{breakablealgorithm}
\caption{Breakable Algorithm}
\begin{algorithmic}
\State Start
\end{algorithmic}
\end{breakablealgorithm}
And even more text.
\end{document}
Also, when setting the document class to amsart or amsbook, there is no padding at all. How can I modify the breakablealgorithm
environment to naturally have the same padding as the regular algorithm environment?