将章节书签分组到单独添加的书签中

将章节书签分组到单独添加的书签中

我正在设计一本目录详尽的书。我想保留目录原样,但想通过将章节分组在一起,使 PDF 中的书签不那么繁琐。

梅威瑟:

\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} 

因此,我想在这里将名为“January”和“February”的书签添加到生成的 PDF 中(但不添加到目录中)。然后,这些附加书签需要默认未打开,所有单独的一月和二月章节都按顺序排列。我该如何实现这一点?

答案1

使用当前的 hyperref 您可以这样做(当前的 latex 中不再需要 inputenc,无论如何,几年来 utf8 一直是默认设置):

\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} 

在此处输入图片描述

在旧系统上,您必须手动创建目标:

\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} 

相关内容