# ToC pdf bookmark missplaced anchor

I want to add the table of contents to the bookmarks to facilitate navigation in the pdf. I managed to do so but the behaviour of said bookmark is inconsistant with the others as it anchors below the title of the toc and not directly to it (i.e. The "Contents" title is masked, only displaying the actual content of the ToC).

Any way to fix that?

### MWE

\documentclass{article}
\usepackage{mwe}
\usepackage{bookmark}
\begin{document}
\tableofcontents
\blinddocument
\end{document}

• Is \usepackage{tocbibind} working for you instead of using \addtocontents?
– user31729
Sep 21 '17 at 9:19
• @ChristianHupfer It does indeed work but it also adds a line for Contents in the ToC which I would like to avoid. Sep 21 '17 at 9:43

This inserts the bookmark and the relevant hypertarget such that it jumps to Contents, i.e. the heading of the Contents page.

\documentclass{article}
\usepackage{mwe}
\usepackage{bookmark}
\begin{document}
\pdfbookmark[section]{\contentsname}{toc}
\tableofcontents
\blinddocument
\end{document}


Another solution: Use etoolbox and \preto in order to prepend code to \tableofcontents.

\documentclass{article}
\usepackage{mwe}
\usepackage{etoolbox}
\usepackage{bookmark}

\preto{\tableofcontents}{\pdfbookmark[section]{\contentsname}{toc}}
\begin{document}
\tableofcontents
\blinddocument
\end{document}

• It does work as intended, but it requires the statement to be passed after the beginning of the document which I would prefer to avoid. I am trying to develop a framework for documents which I include in the preamble. Any way to circumvent that? Sep 21 '17 at 9:52
• @Florian: Did you specify that in your question? ;-) No, you didn't.
– user31729
Sep 21 '17 at 9:54
• Yes, your answer is correct as I stated. I was just wondering if you knew another way. Sep 21 '17 at 9:56
• @Florian: See the edit
– user31729
Sep 21 '17 at 9:59
• Thank you so much. I had similar issues with other commands and this is going to solve a lot them. Sep 21 '17 at 11:16