
我有一個由三個頁面組成的演算法,我可以多次使用 use\algstore
和來將該演算法拆分到這三個頁面上嗎?\algrestore
答案1
是的,您可以根據需要多次執行此操作:
\documentclass{article}
\usepackage{algorithm,algpseudocode}
\begin{document}
\begin{algorithm}
\caption{Part 1}
\begin{algorithmic}[1]
\If {$a>b$}
\ForAll{x}
\State y
\EndFor
\algstore{part1}
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\caption{Part 2}
\begin{algorithmic}[1]
\algrestore{part1}
\Else
\ForAll{z}
\State t
\EndFor
\algstore{part2}
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\caption{Part 3}
\begin{algorithmic}[1]
\algrestore{part2}
\State R
\EndIf
\end{algorithmic}
\end{algorithm}
\end{document}
請注意,它甚至會追蹤行號,並且也會以更大的增量來執行此操作。