答案1
也许你可以\Statex
使用algpseudocode
“评论”某个步骤或中断:
\documentclass{article}
\usepackage{algorithm,algpseudocode}
\algnewcommand{\And}{\textbf{and}}
\begin{document}
\begin{algorithm}
\caption{A two-step algorithm}
\begin{algorithmic}[1]
\Statex \textit{First step}
\While{$X\ \And\ Y$}
\State Statement~1
\If{$Z$}
\State Statement~2
\EndIf
\EndWhile
\Statex \textit{Second step}
\While{$Y\ \And\ X$}
\State Statement~3
\If{$Z$}
\State Statement~4
\EndIf
\EndWhile
\end{algorithmic}
\end{algorithm}
\end{document}