I read the documentation of the package algorithm2e
to figure out how to insert continue
command within a while
loop, but I couldn't find any way to do it. Is there any work-around for this lack of syntax in this package?
1 Answer
You can define custom keywords using the \SetKw
command, as described in Section 11 of the manual. MWE:
\documentclass{article}
\usepackage{algorithm2e}
\SetKw{Continue}{continue}
\begin{document}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
\Continue
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms}
\end{algorithm}
\end{document}
Result:
Note: for future questions, please always provide an example of code that you have tried, so it is easier to provide a solution.
-
Thanks! I didn't know that it is possible to define new keywords for the package
algorithms2e
.– RasoulCommented Mar 12, 2016 at 15:39