3

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

referring to algorithm 2

lockstep
  • 250,273
Eric
  • 2,587
  • 5
  • 23
  • 26
  • 1
    Is \label{alg:algorithm2} after the \caption command in your algorithm? – Werner Dec 01 '11 at 20:12
  • 2
    Also make sure to load cleveref after hyperref – cmhughes Dec 01 '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 01 '11 at 20:20
  • 1
    Could you create a MWE that demonstrates this? – cmhughes Dec 01 '11 at 20:23
  • I tried to prepare a minimal example, but - as expected - everything worked out correctly. It most likely has to do with my setup. Is there any way to trace how the links are constructed/ built and why hyperref therefore links to page 31? – Eric Dec 01 '11 at 20:52
  • @Eric: In your post you mention that "pageref command reflects the correct page", yet now you mention that it is incorrect. Which of the \cref or \pageref commands point to the correct referencing point? Also, have you compiled your document a couple of times to let the references "settle"? – Werner Dec 01 '11 at 20:56
  • @Werner: I let latexmk do the work for me; the text in the final PDF is correct - i.e. the algorithm2 is on page 33; the hyperlink points to page 31, which is wrong. Hope that my post makes more sense to you now. – Eric Dec 01 '11 at 21:02
  • 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 02 '11 at 08:00

1 Answers1

3

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.

Eric
  • 2,587
  • 5
  • 23
  • 26