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

  • Are you tied to this output, or are you open to alternatives that might be more visually appealing? What are the restrictions in terms of packages? – Werner Sep 7 '16 at 6:23
  • I'm trying to reduce context due to letter's volume by tying two steps in one algorithm. I have no restrictions in terms of packages. I only want to solve this problem. Is there any solution? – Dongkyu Sim Sep 7 '16 at 7:04

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

enter image description here




  \caption{A two-step algorithm}
    \Statex \textit{First step}
    \While{$X\ \And\ Y$}
      \State Statement~1
        \State Statement~2
    \Statex \textit{Second step}
    \While{$Y\ \And\ X$}
      \State Statement~3
        \State Statement~4

  • Here is a very simple adaptation that adds hrules above and below text: \newcommand{\algstep}[1]{\item[]\medskip\hrule\kern 2pt\hbox to \textwidth{\hspace{\labelsep}\textbf{#1}\hfill}\hrule} – Francis Sep 7 '16 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.