How do I rename the While
loop using algorithm
and algpseudocode
?
\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithm*}
\caption{bar baz}
\label{alg:interesting}
\begin{algorithmic}[1]
\While{foo bar}
\EndWhile
\end{algorithmic}
\end{algorithm*}
\end{document}
It prints it out as
While foo bar do
end while
I would like to it come as
Until foo bar repeat
end while
How do I change only the first part of the while loop.
Best Answer
The original definition of the while block in
algpseudocode.sty
isyou can then replace
\algorithmicwhile
with\algorithmicuntil
, and\algorithmicdo
with\algorithmicrepeat
; a complete example:I only replaced the first occurrence of
\algorithmicwhile
as requested in the question; perhaps it would be better to change both.Perhaps, as egreg has suggested in a comment, a better option would be to define a new
Until
block; here's how this could be done: