Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
2  
Welcome to TeX.sx! Please add a full but minimal working example (MWE) that illustrates your problem. –  Martin Scharrer Jan 16 '12 at 13:19
add comment

2 Answers

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.

share|improve this answer
add comment

The bookmark package seems to be a powerful and customizable solution, but for most (of my) applications, one usually needs to add the bookmark at or below the current level. For this it is sufficient to use what hyperref provides, namely \belowpdfbookmark{text}{name} and \subpdfbookmark{text}{name}.

As described here: http://ftp.math.purdue.edu/mirrors/ctan.org/macros/latex/contrib/hyperref/doc/manual.html#x1-150004.1

share|improve this answer
2  
Loading the package bookmark has also the advantage, that the bookmarks are faster uptodate, often one run is sufficient, hyperref needs two runs. –  Heiko Oberdiek Oct 31 '12 at 9:21
    
@HeikoOberdiek, good to know. Do you mean that you need a smaller number of compilation? I think I noticed that. Is this true even if you use the plain hyperref commands? –  alfC Oct 31 '12 at 14:27
    
Yes (and more text to make a comment). –  Heiko Oberdiek Oct 31 '12 at 14:29
    
I found it useful to use both \belowpdfbookmark{text}{contents} and \pdfbookmark{other text}{contents} -- without this, having two \pdfbookmarks in my text was causing both of them to be listed on "page 1". –  Joe Corneli Aug 18 '13 at 18:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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