5

This is a follow-up question to PDF bookmark customization

How is it possible, to set in an report/scrreprt all chapters with bold bookmarks in the pdf bookmarks? I've found a discussion about it (in german: renewcommand chapter), however, the MWE from there is not compiling with pdflatex (TeX Live 2012)

\documentclass{scrbook}
\usepackage[ngerman]{babel}
\usepackage{blindtext}
\usepackage[pdftex]{hyperref}
\usepackage[pdftex,open=true]{bookmark}
\makeatletter

\renewcommand{\@chapter}{}
\let\@chapter\chapter

\renewcommand{\chapter}{%
\@ifstar {\@chapter}{\@dblarg\@chapter}%
}
\newcommand*{\@chapter}[2][]{%
\bookmarksetup{bold=true}%
\@chapter[#1]{#2}%
\bookmarksetup{bold=false}%
}

\makeatother

\begin{document}
\tableofcontents
\chapter{Einleitung}
\section{Test}
\blindtext
\chapter[Kurze Überschrift]{Lange Überschrift}
\section{foobar}
\blindtext
\end{document}

1 Answer 1

3

Option addtohook helps:

\usepackage{bookmark}
\bookmarksetup{
  open,
  addtohook={%
    \ifnum\bookmarkget{level}<1 %
      \bookmarksetup{bold}%
    \fi
  },
}

Some remarks:

  • pdfTeX in PDF mode is detected automatically by hyperref and bookmark.
  • I have put option open in \bookmarksetup. This way \usepackage{bookmark} do not need options (reducing option clash conflicts).

You must log in to answer this question.

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