# Algorithm2e package edit the line numbers

I need to remove the line numbers only below Step 1 and continue it after Step 2 and skip numbering infront of cc in Step 2.

Please refer to the attached figure and the latex code.

How I can do this?

I even used the command \LinesNotNumbered infront of the lines that I don't want to be numbered but still I have the problem

\documentclass[a4paper,11pt]{report}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}

\begin{document}
\begin{algorithm}
\DontPrintSemicolon
\KwIn{A,B,C }
\KwOut{D,E,F}
\textbf{Step 1}\\ AAA.\;
BB, \\ee\;
Then go to the home\\
\textbf{Step 2}\\
BB,\\ cc\;
Then go to a hotel\\
\SetAlgoRefName{1}
\caption{Ala kanawa}
\label{algo:sj1}
\end{algorithm}
\end{document}


Use \LinesNumberedHidden (inside a group if the effect is to be kept local) to suppress numbers and then add the numbering to the desired lines (this can be done with a command using \nlset with a user defined counter):

\documentclass[a4paper,11pt]{report}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\usepackage{etoolbox}

\newcounter{algoline}
\newcommand\Numberline{\refstepcounter{algoline}\nlset{\thealgoline}}
\AtBeginEnvironment{algorithm}{\setcounter{algoline}{0}}

\begin{document}

\begingroup
\LinesNumberedHidden
\begin{algorithm}
\DontPrintSemicolon
\KwIn{A,B,C }
\KwOut{D,E,F}
\Numberline\textbf{Step 1}\\ AAA.\;
BB, \\ee\;
\Numberline Then go to the home \\
\Numberline\textbf{Step 2} \\
\Numberline BB,\\ cc\;
\Numberline Then go to a hotel \\
\SetAlgoRefName{1}
\caption{Ala kanawa}
\label{algo:sj1}
\end{algorithm}
\endgroup

\end{document}


• Thanks for your response. I have a few algorithms but I need to change the numbers only in this algorithm. If I use your approach I need to change all my other algortihms which is a pain as I have alogrithms over 100 lines so I don't want to do this manually. So could you please suggest any other approach? Jan 16 '15 at 1:09
• @Harry Why would you need to change your other algorithms? As I explained, using a group, the changes I suggested will apply just to that specific algorithm; all others will remain unchanged. Jan 16 '15 at 1:14