\usepackage{algorithm}
\usepackage{algorithmic}
\begin{document}
\begin{algorithm}[H]
\caption{My algo}
\begin{algorithmic}[1]
\STATE instruction 1
\STATE instruction 2
......................Many instructions
\end{algorithmic}
\end{algorithm}
\end{document}
我的算法占了一整页,可以分成两页吗?非常感谢。
答案1
我建议你使用algorithmicx
和它的algcompatible
变体而不是 algorithmic
;前者更加灵活和强大,为您提供了很多定制的可能性和一种简单的分割算法的方法,使用\algstore
和\algrestore
;一个小例子:
\documentclass{article}
\usepackage[paperheight=6\baselineskip]{geometry}% just for the example
\usepackage{algorithm}
\usepackage{algcompatible}
\begin{document}
\begin{algorithm}[H]
\caption{My algo}
\begin{algorithmic}[1]
\STATE instruction 1
\STATE instruction 2
\algstore{testcont}
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[H]
\caption{My algo - Part 2}
\begin{algorithmic}[1]
\algrestore{testcont}
\STATE instruction 3
\STATE instruction 4
\end{algorithmic}
\end{algorithm}
\end{document}