[Tex/LaTex] Turn off line numbering in algorithm2e

algorithm2eline-numbering

I have the following preamble for algorithm2e:

   \usepackage[ruled,vlined,linesnumbered,resetcount,algochapter]{algorithm2e}

I have many algorithms, in on of the algorithm as follows:

 \begin{algorithm}[t!]
    \centering
    nonumbering
    \caption{CAmple}\label{algoCPOR}
    \end{algorithm}

I do not want the line nonumbering (only that line) to be numbered, how should I achieve this?

Best Answer

Depending on your use-case, you can either use \LinesNotNumbered or \LinesNumberedHidden to temporarily remove lines numbers in an algorithm. Under the latter, \ShowLn prints the line number for that specific line (if you wish to intermix showing/not):

enter image description here

\documentclass{book}
\usepackage[ruled,vlined,linesnumbered,resetcount,algochapter]{algorithm2e}% http://ctan.org/pkg/algorithm2e
\begin{document}

{\LinesNumberedHidden
\begin{algorithm}[ht]
  \centering
  nonumbering
  \caption{CAmple1}\label{algoCPOR1}
\end{algorithm}}

\begin{algorithm}[ht]
  \centering
  nonumbering
  \caption{CAmple2}\label{algoCPOR2}
\end{algorithm}

\LinesNumberedHidden
\begin{algorithm}[ht]
  \centering\ShowLn
  nonumbering
  \caption{CAmple3}\label{algoCPOR3}
\end{algorithm}
\end{document}