I am looking for a way to use cleveref and hyperref in combination with the clrscode3e package. Unfortunately, the packages do not work together out-of-the-box.
More precisely, I am considering the following use case. For a given codebox, I want to be able to label a line and later reference it in the text using the \cref
command. When typeset, this should print a clickable line number hyperlinking back to the line in the codebox. A MWE is depicted below.
\documentclass{article}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{clrscode3e}
\begin{document}
\begin{codebox}
\Procname{$\proc{MWE}$}
\li $x \gets 1$ \label{lin:assign}
\End
\end{codebox}
As shown in \cref{lin:assign}, \dots
\end{document}
I have posted a similar question not too long ago: Cleveref with clrscode3e. The question however did not involve the use of hyperref and the solution therefore cannot be mapped one-to-one. The reason, more precisely, is that the hyperlinks created by hyperref always point to the first codebox in the document, no matter the codebox containing the label.