[Tex/LaTex] How to remove vertical lines representing a block in 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}

Here \SetNoLine is not working

Best Answer

The documentation hasn't been updated (or I didn't find the information): \SetNoLine is deprecated, and replaced with \SetAlgoNoLine. If you want no vertical lines for the whole document, you have the option noline.

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

enter image description here