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 had a problem as I wanted to make my appendices look like sections.

I already found a solution to do this for the table of contents by using this code just before the \chapter command in the appendix environment :

\makeatletter
\addtocontents{toc}{\let\protect\l@chapter\protect\l@section}
\makeatother

Now, I would like to make the bookmarks "realize" it. When I open the PDF file the Appendices appears at a chapter level, but the title of the appendix appears at chapter level too.

All the bookmarks I have come from the hyperref package, so I guess I can't use the bookmark package to find a solution.

Is there any way to make it look like a section of the chapter Appendices in the bookmarks?

Here is the code I use in my LaTeX program:

\begin{appendices}
 \makeatletter
 \addtocontents{toc}{\let\protect\l@chapter\protect\l@section}
 \makeatother
 \chapter{Appendix1}
 \chapter{Appendix2}
 ...
 \end{appendices}

I already tried to use the \section function instead of \chapter, but it doesn't seem to work.

share|improve this question

2 Answers 2

Perhaps you're after something like this:

enter image description here

\documentclass{report}
\usepackage{appendix,bookmark,xpatch}% http://ctan.org/pkg/{appendix,bookmark,xpatch}
\begin{document}
\tableofcontents
\chapter{A chapter}
\section{A section}
\chapter{Another chapter}
\section{A section}
\begin{appendices}
\makeatletter
\addappheadtotoc
\addtocontents{toc}{\let\protect\l@chapter\protect\l@section}
% \xpatchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\xpatchcmd{\Hy@org@chapter}{{toc}{chapter}}{{toc}{section}}{}{}%
\xpatchcmd{\Hy@org@chapter}{{toc}{chapter}}{{toc}{section}}{}{}%
\makeatother
\chapter{Appendix1}
\chapter{Appendix2}
 ...
\end{appendices}
\end{document}

The missing puzzle piece is provided by the xpatch package. It is used to patch the original \@chapter command, stored in \Hy@org@chapter (as defined by hyperref and/or bookmark).

In essence, the patch changes the ToC entry from chapter to section.

The solution works with both hyperref and bookmark.

share|improve this answer
    
Thanks, it worked perfectly for me, this is exactly what I was looking for. –  Heron Birin Nov 29 '12 at 5:45

Method via \bookmarksetupnext

With package bookmark the following is possible:

\bookmarksetupnext{level=-1}
\addappheadtotoc

overwrites the bookmark setting of "Appendices" and moves it a level higher to part level. Then the appendix chapters become children to the "part" appendices.

\documentclass{report}
\usepackage{appendix}
\usepackage{hyperref}
\usepackage{bookmark}
\begin{document}
  \tableofcontents
  \chapter{A chapter}
  \section{A section}
  \chapter{Another chapter}
  \section{A section}
  \begin{appendices}
    \bookmarksetupnext{level=-1}
    \addappheadtotoc
    \makeatletter
    \addtocontents{toc}{\let\protect\l@chapter\protect\l@section}
    \makeatother
    \chapter{Appendix1}
    \chapter{Appendix2}
     ...
  \end{appendices}
\end{document}

The example is based on the example in Werner's answer.

Method via \toclevel@<section>

Package hyperref configures the bookmark levels in macros \toclevel@chapter, \toclevel@section:

...
\def\toclevel@chapter{0}
\def\toclevel@section{1}
\def\toclevel@subsection{2}
\def\toclevel@subsubsection{3}
\def\toclevel@paragraph{4}
\def\toclevel@subparagraph{5}
...

These macros can be redefined:

\begin{appendices}
  \makeatletter
  \addtocontents{toc}{\let\protect\l@chapter\protect\l@section}
  \def\toclevel@chapter{1}
  \def\toclevel@section{2}
  \def\toclevel@subsection{3}
  % ... (add deeper levels if needed)
  \makeatother
  \chapter{Appendix1}
  \chapter{Appendix2}
  ...
\end{appendices}

Remark: You can use package bookmark together with hyperref getting faster updated bookmarks and more features.

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.