I have a custom command to display pseudocodes using tcolorbox. The \newtcblisting command creates a custom counter to display the boxes. I'm trying to reference the pseudocodes somewhere in the document showing this custom counter but I only managed to show the chapter counter using \ref.
Here's a sample code:
\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage[most]{tcolorbox}
\usepackage{minted}
\usepackage[
colorlinks=true,
]{hyperref}
\usepackage{etoolbox}
\begin{document}
\newtcblisting[auto counter,list inside=mypseudocodes]{pseudocodeV1}[3][]{%
list entry={\thesection.\protect\numberline{\thetcbcounter}#2},
title={Pseudocode \thesection.\thetcbcounter\label{pseudocode:#3}: #2},
listing options={tabsize=2,escapeinside=||,mathescape=true},
listing only,
enhanced,
#1
}
\newtcblisting[auto counter,list inside=mypseudocodes]{pseudocodeV2}[3][]{%
list entry={\thesection.\protect\numberline{\thetcbcounter}#2},
title={Pseudocode \thesection.\thetcbcounter\def@currentlabel{Custom ref Text}{\label{pseudocode:#3}}: #2},
listing options={tabsize=2,escapeinside=||,mathescape=true},
listing only,
enhanced,
#1
}
\tcblistof[\section*]{mypseudocodes}{List of Pseudocodes}
\addcontentsline{toc}{chapter}{List of Pseudocodes}
\section{Test1}
PseudocodeV1: \ref{pseudocode:code} \
\noindent
PseudocodeV2: \ref{pseudocode:code2} \
\section{Test2}
\begin{pseudocodeV1}{
My Title
}{code}
a = 1;
a = 2;
\end{pseudocodeV1}
\section{T1}
\begin{pseudocodeV2}{
My Title
}{code2}
a = 1;
a = 2;
\end{pseudocodeV2}
\end{document}
Anyone knows why the command \def\@currentlabel{}{} isnt working or can suggest any workarround?
I've got the \def\@currentlabel{}{} suggestion from: Labeling a text and referencing it later


\makeatletteris missing (before the\newtcblisting). – Ulrike Fischer Sep 21 '23 at 19:18\ref{pseudocode:code2}to print “Custom ref Text“, do you? – egreg Sep 21 '23 at 20:38