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:




\caption{\label{alg:MyAlgorithm}My Algorithm}
\textbf{\footnotesize Inputs}{\footnotesize \par}
\item {\footnotesize Input $A$}{\footnotesize \par}
\item {\footnotesize Input $B$}{\footnotesize \par}
\textbf{\footnotesize Steps}{\footnotesize \par}
\item {\footnotesize Calculate $X$}{\footnotesize \par}
\item {\footnotesize Calculate $Y$}{\footnotesize \par}



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).

enter image description here

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


  \caption{My algorithm}
  \textbf{Inputs}% Inputs section
    \State Input $A$
    \State Input $B$
    \State Input $C$

  \textbf{Steps}% Steps section
    \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$


  \caption{My algorithm (continued)}

        \State $r\gets a\bmod b$
      \State \textbf{return} $b$\Comment{The gcd is b}

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.