[Tex/LaTex] Algorithm2e package edit the line numbers

algorithm2ealgorithmicxalgorithms

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} 

enter image description here

Best Answer

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} 

enter image description here

Related Question