2

I want to colorize my bookmarks in this way. Is there any chance to do this with the hyperref package? Thanks.

enter image description here

1
  • Yes, it is possible, using bookmark package
    – user31729
    Nov 15, 2015 at 21:23

2 Answers 2

2

One way is to use the \bookmark command and its color= option. However, hyperref adds automatically bookmarks unless the tocdepth is smaller than -1, so using \bookmark would double the entries.

Setting tocdepth to -2 temporarilywill disable this, use\bookmarkthen with a destination and use the the relevant sectioning command then (or whatever should be bookmarked),after that set thetocdepth` to another value again to provided the automatically generated bookmarks.

\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
  • thanks. how can i change the color of a specific bookmark (e.g. make all chapters blue or only bibliography red)?
    – Jaska
    Nov 15, 2015 at 21:47
  • @Jaska: Use color=red for example and the bookmarkdefinestyle command -- please look into the bookmark manual.
    – user31729
    Nov 15, 2015 at 21:48
2

Inserting this in your preamble works fine:

\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}}}
1
  • Perhaps a hint to the manual as I gave you in my answer would be useful.
    – user31729
    Nov 16, 2015 at 10:14

You must log in to answer this question.

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