1

Using bookmarksopen option for hyperref, the tree of bookmarks is automatically expanded.

I'm curious how can I collapse one specific item (chapter, section etc.)? Maybe there's a command like \CloseNextBookmark?

enter image description here

\documentclass{book}
\usepackage{hyperref}
\hypersetup{bookmarksopen}

\begin{document}

\chapter{first}
\section{one}
\section{two}
\section{three}

\chapter{second}
\section{foo}
\section{bar}
\section{baz}

\chapter{third}
\section{1}
\section{2}
\section{3}

\end{document}

1 Answer 1

2

You can change the level in the document:

\documentclass{book}
\usepackage{hyperref}
\hypersetup{bookmarksopen}

\begin{document}

\chapter{first}
\section{one}
\section{two}
\section{three}

\hypersetup{bookmarksopenlevel=0}
\chapter{second}
\section{foo}
\section{bar}
\section{baz}

\hypersetup{bookmarksopenlevel=3}
\chapter{third}
\section{1}
\section{2}
\section{3}

\end{document}

Switching the boolean off again works too:

\documentclass{book}
\usepackage{hyperref}
\hypersetup{bookmarksopen}

\begin{document}

\chapter{first}
\section{one}
\section{two}
\section{three}

\hypersetup{bookmarksopen=false}
\chapter{second}
\section{foo}
\section{bar}
\section{baz}

\hypersetup{bookmarksopen=true}
\chapter{third}
\section{1}
\section{2}
\section{3}

\end{document}

enter image description here

You must log in to answer this question.

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