## 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!
\documentclass[12pt]{article}\usepackage{hyperref}\renewcommand{\theequation}{\thesubsection.\arabic{equation}}\begin{document} Start Section~1, Subsection~1:\stepcounter{section} To square $x$, see: \ref{xsquared}. \vfil\eject Another equation is:\begin{equation}1+1=2\end{equation} Start Subsection~2, with reset equation numbers:\stepcounter{subsection}\setcounter{equation}{0} (Some text.) \vfil\eject The square of $x$ is:\begin{equation}\label{xsquared}x^2\end{equation} \end{document}

Stefan Kottwitz
Posts: 9367
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!