答案1
一种方法是使用\bookmark
命令及其color=
选项。但是,除非小于,hyperref
否则会自动添加书签,因此使用会使条目数加倍。tocdepth
-1
\bookmark
tocdepth
再次将-2
临时will disable this, use
\bookmark tocdepth`设置then with a destination and use the the relevant sectioning command then (or whatever should be bookmarked),after that set the
为另一个值,以提供自动生成的书签。
\documentclass{book}
\usepackage{xcolor}
\usepackage[bookmarksopen=true]{hyperref}
\usepackage{bookmark}
\begin{document}
\tableofcontents
\setcounter{tocdepth}{-2}
\bookmark[level=0,dest=chap:here,color=blue]{A chapter}
\chapter{A chapter}\hypertarget{chap:here}{}
\setcounter{tocdepth}{2}
\section{Another level}
\end{document}
答案2
将其插入到您的序言中效果很好:
\usepackage{bookmark}
\bookmarkdefinestyle{TheStyleOfTheBookmark0}{color=blue} % Farbe Bookmark Chapter
\bookmarkdefinestyle{TheStyleOfTheBookmark1}{color=green} % Farbe Bookmark Section
\bookmarkdefinestyle{TheStyleOfTheBookmark2}{color=red} % Farbe Bookmark Subsection
\bookmarkdefinestyle{TheStyleOfTheBookmark3}{color=black} % Farbe Bookmark Subsubsection
\bookmarksetup{open,addtohook=\bookmarksetup{style=TheStyleOfTheBookmark\bookmarkget{level}}}