I am trying to split an algorithm over two pages. This has already been addressed before, with the closest result being this question. However, I have a wrinkle – I need the algorithm to have two sections: one lists the inputs, the second lists the steps.
Here is an example:
\documentclass{article}
\usepackage{algorithm}
\usepackage{caption}
\begin{document}
\begin{algorithm}[H]
\caption{\label{alg:MyAlgorithm}My Algorithm}
\textbf{\footnotesize Inputs}{\footnotesize \par}
\begin{itemize}
\item {\footnotesize Input $A$}{\footnotesize \par}
\item {\footnotesize Input $B$}{\footnotesize \par}
\end{itemize}
\textbf{\footnotesize Steps}{\footnotesize \par}
\begin{enumerate}
\item {\footnotesize Calculate $X$}{\footnotesize \par}
\item {\footnotesize Calculate $Y$}{\footnotesize \par}
\end{enumerate}
\end{algorithm}
\end{document}
The reason I need to split the algorithm across two pages is that the combination of the list of inputs and the steps of the algorithm won't fit on one page. I chose algorithmicx
because (1) it supports splitting, and (2) the ability to caption the continuation (that may be supported by other packages, but the linked example above showed how to do it). However, I am not clear on how I can include an itemized list (i.e. the first section, where I name the inputs to the algorithm) – the third thing I desire.
Is there something I'm missing about being able to use itemize
(for the section with the algorithm's inputs) and enumerate
(for the steps of the algorithm; I'm also happy to use line numbers instead of enumerate
), or am I barking up the wrong tree package-wise?
Best Answer
You can combine any number of
algorithmic
environments within youralgorithm
environment. The following MWE shows how you can do this to create a section called Inputs and one called Steps while still being able to break the algorithm over more than one page (with\algstore
and\algrestore
).