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
  • 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). Commented Jun 2, 2016 at 6:30

1 Answer 1

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}
1
  • Oh, I didn't even know the loading order of packaged mattered! Thanks for the explanation!
    – PHPirate
    Commented Jun 2, 2016 at 6:55

You must log in to answer this question.

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