[Tex/LaTex] End word is hidden in algorithm block

algorithm2ealgorithms

Suppose that i have this code:

\usepackage[ruled,vlined]{algorithm2e}
\begin{dcocument}
\begin{algorithm}[H]
 \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\;
   }{
   go back to the beginning of current section\;
  }
 }
 \caption{How to write algorithms}
\end{algorithm}
\end{dcocument}

Result:

enter image description here

Where are end words?

Best Answer

The vlined option suppresses the printing of “end”. Just remove the option, keeping just ruled:

\documentclass{article}
\usepackage[ruled]{algorithm2e}

\begin{document}
\begin{algorithm}[H]
\caption{How to write algorithms}
 \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\;
   }{
   go back to the beginning of current section\;
  }
 }
\end{algorithm}
\end{document}

enter image description here