# How to make appendices like section in bookmarks

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
\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
\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.

-

Perhaps you're after something like this:

\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
% \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.

-
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}


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}
\makeatletter
\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
\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.

-