3

I would like to highlight all chapters except the appendix, table of figures and table of tables. I'm using the bookmark-package and I tried to set all entries at the level = 0 to bold and just to turn bold off for the LoF etc. but it seems it has no effect to turn bold off.

enter image description here

\documentclass[listof=totoc]{scrreprt}

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


\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{mwe}

\begin{document}
\pdfbookmark[0]{Content}{toc}
\tableofcontents 
\bookmarksetupnext{bold=false}
\listoffigures  
\newpage

\chapter{Chapter 1}
\lipsum[1]
\begin{figure}[h]
\includegraphics[width=\textwidth]{example-image-a}
\caption{I am a figure\label{fig:one}}
\end{figure}
\section{Section 1}
\lipsum[1]
\begin{figure}[h]
\includegraphics[width=\textwidth]{example-image-a}
\caption{I am a figure\label{fig:one}}
\end{figure}

\bookmarksetupnext{bold=false}
\appendix
\addtocontents{toc}{\protect\contentsline {chapter}{Appendix}{}{}}
\chapter{App 1}
\lipsum[1]
\end{document}
  • As I read the documentation, the hook is executed after any options passed to \bookmark. So I assume that bold is switched off but then it is switched on again. However, none of the bookmarks are formatted in bold type in my PDF viewer, so I guess the effects may be Adobe-specific or something. – cfr Aug 31 '15 at 23:43
3

You can provide an additional toggle (or conditional) that is used in your hook. Below I defined \ifboldPDFchapters that you can switch depending on what you need, and added the conditional to the hook:

\usepackage{bookmark}

\newif\ifboldPDFchapters

\bookmarksetup{
  open,
  addtohook={%
    \ifnum\bookmarkget{level}=0 %
      \ifboldPDFchapters
        \bookmarksetup{bold}%
      \fi
    \fi
  }
}

Adding \boldPDFchapterstrue to your document will ensure that all level-0 elements following will be set in bold. \boldPDFchaptersfalse will remove this setting.

enter image description here

\documentclass[listof=totoc]{scrreprt}

\usepackage{bookmark}

\newif\ifboldPDFchapters

\bookmarksetup{
  open,
  addtohook={%
    \ifnum\bookmarkget{level}=0 %
      \ifboldPDFchapters
        \bookmarksetup{bold}%
      \fi
    \fi
  }
}

\begin{document}

\boldPDFchapterstrue
\pdfbookmark[0]{Content}{toc}
\tableofcontents 

\boldPDFchaptersfalse
\listoffigures  

\boldPDFchapterstrue
\chapter{Chapter 1}
\begin{figure} \caption{I am a figure} \end{figure}
\section{Section 1}
\begin{figure} \caption{I am a figure} \end{figure}

\boldPDFchaptersfalse
\appendix
\addtocontents{toc}{\protect\contentsline {chapter}{Appendix}{}{}}
\chapter{App 1}

\end{document}

It would be possible to incorporate these settings as part of the document commands themselves:

\newif\ifboldPDFchapters
\boldPDFchapterstrue% All chapter (level 0) bookmarks are BOLD

\bookmarksetup{
  open,
  addtohook={%
    \ifnum\bookmarkget{level}=0 %
      \ifboldPDFchapters
        \bookmarksetup{bold}%
      \fi
    \fi
  }
}

\let\oldtableofcontents\tableofcontents
% ToC bookmark is BOLD
\renewcommand{\tableofcontents}{{\boldPDFchapterstrue\oldtableofcontents}}
\let\oldlistoffigures\listoffigures
% LoF bookmark is NOT BOLD
\renewcommand{\listoffigures}{{\boldPDFchaptersfalse\oldlistoffigures}}
% Appendix onward has chapter bookmarks NOT BOLD
\let\oldappendix\appendix
\renewcommand{\appendix}{\oldappendix\boldPDFchaptersfalse}

This allows you to set your document as-is, without any use of switches, or temporary/mid-document changes.

|improve this answer|||||
3

The idea is correct using addtohook and \bookmarksetupnext. However, bold=false of \bookmarksetupnext is overwritten by the hook. Therefore \bookmarksetupnext must also use the hook:

\documentclass[listof=totoc]{scrreprt}

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

\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{mwe}

\begin{document}
\pdfbookmark[0]{Content}{toc}
\tableofcontents
\bookmarksetupnext{addtohook=\bookmarksetup{bold=false}}
\listoffigures
\newpage

\chapter{Chapter 1}
\lipsum[1]
\begin{figure}[h]
\includegraphics[width=\textwidth]{example-image-a}
\caption{I am a figure\label{fig:one}}
\end{figure}
\section{Section 1}
\lipsum[1]
\begin{figure}[h]
\includegraphics[width=\textwidth]{example-image-a}
\caption{I am a figure\label{fig:two}}
\end{figure}

\bookmarksetupnext{addtohook=\bookmarksetup{bold=false}}
\appendix
\addtocontents{toc}{\protect\contentsline {chapter}{Appendix}{}{}}
\chapter{App 1}
\lipsum[1]
\end{document}

Result

|improve this answer|||||

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.