I am facing an issue with indexing and hyperlinks. The page number that shows in the index is correct, but clicking it redirects to the wrong (physical) page on the PDF. I have tried it with multiple PDF viewers as well. Here's an MWE:
\documentclass{book}
\usepackage{blindtext}
\usepackage{makeidx}
\makeindex
\usepackage{hyperref}
\begin{document}
Thesis Name
\cleardoublepage
\pagenumbering{roman}
University Name
\cleardoublepage
\tableofcontents
\cleardoublepage
\pagenumbering{arabic}
\chapter{Chapter Title}
\blindtext[5]
\section{A Long Section}
\blindtext[2]\\
Some Indexed Definition\index{definition!type one}\\
\blindtext[5]\\
Another Indexed Definition\index{definition!type two}\\
\blindtext[4]\\
\printindex
\end{document}
The issue is identical to the question posted here. However the solution doesn't work for me : I have tried using \usepackage[hypertexnames=true]{hyperref}
, but the issue persists.
I understand that this is happening because of the two \pagenumbering{}
commands. Indeed, if I comment them out, both the page number and the physical page it points to work fine. But what baffles me is that the makeidx
package knows the correct page number, and yet it seems hyperref
doesn't know it!
The same thing happens in the bibliography, with backref=page
option added to the hyperref
package (not shown in the MWE).
Any help regarding this is appreciated. Cheers!