# cleveref, hyperref and algorithm2e package produce wrong hyperlink (though correct page reference)

I'm using the packages as stated above in their latest version (also oberdiek-package is up-to-date).

The following code produces the wrong pdf-link to a float environment (refers to the same page as the reference, not to the referred algorithm), although the pageref command reflects the correct page.

 [...] depends upon \cref{alg:algorithm2} which is on page
\pageref{alg:algorithm2}.


produces

• Is \label{alg:algorithm2} after the \caption command in your algorithm? – Werner Dec 1 '11 at 20:12
• Also make sure to load cleveref after hyperref – cmhughes Dec 1 '11 at 20:17
• Yes. Every algorithm is defined like the following snipplet shows: \begin{algorithm} \caption{CaptionOfTheAlgorithm} \label{alg:algorithm2} [...] @cmhughes: cleveref loaded after hyperref, done. – Eric Dec 1 '11 at 20:20
• Could you create a MWE that demonstrates this? – cmhughes Dec 1 '11 at 20:23
• @Eric: Without an MWE it is virtually impossible to assess what the problem is. I would suggest sequentially removing document elements from your source code until the problem disappears. This way you can selectively focus in on the problem and try to eliminate it. This could be removing actual main document/typeset content, to removing preamble content while still maintaining a consistent/compilable document. Some more considerations: What PDF viewer are you using? Have you tested it in other viewers? Do you reset the page numbers in your document (or have a \front-, \mainmatter setup)? – Werner Dec 2 '11 at 8:00

• In tex.stackexchange.com/a/1868/586 it is mentioned that algorithm is one of the exceptions to the rule "load hyperref last", perhaps the same is true for algorithm2e. – Torbjørn T. Dec 2 '11 at 10:09