[Tex/LaTex] How to insert a “continue” in while command of Algorithm2e

algorithm2e

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?

Best 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:

enter image description here

Note: for future questions, please always provide an example of code that you have tried, so it is easier to provide a solution.