结束词隐藏在算法块中

结束词隐藏在算法块中

假设我有以下代码:

\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}

结果:

在此处输入图片描述

文字在哪儿end

答案1

vlined选项禁止打印“end”。只需删除该选项,只保留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}

在此处输入图片描述

相关内容