4

I am finishing a document with a bunch of "front matter" sections and then several chapters. For the PDF bookmarks, I would like to have "Front Matter" as a top-level bookmark (like chapters) and then these things like abstract, acknowledgements, TOC, etc. as nested bookmarks under that one. I have it mostly working with a setup like this:

\documentclass{report}
\usepackage{hyperref}

\title{My document}
\author{Myself}

\begin{document}
% Top-level front matter bookmark
\pdfbookmark[0]{Front Matter}{frontmatter}
\maketitle
% Abstract bookmark
\pdfbookmark[1]{\abstractname}{abstract}
\begin{abstract}
The abstract
\end{abstract}
% TOC bookmark
\pdfbookmark[1]{\contentsname}{toc}
\tableofcontents
% List of figures bookmark
\addcontentsline{toc}{section}{\listfigurename}
\listoffigures
% List of tables bookmark
\addcontentsline{toc}{section}{\listtablename}
\listoftables
% Chapters
\chapter{Chapter 1}
\chapter{Chapter 2}
\end{document}

This gives me the bookmarks layout that I want in the PDF:

PDF bookmarks layout

But the problem is that then the list of figures and the list of tables show up as second-level items in the TOC, because indeed I added them as section with \addcontentsline, not as chapter.

Wrong table of contents

I would like them to show up as top-level elements, which I can do if I use \addcontentsline{toc}{chapter}{\listfigurename} and \addcontentsline{toc}{chapter}{\listtablename}:

Correct table of contents

But then of course the bookmarks layout is wrong, showing the list of figures and the list of tables as top-level elements.

Is there anyway to select a different bookmark level for a TOC entry? Or, more likely, to create a TOC entry without generating a PDF bookmark, so I can then add the bookmark myself at the level I prefer with \pdfbookmark? I have the impression the command \addtocontents might help, but I do not really understand how it is supposed to be used.

Note: I am aware that I could use the package tocbibind to add the list of figures and the list of tables to the TOC, I was in fact using it initially but I am doing it "by hand" now precisely because I am trying to solve this issue.

1 Answer 1

4

You can use the package bookmark, the option startatroot resets the hierarchy after the frontmatter:

\documentclass{report}
\usepackage{hyperref}
\usepackage{bookmark}

\title{My document}
\author{Myself}

\begin{document}
% Top-level front matter bookmark
\pdfbookmark[-1]{Front Matter}{frontmatter}
\maketitle
% Abstract bookmark
\pdfbookmark[0]{\abstractname}{abstract}
\begin{abstract}
The abstract
\end{abstract}
% TOC bookmark
\pdfbookmark[0]{\contentsname}{toc}
\tableofcontents
% List of figures bookmark
\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures
% List of tables bookmark
\addcontentsline{toc}{chapter}{\listtablename}
\listoftables
% Chapters
\bookmarksetup{startatroot}

\chapter{Chapter 1}
\chapter{Chapter 2}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .