# Exclude sections from bookmarks or get sections with no numbers

Really the question is on Title. I'm creating a book, it has parts, sections and subsections. The TOC contains all sections with their numbers, it's ok. But for bookmarks I'd like to get sections with no numbers. Could anybody show the suitable option(s) for hyperref or bookmark packages to get this result?

• The usual way is to provide a MWE here, not forcing users to glue an example for you. There is no hyperref package option that prevents bookmarks for some level, however, there's another approach. – user31729 Mar 21 '16 at 11:49

The numerical value of toclevel@foo commands decide whether a section level is shown in the bookmarks or not -- foo is a placeholder here for the various structure levels, from part... down to subparagraph.

The normal values are -1,0,1,2,3,4,5 from part to subparagraph, increasing the toc level (actually bookmark level rather) will prevent the relevant levels to be shown. Using values from 100 etc. are pretty safe then.

\documentclass{book}

\usepackage{bookmark}

\setcounter{tocdepth}{6} % Only for demonstration
\makeatletter
\renewcommand{\toclevel@section}{100}
\renewcommand{\toclevel@subsection}{101}
\renewcommand{\toclevel@subsubsection}{102}
\renewcommand{\toclevel@paragraph}{103}
\renewcommand{\toclevel@subparagraph}{104}
\begin{document}
\tableofcontents
\chapter{A chapter}
\section{A section}
\subsection{A subsection}

\subsubsection{A subsubsection}
\paragraph{A paragraph}
\subparagraph{A subparagraph}

\end{document}

• Very clear, thank you. The first part of my question is answered. Your code makes my parts and chapters visible in bookmarks, sections are disapeared. Could you recommend something to make sections (without their numbers!) still visible in bookmarks? But chapters and parts with their numbers still. – Olga K Mar 21 '16 at 12:31
• @OlgaK: You asked for 'or', not 'and' -- you know the difference, since you're a Mathematician (according to your profile) ;-) – user31729 Mar 21 '16 at 12:32
• Oh, yes)) actually I want to know them both, or + and. If you dont mind)) – Olga K Mar 21 '16 at 12:39
• @OlgaK: This is not really easy, actually. I assume, that the \subsection etc. shouldn't appear numbered then as well. – user31729 Mar 21 '16 at 12:44
• Seems I got something by myself, wait a little. You are right, not easy way, but it exists. I'll post it a bit later – Olga K Mar 21 '16 at 12:47