We try to reference a line in a shy algorithm and the algorithm itself with zref-clever. Running pdflatex twice on
\documentclass{article}
\pagestyle{empty}
\usepackage{hyperref}
\usepackage{algorithm2e}
\usepackage{zref-clever}
\zcRefTypeSetup{algocf}{
name-sg=Alg.\@,
Name-sg=Alg.\@
}
\zcRefTypeSetup{AlgoLine}{
Name-sg=line,
name-sg=line
}
\zcRefTypeSetup{algocfline}{
Name-sg=line,
name-sg=line
}
\zcRefTypeSetup{line}{
Name-sg=line,
name-sg=line
}
\begin{document}
\begin{algorithm}\LinesNumbered
\caption{My great algorithm}\label{algLabel}
\KwOut{The oh so great output of my great algorithm}
command1\;
command2\nllabel{lineLabel}\;
command3
\end{algorithm}
\zcref[S]{algLabel} contains \zcref{lineLabel}.
\end{document}
yields
As we see, the second type name is “Alg.”, whereas we'd expect “line”. If we comment out hyperref, we get “Alg. 1 contains line 2.” as expected. So far we failed to get different type names for the two references in the presence of hyperref, so you can blame it. At the same time, given that algorithm2e has been unmaintained for about 8½ years and zref-clever for slightly over 1 year, you can blame them, too. Anyway, what is the technical root cause of the failure? Any bugfix, patch, or workaround?


\autoref{algLabel} contains \autoref{lineLabel}be an option?\zreffrom zref-clever to\autoreffrom thmtools? I'm afraid switching to yet another package for my non-minimal document (not shown here) is out of option as of now, as it'd take me at least a full day, given the current state of the bug tracker of thmtools and given that its last commits happened already 2 years ago. I'm in the process of ditching an even older cleveref …\autorefis fromhyperref, not fromthmtools(see page 26 of the hyperref manual). It just takes the value of the string fromthmtoolsorbabelor whichever other package (re)defines\algorithmname. You can still usezref-cleverfor everything else. Not ideal but a quick solution - I'll post an answer.