# [texhax] Hyperref pointer misses the correct page

Alan T Litchfield alan at alphabyte.co.nz
Thu Jul 5 23:17:01 CEST 2012

Hi,

To be honest I was resisting the requirement for a minimal example,
simply because the real case is large and complex and I did not want to
inflict that on all and sundry. I know it is easier to have that.

*sigh* I guess I will have to comply.

The aux file does not offer much that I can that is helpful.

I seen have multiple instances of the same/similar behaviour and the fix
has been described as the process I described. However, while the page
numbers are correctly listed, the counter seems to accumulate all counters.

To be honest I don't think the fix you proviedd, Uwe, has caused the
problem because of the prevalence of postings about it.

Anyway, a minimal example has been constructed that comprises the
elements concerned and illustrates the issue on the final page.

Regards
Alan

On 5/07/12 9:15 PM, Uwe Lueck wrote:
> Sorry for the HTML again, read
> http://tug.org/pipermail/texhax/2012-July/ for .txt.
>
> Sorry, Alan, this kind of question can only trigger the
> newbie ritual of asking for a minimal example,
>
>      http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl
>
> where I opt for "hacking down" -- take away as much as possible
> keeping the effect, and then perhaps use lorem ipsum
> to replace the actual text.
>
> It may suffice for us to see the .aux file.
>
> I would not be surprised if it had something to do with my
> \ref and \pageref tricks; so we must see whether the
> phenomenon stays when you remove my macros or even
> any line number stuff.
>
> What you write reminds me of experiences when I tried to
> get lineno+hyperref functionality via hyperref's usual
> treatment of counters. The hyperref documentations says
> something like that whenever the user introduces a new
> kind of "objects" in addition to section' etc. -- say, extra',
> besides \theextra (that gets a default by the basic
> \newcounter{extra}'), hyperref needs some \theHextra
> for generating the hyperlink. I tried this and, for some
> time, I got a broken link to a section' that indeed started
> on a different page than where I wanted to link to.
> The reason was that hyperref (with counters) internally uses
> a "\@currentlabelname" that expanded to section' because
> I had failed to change this for line numbers.
>
> hyperref indeed contains large sections to deal with
> certain "objects" including footnotes, equations, and
> subfigures that need a more refined treatment than the
> other usual LaTeX "objects" like sections etc.
>
> So I guess it is a problem with the setup of your new
> kind of things and its counter, and it may suffice to
> tell us about that (first).
>
> Cheers,
>
>      Uwe.
>
> *Gesendet:* Donnerstag, 05. Juli 2012 um 07:31 Uhr
> *Von:* "Alan T Litchfield" <alan at alphabyte.co.nz>
> *An:* texhax at tug.org
> *Betreff:* Re: [texhax] Hyperref pointer misses the correct page
> Further,
>
> I have tried the following approach:
> 1. I add the counter \newcounter{hyperfixer} into the preamble
> 2. I add the target \refstepcounter{hyperfixer}\label{theLabel} into the
> text
> 3. I reference the target with \hyperref[theLabel]{\pageref*{theLabel}}
> somewhere else in the text.
>
> Page numbers are linking and displaying consistently now.
>
> The problem seems to be that \refstepcounter{hyperfixer} is
> indiscriminate. While the page numbers are now correctly linking,
> section numbering is affected. That is, a section (e.g. 8.3) is
> displayed as 109 instead of 8.3 because, I think, it is the 109th anchor
> in the document. However, it links to the correct anchor. Garrrgh.
>
> Fix one, break one,...
>
> Alan
>
> On 5/07/12 3:16 PM, Alan T Litchfield wrote:
>  > Hi all, and particularly the hyperref package maintainers.
>  >
>  > With Uwe's help, my previous issues have have resolved nicely. However,
>  > in the process I have found a new problem. I shall try to summarise:
>  >
>  > 1. Create a standard label in a document.
>  > 2. Somewhere earlier in the document, a pageref is entered that points
>  > at the label created.
>  > 3. PDFLaTeX the document and page reference is created correctly (p. 106)
>  > page 104 and not 106.
>  >
>  > Further investigation shows that hyperref might be pointing at the
>  > \section text and not the actual page the label is on. In this case, the
>  > section head is on page 104. There are other instances where the section
>  > text is on the same page as the label and the hyperlink points to the
>  > right page.
>  >
>  > \ref works as expected.
>  >
>  > Yes, the hyperref package is loaded in the correct sequence.
>  >
>  > Your help will be appreciated
>  >
>  > Alan Litchfield
>
> --
> AlphaByte
> PO Box 1941, Auckland
> http://www.alphabyte.co.nz
>
>
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/
>
> Automated subscription management: http://tug.org/mailman/listinfo/texhax
> Human mailing list managers: postmaster at tug.org
>
>

--
AlphaByte
PO Box 1941, Auckland
http://www.alphabyte.co.nz

-------------- next part --------------
A non-text attachment was scrubbed...
Name: hypertextCounter.tex
Type: application/x-tex
Size: 15246 bytes
Desc: not available
URL: <http://tug.org/pipermail/texhax/attachments/20120706/4bab6625/attachment-0001.tex>
`