TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Within the book.cls class, I redefined the \part section to customize the respective toc entry as follows:

\ifnum \c@secnumdepth >-2\relax
\addcontentsline{toc}{part}{\noindent\fcolorbox{ocre}{black!5}{\protect\makebox[\linewidth-2\fboxsep]{\Large\sffamily\strut #1}}}%

The problem is that the \fcolorbox somehow does not go well with the created part bookmark in the pdf file. For instance, instead of parttitle, I am getting the following bookmark in the built pdf file:

push0 g 0 Gpop[-2]parttitleocreblack!5push0 g 0 Gpoptowidthheightdepthottheight-0.5 -widthheightdepthd- widthheightdepthheightted

I have been trying some \protect commands, without success so far. Would you be aware of a systematic way to correct this behavior. If not, I can still redefine the part titles directly in the pdf.

share|improve this question
up vote 1 down vote accepted

Something like this:



\def\@myparttocformat #1{\noindent
       {\makebox[\linewidth-2\fboxsep-\@pnumwidth]{\Large\sffamily\strut #1}}}

  \ifnum \c@secnumdepth >-2\relax 
    \addcontentsline {toc}{part}
 \addcontentsline {toc}{part}{#1}\fi \markboth {}{}{\centering \interlinepenalty \@M \normalfont \ifnum \c@secnumdepth >-2\relax \huge \bfseries \partname \nobreakspace \thepart \par \vskip 20\p@ \fi \Huge \bfseries #2\par }\@endpart }




\chapter{A chapter}



I did this to keep close to your skeleton of a mwe, however, I would much rather redefine \l@part. (do not know in which device name xcolor option ocre is defined)

The hyperref link would admittedly then be only on the actual name of the Part, and not like here the entire shaded and framed box. But the whole thing would be cleaner.


with the bookmarks shown (now in Acrobat):

toc with acroread

share|improve this answer
Nice. Do you know why the part and chapter numbers are not included in the bookmarks? – pluton Feb 24 '13 at 22:12
I think they never are for chapters and sections. They are for parts because standard LaTeX puts different things in the toc file then (no \numberline but a \hspace{1em}) and (I did not investigate more), presumably hyperref just filters out the \hspace{1em} which leaves the part number. Yes, I just tried with the memoir class and then even the parts do not get numbers in the bookmarks (memoir uses \partnumberline, \chapternumberline, ...) – jfbu Feb 24 '13 at 22:18
I just found a possible answer: tex.stackexchange.com/questions/11867/customize-pdf-bookmarks/… – pluton Feb 24 '13 at 22:23
yes, that gives a fix. But does one really want numbers in bookmarks? bookmarks are supposed to be clicked upon... and the TOC already has the numbers. – jfbu Feb 24 '13 at 22:29
correct but when the document is long, numbered bookmarks do help a bit. Also, it looks like the \texorpdfstring command removes the automatic bookmark numbering. – pluton Feb 24 '13 at 22:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.