Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to explicitly end a \part in LaTeX with hyperref

Tags:

latex

hyperref

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.

like image 479
Richard Avatar asked Sep 27 '09 11:09

Richard


People also ask

How do you end a chapter in LaTeX?

By default, your LaTeX document has Chapter name (Chapter 1, Chapter 2, etc.) for each chapter. If you want to remove such chapter name from your document, then you can use titlesec package and define the titleformat in order to hide the chapter title.

How do you link a section in LaTeX?

Setting hyperlinks in LaTeX is easy with the hyperref package. Link to any website or add your email address to any document. Adding clickable links to LaTeX documents is very straightforward, you only have to add the hyperref package to your preamble.

How do I make a link clickable in LaTeX?

How Do You Hyperlink in Latex? You can add a hyperlink into your LaTeX article using the command \usepackage{hyperref} and then including the command \href{YOUR URL}{TEXT FOR YOUR HYPERLINK}.

How do you add a URL to overleaf?

Links to a web address or email can added to a LaTeX file using the \url command to display the actual link or \href to use a hidden link and show a word/sentence instead. There are two commands in the example that generate a link in the final document: \href{http://www.overleaf.com}{Something Linky}


1 Answers

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".

like image 50
Will Robertson Avatar answered Sep 20 '22 20:09

Will Robertson