9

I'm having troubles making Index visible in the navigation that is shown with the pdf preview of the document. Namely, the following is the end of my main .tex file:

% Bibliography
% =================================================================
\bibliographystyle{plainnat}
\bibliography{refs}
\addcontentsline{toc}{chapter}{Bibliography}
% =================================================================

\printindex
\addcontentsline{toc}{chapter}{Index}

This indeed show Index in the navigation, but it actually points to bibliography. Exchanging places of \printindex and \addcontentsline removes Index from the navigation. How could I achieve precise navigation to Index?

10

When LaTeX sees your \addcontentsline command, it has already finished typesetting the index. So if this is longer than one page, the reference to the page number will be wrong. Do

\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{\indexname}
\printindex

or try the package tocbibind which will add the entry automatically (also for the bibliography and, by default, the Table of Contents itself):

\usepackage[nottoc]{tocbibind} % nottoc will exclude the toc

Alternatively you can use

\usepackage{imakeidx}
\makeindex[intoc]

instead of \usepackage{makeidx}\makeindex. This will also balance the last page in the index. Remember to call hyperref after imakeidx.

  • 4
    @boy If I weren't the author of imakeidx I'd use the second: simple and effective. – egreg Jun 12 '12 at 20:40
  • \usepackage[nottoc]{tocbibind} produce right pagenumber, but the link is made to the last chapter... – Anton Petrunin Feb 6 '13 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.