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


referring to algorithm 2

  • 1
    Is \label{alg:algorithm2} after the \caption command in your algorithm?
    – Werner
    Dec 1 '11 at 20:12
  • 2
    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
  • 1
    Could you create a MWE that demonstrates this?
    – cmhughes
    Dec 1 '11 at 20:23
  • 2
    @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

After almost 3 hours of error analysis I ended up with a solution that worked with my setup - and may also be a hint to help others and solve similar problems.

I included hyperref as the very first package and as a consequence all links were set correctly.

@Werner: your help is appreciated - thank you. That was actually what I did. It was not obvious to me, how hyperref constructs its links (and it still is :-). I just was wondering, if there's some way to look under the hood - some log-file or any other mechanism that could speed up the investigation.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.