# How to get hyperref to link to the index

I am trying to get hyperref link to the actual page that the index starts. It follows the Bibliography by several pages, but when you click on Index in the TOC, you are taken to the first page of the bibliography. The option hyperindex makes the index entries linkable and that is very nice, but the title Index is supplied by \printindex and I have not been able to figure out to modify it.

The way I get the link to the Biblio is

\chapter*{Bibliography}


Sample file:

\documentclass{book}
\usepackage{index,multicol}
\usepackage[nosort,nocompress]{cite}
\usepackage[hyperindex]{hyperref}
\makeindex
\begin{document}
\tableofcontents
\chapter*{Preface}
This is a very brief preface.
\chapter{This is the first chapter}
\section{Here is the first section}
Here we have Section 1 \index{Section 1}
Here is a bibliographical reference \cite{Kn1,Kn2}.
\section{Here is the second section}
Here is Section 2 \index{section 2}
\begin{thebibliography}{Kn2}
\bibitem{Kn1}D.E. Knuth, AOCP 1
\bibitem{Kn2}D.E. Knuth, AOCP 2
\end{thebibliography}
\printindex
\end{document}


Note that in the real book, adding \addtocontentsline after the \printindex would put the pointer in the wrong place.

• Show a small complete example. That makes it much easier to test your issue. – Ulrike Fischer Apr 1 '20 at 18:58
• It would be easier to understand what you wanted if you added minimal working example to show what you are doing: without code that exhibits your problem we have to guess what you are doing, which makes it much harder to help. A MWE should start with a \documentclass statement, compile and be as small as possible to demonstrate your problem. – user30471 Apr 1 '20 at 19:04
• Does the listing of "Index" in the TOC show the correct starting page number? – barbara beeton Apr 1 '20 at 19:58
• To Barbara: Yes, the TOC is correct. – Michael Barr Apr 1 '20 at 21:16
• You probably need a \phantomsection (page 32). – John Kormylo Apr 2 '20 at 4:05

You need to add a \phantomsection as anchor, if the relevant command doesn't do this internally. In your case I would suggest to use imakeidx and tocbibind, to simplify the code:

\documentclass{book}
\usepackage{tocbibind}
\usepackage{imakeidx}
\usepackage[nosort,nocompress]{cite}
\usepackage[hyperindex]{hyperref}

\makeindex[intoc]

\begin{document}
\tableofcontents
\cleardoublepage\phantomsection
\chapter*{Preface}
This is a very brief preface.
\chapter{This is the first chapter}
\section{Here is the first section}
Here we have Section 1 \index{Section 1}
Here is a bibliographical reference \cite{Kn1,Kn2}.
\section{Here is the second section}
Here is Section 2 \index{section 2}
\begin{thebibliography}{Kn2}
\bibitem{Kn1}D.E. Knuth, AOCP 1
\bibitem{Kn2}D.E. Knuth, AOCP 2
\end{thebibliography}

\printindex
\end{document}

• That works fine for the sample file, but didn't for the real one. I had to make a number of changes to accommodate the real homespun class file and then ended with "Index" appearing twice in the TOC, one with the correct link and one without and have finally decided it just is not worth the effort. – Michael Barr Apr 3 '20 at 20:37