9

Since update of TeXLive, both on macOS and Ubuntu (from 12.04 to 13.04), index is not referenced correctly in the table of content. Instead, the hyperlink to Index point to the bibliography.

A lot of question are related to the hyperlink problem with index, but since mine seems a bit different, I post a new question. I emphasize the fact that this worked correctly with previous version of TeXlive (prior to 2010) which suggest that some modification in between are causing this problem.

Here is a minimal example :

\documentclass[a4paper]{report}
\usepackage{makeidx} 
\usepackage{tocbibind}
\usepackage{hyperref}
\makeindex
\begin{document}
\tableofcontents

test\index{test}

\begin{thebibliography}{1}
  \bibitem{test} Test, 2013.
\end{thebibliography}

\printindex
\end{document}
Autiwa
  • 193
  • 5
  • Interestingly, it seems that no packages used by the MWE above have been changed since 2012! – daleif Oct 15 '13 at 08:29
  • 1
    I just tested using TL12 frozen. The MWE does not work there either. So it might be a question of then this actually worked. – daleif Oct 15 '13 at 08:31
  • 1
    Even more strange, it works if report is replaced by article!?! – daleif Oct 15 '13 at 08:40
  • Maybe then it worked in TeXlive 2011. The point is, it worked in Ubuntu 12.04.3, with all updates. Maybe it was the 2011 tex live packckage that was used. – Autiwa Oct 16 '13 at 07:32

4 Answers4

13

hyperref patches (in hypertex.def) \@schapter (the command used by \chapter*) to insert anchors and so

 \chapter*{blub}
 \addcontentsline...

works as wanted and gives correct links.

But tocbibind redefines the index and doesn't use \chapter* or \@schapter for the title but only \@makeschapterhead and so the anchors are missing. I don't think that it ever worked.

You will have to insert the anchor yourself:

\clearpage
\phantomsection
\printindex

Or use a class like scrreprt which uses \@schapter in this case.

Ulrike Fischer
  • 327,261
  • It worked, I'm sure of it. Maybe not in TL2012, according to daleif, but maybe in TL2011.

    I will implement your solution just to make it work, but I think there's a problem behind it that should be solved in the futur, either in tocbibind, hyperref or makeidx. So far I don't even know were I should report it, since I don't know from what package it comes from.

    Thank you !

    – Autiwa Oct 16 '13 at 07:39
  • 1
    It worked in TL08, but not in TL09,10,11,12 and 13. – daleif Oct 16 '13 at 08:24
  • 1
    Perhaps it is an idea that Will add some \phantomsection's to tocbibind (in the same manner as memoir does). I'll send him an email. – daleif Oct 16 '13 at 08:25
4

With imakeidx the link is correct, but it's necessary either to load tocbibind before it, or it will override the changes made by imakeidx for getting the Index in the table of contents with a correct link.

\documentclass[a4paper]{report}

\usepackage{tocbibind}
\usepackage{imakeidx}
\usepackage{hyperref}

\makeindex[intoc]

\begin{document}
\tableofcontents

test\index{test}

\begin{thebibliography}{1}
  \bibitem{test} Test, 2013.
\end{thebibliography}

\printindex

\end{document}
egreg
  • 1,121,712
2

Not an answer, just a comment that is better formatted here. Bibtex is not relevant

\documentclass[a4paper]{report}
\usepackage{makeidx} 
\usepackage{tocbibind}
\usepackage{hyperref}
\makeindex
\begin{document}
\tableofcontents

test\index{test}

\begin{thebibliography}{1}
  \bibitem{test} Test, 2013.
\end{thebibliography}

\printindex
\end{document}
daleif
  • 54,450
1

This issue applies to both report and book classes, while leaving the article class intact (since chapters are not defined there). A simple workaround using \clearpage, \phantomsection, \printindex will link the index entry (in the table of contents) to the correct page, but the link appears to systematically take you to somewhere slightly below the title of the index page - which is unlike how it works with list of figures, list of tables, bibliography and all the sectional units.

In fact, testing with the KOMA classes scrreprt and scrbook leads to the same result of linking index to the right page but slightly-incorrect position. As alluded to by egreg, using imakeidx to override tocbibind's setting fixes the problem altogether, but then this suggests a bug in the tocbibind package, perhaps the fact that \printindex isn't loaded by creating a chapter.