I do know that this questions have been asked before in
How to split algorithm2e over two pages
Unfortunately the answers given there did not work out for me.
I am struggling to realize a page break at the indicated spot.
Help is much appreciated.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[ruled,vlined,linesnumbered,onelanguage]{algorithm2e}
\begin{document}
\begin{algorithm}[H]
\SetAlgoLined
\caption{Dummy Algorithm.}
%
Do something. \\
\For{$k=0,1,2,3, ...$}{
Do something. \\
\eIf{$x \geq y$}{
Do something. \\
}{
Do something. \\
\For{$j = 1,...,10$}{
Do something. \\
}
THIS IS THE SPOT WHERE I NEED THE PAGE BREAK.\\
Do something. \\
}
}
\end{algorithm}
\end{document}
Best Answer
The linked answer's method will only work if you can break the algorithm into two or more parts that can be compiled separately. This is not the case in your example.
This approach is an alternative to solve the problem.
(1) Generate the algorithm as a standalone pdf file (
algo.pdf
in this example) usingalgo.tex
.(2) Add the top part of the algorithm using the
trim
andclip
options of the\includegraphics
command to crop the upper part of image.\includegraphics[trim=left bottom right top, clip]
(In bp units. A big point is 1/72 inch)Add
\clearpage
to typeset all remaining floats and then include the lower part of the figure, this time choosing the trim values to crop the bottom part of the image.Finally increase the counter of algorithm by 1.
This is the file algo.tex
This is the complete code.