Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to style my PDF bookmarks in a way such that I can manipulate the levels of the standard sections as I wish. I thought the bookmark package was the best choice to do this, unfortunately it does not behave as I expected. A MWE of my efforts follows:

\documentclass{book}
\usepackage{hyperref,bookmark}
\begin{document}
\tableofcontents
\bookmarksetup{level=0}
\part{Part}
\chapter{Chapter 1}
\bookmarksetup{rellevel=-1}
\addcontentsline{toc}{chapter}{Chapter 2}
\chapter*{Chapter 2}
\bookmarksetup{level=1}
\chapter{Chapter 3}
\end{document}

The pdf bookmark-tree should look like this:

Part

|__Chapter 1

Chapter 2

|__Chapter 3

Obviously I cant use the \boomarksetup{startatroot} command of the bookmark package before Chapter 2 because Chapter 3 would also be pulled out to the root. On the other hand the level options included in the code seem only to have an effect on bookmarks which were manually set with \bookmark. However, I don't want to issue a manual bookmark for every chapter because this would be quite annoying and I would anyway end up with two entries in PDF-bookmarks. The package documentation is not the best and so far I did not figure if it is actually possible to achieve the styling with this package.

The reason why I dont use a part for 'Chapter 2' is that I want it to be typset like a Chapter in the ToC as well as in the body of the document. It is actually the title page of an Appendix.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

One option would be to add "Chapter 2" to the ToC as a part instead of as a chapter; this, however, will treat "Chapter 2" as a part in the ToC and this is not desired. To correct the formatting in the ToC, you can use the titletoc package to locally make parts to behave as chapters in the ToC:

\documentclass{book}
\usepackage{titletoc}
\usepackage{hyperref}

\begin{document}

\tableofcontents

\part{Part}
\chapter{Chapter 1}

\begingroup
\titlecontents{part}
[0pt]{\normalsize\bfseries\vskip10pt}{}{}
{\hfill\bfseries\contentspage}

\chapter*{Chapter 2}
\addcontentsline{toc}{part}{Chapter 2}

Contents of Chapter 2....
\endgroup

\chapter{Chapter 3}

\end{document}

The resulting bookmark tree:

enter image description here

and the resulting ToC:

enter image description here

share|improve this answer
    
Sure, in general this is an option, however, as I stated in my original post I don't want Chapter 2 to be typeset as a "Part" in the ToC. –  Paul Hanson Nov 2 '11 at 15:04
    
@PaulHanson: Ah... I'm sorry. I overlooked the last paragraph of your question. –  Gonzalo Medina Nov 3 '11 at 2:52
    
@PaulHanson: see my updated answer for a workaround. –  Gonzalo Medina Nov 3 '11 at 3:07
    
Thank You. Your solution works fine, even though I'm already using the tocloft package to customize my ToC. –  Paul Hanson Nov 4 '11 at 20:56

In your MWE just replace

\bookmarksetup{rellevel=-1}

by

\bookmarksetupnext{rellevel=-1}

to achive the desired effect. Additionally you can remove

\bookmarksetup{level=0}

and

\bookmarksetup{level=1}

and you should note that the header in Chapter 2 will read "Chapter 1" and Chapter 3 will be named "Chapter 2", because you used \chapter*{Chapter 2} instead of \chapter{Chapter 2}, but maybe you want this (and manually change things).

share|improve this answer

Your Answer

 
discard

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.