8

As far as I know, there is no way to globally set-up the bookmark options for sections only. If I am wrong, what is the correct way to have sections (only) with respective blue bookmarks? It can be done manually but it is quite tedious.

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{times}
\usepackage{bookmark}
\begin{document}
\bookmarksetup{level=section,bold,color=blue}
\chapter{chapter}
\section{section}
\end{document} 

The level=section option above is wrong but somehow describes what should be achieved: blue section bookmarks.

pluton
  • 16,421
  • I'm assuming you're using hyperref? Also, what specifically do you mean with "globally set-up the bookmark options for sections only"? Perhaps you can add a mock-up done with Word? – doncherry Sep 30 '12 at 01:45

1 Answers1

17

Option addtohook of package bookmark helps:

\documentclass{article}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage{bookmark}[2010/04/03]
\bookmarksetup{
  open,
  numbered,
  addtohook={%
    \ifnum\bookmarkget{level}=1 % section=1, subsection=2, ...
      \bookmarksetup{color=blue}%
    \fi
  },
}

\begin{document}
\addcontentsline{toc}{section}{\contentsname}
\tableofcontents
\part{First part}
\section{Hello World}
\subsection{Subsection A}
\section{Next section}
\subsection{Subsection B}
\end{document}

Bookmarks

Heiko Oberdiek
  • 271,626