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:
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
.
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}
:
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.