[Tex/LaTex] Repeat block without until (or blank line) using algorithm2e

algorithm2emacrospseudocode

I'm trying to format a "repeat forever" block using algorithm2e. I've found the \Repeat command but this prints an until at the end of my block. I can hide the word until using:

\SetKwRepeat{Repeat}{repeat}{}

But then a blank line appears. I'm currently using the noend option so I'd like to completely remove the closing clause. How can I get rid of this blank line?

Best Answer

You could use \SetKwBlock:

\documentclass{article}
\usepackage{algorithm2e}

\SetKwBlock{Repeat}{repeat}{}

\begin{document}

\begin{algorithm}
\Repeat{do these things}
\While{$i<n$}{a while loop\;
  \Repeat{do other things}
  this condition\;
}
\end{algorithm}

\end{document}

enter image description here

Related Question