4

I loaded both the bookmark and hyperref package, but when I have them both the index links don't work. When I comment out the bookmark package the index links work, but the bookmarks don't. How do I fix this?

Minimal Not Working Example:

\documentclass{article}
\usepackage{lipsum}

\usepackage{bookmark} % Used for pdf bookmarks
\usepackage{imakeidx} % Used for index
\usepackage{hyperref} % Used for index links

\makeindex

\begin{document}
    \section{foo}
    \lipsum[1]
    \index{foo}
    \section{bar}
    \index{bar}
    \lipsum[2]

    \printindex
\end{document}
  • 1
    Load bookmark after imakeidx, also you don't have to load hyperref, bookmark will do it. If you want to load hyperref to pass an option do it before bookmark (but again after imakeidx). – Ulrike Fischer Jun 2 '16 at 6:30
4

The bookmark package is designed to fix a few features of hyperref; although the documentation doesn't tell it explicitly, it should be loaded after hyperref.

Actually, bookmark loads hyperref itself, if not already done. Since hyperref changes the meaning of \index, it should be loaded later than imakeidx for hyperlinks to be added to index entries.

So the correct loading order is

\usepackage{imakeidx}
\usepackage{hyperref}
\usepackage{bookmark}
  • Oh, I didn't even know the loading order of packaged mattered! Thanks for the explanation! – PHPirate Jun 2 '16 at 6:55

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.