1

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

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.