2

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!

1 Answer 1

1

The problem is in the two pages before \pagenumbering{roman}. Usually the (internal) frontispiece is numbered like the front matter.

If you insist to start numbering after the “Thesis name”, issue

\pagenumbering{Alph}
\pagestyle{empty}

at the beginning and restore \pagestyle{headings} after \frontmatter, which is better than issuing \cleardoublepage\pagenumbering{roman}.

\documentclass{book}

\usepackage{blindtext}

\usepackage{makeidx}
\makeindex

\usepackage{hyperref}

\begin{document}

\pagenumbering{Alph}
\pagestyle{empty}

Thesis Name

\frontmatter
\pagestyle{headings}

University Name

\tableofcontents

\mainmatter

\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}
1
  • 1
    The template that I am using has \frontpage, \coverpage etc defined, with \thispagestyle{empty} in the definition. I didn't add it to the MWE since I thought that was not the problem! In any case, I solved the issue by putting \pagenumbering{roman} at the very beginning and \pagenumbering{arabic} just before \mainmatter.
    – ChesterX
    May 31, 2021 at 14:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .