[Tex/LaTex] Add PDF bookmark manually

bookmarkspdfpdftex

I would like to add a bookmark to the table of contents. This page shows a method, but \pdfbookmark is not recognised as a command. This is my document header:

\documentclass[a4paper]{report}
\usepackage[pdftex,bookmarks=true]{hyperref}
\usepackage[pdftex]{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{array}

I'm compiling the document with TexMakerX's PDFLaTeX option.

Best Answer

This works for me.

\documentclass[a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{array}

\usepackage[bookmarks=true]{hyperref}
\usepackage{bookmark}

\begin{document}

\cleardoublepage
\pdfbookmark{\contentsname}{Contents}
\tableofcontents

\chapter{P}
Some text
\end{document}

Notice that the pdftex options should not be used, as it is supplied automatically when the LaTeX engine used is pdftex. Moreover hyperref should generally be loaded last, with some exception; one of the exceptions is bookmark that eases bookmark management (and is not strictly necessary).

The \cleardoublepage is redundant in the example, but is necessary if some copy precedes the table of contents to ensure the correct correspondence of the bookmark with the text.