Hyperref – Grouping Chapter Bookmarks into Separate Added Bookmark

bookmarkshyperrefscrbook

I'm designing a book with an elaborate ToC. I'd like to keep the ToC the way it is, but would like to make the bookmarks in the PDF a little less overwhelming, by grouping chapter together.

MWE:

\usepackage[utf8]{inputenc}
\usepackage[hidelinks, bookmarksopen=false]{hyperref}
\usepackage{bookmark}

\title{Question PDF bookmarks}
\author{Alex Dijk}
\date{April 2022}

\begin{document}

\chapter{1 jan}First January lecture
\chapter{2 jan}Another January lecture
\chapter{3 jan}Another January lecture
\chapter{4 jan}Another January lecture
\chapter{5 jan}Another January lecture
\chapter{6 jan}Another January lecture
\chapter{7 jan}Another January lecture
\chapter{8 jan}Another January lecture
\chapter{1 feb}First February lecture
\chapter{2 feb}Another February lecture
\chapter{3 feb}Another February lecture
\chapter{4 feb}Another February lecture
\chapter{5 feb}Another February lecture
\chapter{6 feb}Another February lecture
\chapter{7 feb}Another February lecture
\chapter{8 feb}Another February lecture

\end{document} 

So here, I would like to add bookmarks called 'January' and 'February' to the resulting PDF (but not to the ToC). These additional bookmarks then need to be unopened by default, under which all of the individual January and February chapters are ordered. How do I accomplish this?

Best Answer

With a current hyperref you can do this (inputenc is no longer needed in a current latex, utf8 is the default since a few years anyway):

\documentclass{book}
\usepackage[hidelinks, bookmarksopen=false]{hyperref}
\usepackage{bookmark}

\title{Question PDF bookmarks}
\author{Alex Dijk}
\date{April 2022}

\begin{document}

\bookmark[level=part,dest=\hyperget{anchor}{chap:jan}]{January}
\chapter{1 jan}\label{chap:jan}First January lecture
\chapter{2 jan}Another January lecture
\chapter{3 jan}Another January lecture
\chapter{4 jan}Another January lecture
\chapter{5 jan}Another January lecture
\chapter{6 jan}Another January lecture
\chapter{7 jan}Another January lecture
\chapter{8 jan}Another January lecture
\cleardoublepage
\bookmark[level=part,dest=\hyperget{anchor}{chap:feb}]{February}
\chapter{1 feb}\label{chap:feb}First February lecture
\chapter{2 feb}Another February lecture
\chapter{3 feb}Another February lecture
\chapter{4 feb}Another February lecture
\chapter{5 feb}Another February lecture
\chapter{6 feb}Another February lecture
\chapter{7 feb}Another February lecture
\chapter{8 feb}Another February lecture

\end{document} 

enter image description here

On older systems you must create targets manually:

\documentclass{book}
\usepackage[hidelinks, bookmarksopen=false]{hyperref}
\usepackage{bookmark}

\title{Question PDF bookmarks}
\author{Alex Dijk}
\date{April 2022}

\begin{document}

\hypertarget{jan}{}
\bookmark[level=part,dest=jan]{January}
\chapter{1 jan}First January lecture
\chapter{2 jan}Another January lecture
\chapter{3 jan}Another January lecture
\chapter{4 jan}Another January lecture
\chapter{5 jan}Another January lecture
\chapter{6 jan}Another January lecture
\chapter{7 jan}Another January lecture
\chapter{8 jan}Another January lecture
\cleardoublepage
\hypertarget{feb}{}
\bookmark[level=part,dest=feb]{February}
\chapter{1 feb}\label{chap:feb}First February lecture
\chapter{2 feb}Another February lecture
\chapter{3 feb}Another February lecture
\chapter{4 feb}Another February lecture
\chapter{5 feb}Another February lecture
\chapter{6 feb}Another February lecture
\chapter{7 feb}Another February lecture
\chapter{8 feb}Another February lecture

\end{document} 
Related Question