# Algorithm over 2 pages

I am writing a few rather large pseudocode functions using algorithm and algorithmic, i.e. my code looks something like:

\begin{algorithm}
\caption{Coolest Algorithm ever}
\label{findme}
\begin{algorithmic} [1]                   % enter the algorithmic environment
\REQUIRE    Here are a few variables \\
variable 2 \\
variable 3
\ENSURE     this is the output \\
output 2

\STATE $some cool code here$
\STATE $some cool code here$
\STATE $some cool code here$
\STATE $some cool code here$
\end{algorithmic}
\end{algorithm}

Unfortunately this code does not fit on one page and I am definitely not able to split it into some subfunctions or so (I already did that as far as possible).

So now I need to split up the algorithm into two pages, but I have no idea how.

The easiest way I can imagine is just to start a new algorithm on the new page, but this time letting the line counter start at line 35 or so instead of 1. But how can I do that?

Please not that there is already a similar question here on this site, but it deals with the package algorithmicx.

-
Note that the algorthmicx package is compatible with the commands provided by algorithmic (from the algorithms bundle). – Werner Sep 28 '11 at 20:08

You should use the algorithmicx package instead and its \algstore and \algrestore commands. If you don't want to rewrite all your algorithmic algorithms, you can still use algorithmicx either by loading the algpseudocode package with the compatible option, or by loading the algcompatible package:

\documentclass{article}
\usepackage{algcompatible}
\usepackage{algorithm}

\begin{document}

\begin{algorithm}
\caption{Coolest Algorithm ever}
\label{findme}
\begin{algorithmic} [1]                   % enter the algorithmic environment
\REQUIRE    Here are a few variables \\
variable 2 \\
variable 3
\ENSURE     this is the output \\
output 2
\algstore{myalg}
\end{algorithmic}
\end{algorithm}

\begin{algorithm}
\begin{algorithmic} [1]                   % enter the algorithmic environment
\algrestore{myalg}
\STATE $some cool code here$
\STATE $some cool code here$
\STATE $some cool code here$
\    STATE $some cool code here$
\end{algorithmic}
\end{algorithm}

\end{document}

-
I just tried it and got this error: LaTeX Error: Unknown option 'algcompatible' for package 'algpseudocode'. Why that? I use MacTex – chris Sep 28 '11 at 20:51
@chris Most probably you are using an outdated version of algpseudocode (and possibly some other package(s)). The best way to proceed would be to update your packages or, even better, your LaTeX system. If updating is not an option, you could try with the now superseded option compatible instead of algcompatible; e.g., \usepackage[compatible]{algpseudocode}. – Gonzalo Medina Sep 28 '11 at 21:49
I just updated my complete system with all packages, the error is still the same - when I use compatible instead of algcompatible, my file compiles, but not all commands are supported – chris Sep 28 '11 at 23:57
@chris: my bad. You can use either \usepackage[compatible]{algpseudocode} or \usepackage{algcompatible}. I mixed the two options up (must be the flu). I will correct my example code. – Gonzalo Medina Sep 29 '11 at 0:09
Thank you, works now :) – chris Sep 29 '11 at 10:48