如何删除 algorithm2e 中代表块的垂直线

如何删除 algorithm2e 中代表块的垂直线
\begin{algorithm}
\SetNoLine
\DontPrintSemicolon % Some LaTeX compilers require you to use\dontprintsemicolon instead
\KwIn{A finite set $A=\{a_1, a_2, \ldots, a_n\}$ of integers}
\KwOut{The largest element in the set}
$max \gets a_1$\;
\For{$i \gets 2$ \textbf{to} $n$} {
  \If{$a_i > max$} {
      $max \gets a_i$\;
  }
}
\Return{$max$}\;
\caption{{\sc Max} finds the maximum number}
\label{algo:max}
\end{algorithm}

这里 \SetNoLine 不起作用

答案1

文档尚未更新(或者我没有找到信息):\SetNoLine已被弃用,并替换为\SetAlgoNoLine

\documentclass{article}

\usepackage{algorithm2e}

\begin{document}

{\SetAlgoNoLine%
  \begin{algorithm}
    \DontPrintSemicolon % Some LaTeX compilers require you to use\dontprintsemicolon instead
    \KwIn{A finite set $A=\{a_1, a_2, \ldots, a_n\}$ of integers}
    \KwOut{The largest element in the set}
    $max \gets a_1$\;
    \For{$i \gets 2$ \textbf{to} $n$} {
      \If{$a_i > max$} {
        $max \gets a_i$\;
      }
    }
    \Return{$max$}\;
    \caption{{\sc Max} finds the maximum number}
    \label{algo:max}
  \end{algorithm}}%

\begin{algorithm}
  %
  \DontPrintSemicolon % Some LaTeX compilers require you to use\dontprintsemicolon instead
  \KwIn{A finite set $A=\{a_1, a_2, \ldots, a_n\}$ of integers}
  \KwOut{The largest element in the set}
  $max \gets a_1$\;
  \For{$i \gets 2$ \textbf{to} $n$} {
    \If{$a_i > max$} {
      $max \gets a_i$\;
    }
  }
  \Return{$max$}\;
  \caption{{\sc Max} finds the maximum number}
  \label{algo:max}
\end{algorithm}
\end{document} 

在此处输入图片描述

如果希望整个文档没有垂直线,您可以选择noline

\usepackage[noline]{algorithm2e}

相关内容