## LaTeX forum ⇒ General ⇒ hyperref internal link to wrong page Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
JeffR
Posts: 9
Joined: Thu Aug 29, 2013 6:39 pm

### hyperref internal link to wrong page

Hello. I am writing long lecture notes in LaTeX, and sometimes modifying the subsection and equation counters myself. It works great, except that occasionally the resulting pdf file's hyperref internal links mysteriously go to the wrong page. I have managed to untangle the problem into a minimal example, which follows. In this case, after compiling the code with pdflatex, the link to 1.1.1 on the page 1 should jump to page 3, but instead it jumps to page 2. Why?? I'm hoping there is a simple fix for this. Thank you!
1. \documentclass[12pt]{article}
2. \usepackage{hyperref}
3. \renewcommand{\theequation}{\thesubsection.\arabic{equation}}
4. \begin{document}
5.
6. Start Section~1, Subsection~1:
7. \stepcounter{section}
8.
9. To square $x$, see: \ref{xsquared}.
10.
11. \vfil\eject
12.
13. Another equation is:
14. \begin{equation}
15. 1+1=2
16. \end{equation}
17.
18. Start Subsection~2, with reset equation numbers:
19. \stepcounter{subsection}
20. \setcounter{equation}{0}
21.
22. (Some text.)
23.
24. \vfil\eject
25.
26. The square of $x$ is:
27. \begin{equation}\label{xsquared}
28. x^2
29. \end{equation}
30.
31. \end{document}

Stefan Kottwitz
Posts: 9403
Joined: Mon Mar 10, 2008 9:44 pm
Hi Jeff!

By default, hyperref creates internal links based on the counters. When counters are changed, the names may not be properly distinguishable internally.

Disabling that by setting the hypertexnames option to false can fix it - it works with the example:

\usepackage[hypertexnames=false]{hyperref}

Stefan

JeffR
Posts: 9
Joined: Thu Aug 29, 2013 6:39 pm
Yes, that seems to fix it -- in my long notes file too. Woo hoo! Thank you so much!

Stefan Kottwitz wrote:Hi Jeff!

By default, hyperref creates internal links based on the counters. When counters are changed, the names may not be properly distinguishable internally.

Disabling that by setting the hypertexnames option to false can fix it - it works with the example:

\usepackage[hypertexnames=false]{hyperref}

Stefan

JeffR
Posts: 9
Joined: Thu Aug 29, 2013 6:39 pm
Hi again Stefan. Your solution is working great to fix up the equation hyperlinks -- thanks again! But I just discovered that it created a new problem, with the *index* hyperlinks. Specifically, my document has 11 pages of preamble (Preface etc) numbered with roman numerals, before beginning the main text on a fresh page 1 (arabic). With the hypertexnames=false option, the Index still lists the pages correctly, but the hyperlinks from the Index now take me to 11 pages earlier (e.g. a page 57 link in the index takes me to page 46). Everything else seems correct, aside from the Index hyperlinks. I see that this problem was already discussed somewhat at https://tex.stackexchange.com/questions ... rrect-page and https://stackoverflow.com/questions/145 ... f-the-page but none of their proposed hyperref options (plainpages=false,pdfpagelabels,pagebackref) seems to help. I haven't yet tried to make a minimal example, but I was wondering if you happen to know some other option to hyperref that would make this problem go away (while still allowing me to keep hypertexnames=false to fix that other problem). Thanks a lot!