How to explicitly end a \part in LaTeX with hyperref

Richard picture Richard · Sep 27, 2009 · Viewed 14.5k times · Source

I have a LaTeX document which contains the following:

\tableofcontents
\chapter{Chapter One}
\part{Part One}
...
\part{Final Part}
\chapter{Final Part Chapters}
\chapter{Chapter not Part of Part}

When I compile this to a PDF with hyperref, the last chapter is included as part of the final part in my bookmarks. (I'm including hyperref as shown below.)

\usepackage[xetex,breaklinks,a4paper]{hyperref}

What I would like to know is how to explicitly end the part before the final chapter, so that hyperref promotes this bookmark to top level when the PDF is created.

Any help would be appreciated.

Answer

Will Robertson picture Will Robertson · Sep 28, 2009

Heiko Oberdiek's bookmark package (an improvement on his work in hyperref) allows you do to this with its \bookmarksetup command.

\documentclass{book}
\usepackage{bookmark,hyperref}
\begin{document}
\tableofcontents
\chapter{Chapter One}
\part{Part One}
\part{Final Part}
\chapter{Final Part Chapters}

\bookmarksetup{startatroot}% this is it
\addtocontents{toc}{\bigskip}% perhaps as well

\chapter{Chapter not Part of Part}
\end{document}

The \bigskip parts adds a little space in the printed table of contents to visually separate the final chapter from the preceding "part".