[Tex/LaTex] How to split two steps in one algorithm box for LaTeX

algorithms

How can I split two steps in one algorithm box for LaTeX like below image?

Is it impossible? If possible, please answer me.

Thank you very much.

enter image description here

Best Answer

Perhaps you can use \Statex from algpseudocode to "comment" a step or break:

enter image description here

\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}