# avoid line numbering in a algorithm when closing tcolorbox and adjustbox

when closing the tcolorbox and adjustbox inside an algorithm, the lines of codes corresponding to their commands are displayed numbered. How can I prevent the 1 beside the caption (see the below figure) from being displayed in the following code?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[linesnumbered]{algorithm2e}
\begin{document}

\begin{algorithm}[htp!]
\setcounter{AlgoLine}{0}
\KwData{X: some description o fthe data}
\KwData{Y: other data to describe}
\vspace*{5pt}
\hrule
\vspace*{5pt}
here is the first lone of the code \;
\For{ condition }{
wow for loop!! \;
\For {condition}{
\While{condition}{
that's intriguing;
\While{indx in indxs or empty}{indx  $\leftarrow$ rblabla\;}}
blabla\;
\For{condition}{
blabla\;
blabla\;}}}
%here I should put something to stop the numbering
\caption{my caption}\label{alg:this}
\end{algorithm}
\end{document}


The following might be sufficient to remove the orphaned line numbering:

\documentclass{article}

\usepackage[linesnumbered]{algorithm2e}

\begin{document}

\begin{algorithm}
\SetNlSty{@gobble}{}{}% Remove line numbering
\SetNlSty{textbf}{}{}% Default line numbering style
\setcounter{AlgoLine}{0}% Restore default line numbering start
\begin{tcolorbox}[left=20pt]
\KwData{X: some description o fthe data}
\KwData{Y: other data to describe}
\vspace*{5pt}
\hrule
\vspace*{5pt}
here is the first lone of the code \;
\For{ condition }{
wow for loop!! \;
\For {condition}{
\While{condition}{
that's intriguing;
\While{indx in indxs or empty}{indx  $\leftarrow$ rblabla\;}}
blabla\;
\For{condition}{
blabla\;
blabla\;}}}
%here I should put something to stop the numbering
\end{tcolorbox}
\caption{my caption}
\end{algorithm}

\end{document}


We set \NlSty to \@gobble the line numbering outside the tcolorbox, and restore it inside. Crude, but functional.

• Thank you for the solution. this works fine! – matlio Oct 21 at 18:49