[Tex/LaTex] Customize PDF bookmarks

bookmarkshyperrefpdf

I have the following document (this is an example):

\documentclass{book}

\usepackage[bookmarks=true,pdfborder={0 0 0}]{hyperref}

\title{Sample document}

\begin{document}

\thispagestyle{empty}
\maketitle
\thispagestyle{empty}
\frontmatter

\pagestyle{plain} 
\tableofcontents

\mainmatter
\part{My first part}
\chapter{A chapter}
\section{First section}
A text...
\chapter{Other chapter}
Other text...

\part{My second part}
\chapter{Another chapter}
Yet another text...

\end{document}

And the PDF bookmarks that is being produced do not satisfy my needs. I needed:

  • A root node "Sample document" pointing to the begining of first page of the document (title page)
  • Contents page (TOC) appearing like one document part on bookmarks (but not in TOC, I don't want it to appear in TOC, only in Bookmarks)
  • Instead of "I My first part" I wanted "Part I: My first part" and so on to the other parts
  • Instead of "A chapter" I wanted "1 A chapter", instead of "Other chapter" I wanted "2 Another Chapter" and so on
  • The section would continue to appear as it currently does on bookmarks, with no numbers, only its title

How can I do that?

Best Answer

You could use the bookmark package. For example:

\usepackage[numbered]{bookmark}

causes numbered bookmarks, such as the desired 2 Other chapter.

\bookmark[page=1,level=0]{Sample document}

At the beginning gives you the desired first bookmark. It offers many more features described in the documentation. Just follow the link above to CTAN or type texdoc bookmark at the command prompt.

Related Question