# Algorithm over two pages, with itemized lists

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?

-

You can combine any number of algorithmic environments within your algorithm 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).

\documentclass{article}
\usepackage{algorithm}% http://ctan.org/pkg/algorithm
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
\usepackage{caption}% http://ctan.org/pkg/caption

\begin{document}

\begin{algorithm}
\caption{My algorithm}
\textbf{Inputs}% Inputs section
\begin{algorithmic}[1]
\State Input $A$
\State Input $B$
\State Input $C$
\end{algorithmic}
\bigskip

\textbf{Steps}% Steps section
\begin{algorithmic}[1]
\Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
\State $r\gets a\bmod b$
\While{$r\not=0$}\Comment{We have the answer if r is 0}
\State $a\gets b$
\State $b\gets r$
\algstore{myalg}
\end{algorithmic}
\end{algorithm}

\clearpage

\begin{algorithm}
\ContinuedFloat
\caption{My algorithm (continued)}
\begin{algorithmic}
\algrestore{myalg}

\State $r\gets a\bmod b$
\EndWhile\label{euclidendwhile}
\State \textbf{return} $b$\Comment{The gcd is b}
\EndProcedure
\end{algorithmic}
\end{algorithm}

\end{document}​

-
That does the trick, thanks! I had aimed for using itemized lists and enumerated lists, but those weren't essential. Using \State will work instead. –  Iterator Nov 21 '11 at 21:42