1

On Adobe Acrobat Reader "Appendices" is on the same level like the individual appendix chapters. Is there any chance to change the Adobe representation so that it looks like in the table of contents ( = subordinate Chapter One and Two to "Appendices")?

enter image description here

MWE:

\documentclass[a4paper,12pt,parskip=half]{report}

\usepackage{hyperref}

\usepackage[toc,page]{appendix}
\renewcommand\appendixtocname{Appendices}
\renewcommand\appendixpagename{Appendices}
\let\appendixpagenameorig\appendixpagename

\begin{document}

  \tableofcontents

  \begin{appendices}
    \addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
    \makeatletter
    \addtocontents{toc}{%
      \begingroup
      \let\protect\l@chapter\protect\l@section
      \let\protect\l@section\protect\l@subsection
    }
    \makeatother

    \chapter{Chapter One}
    \chapter{Chapter Two} 
  \end{appendices}
\end{document}
  • The stuff that you do to make the chapter entries appear as sections, does not change the fact that they are of type chapter in the .toc file which is presumably what is being used to build the bookmark list. You might have luck using some of the stuff from the bookmark package. – daleif Aug 25 '17 at 8:39
  • Another method is to make the appendencies marker into a part marker instead of the default chapter – daleif Aug 25 '17 at 8:44
1

The whole trouble is because \chapter is used whereas appendices are sections in many cases, but it is possible to shift the bookmark level by changing toclevel@chapter etc by increasing by one.

\documentclass[a4paper,12pt,parskip=half]{report}

\usepackage[toc,page]{appendix}
\usepackage{etoolbox}    
\usepackage[bookmarksopen,bookmarksopenlevel=2]{hyperref}


\makeatletter

\apptocmd{\appendices}{%
  \renewcommand{\toclevel@chapter}{1}% Shift the chapter level to 1 ('section')
  \renewcommand{\toclevel@section}{\the\numexpr\toclevel@chapter+1}
  \renewcommand{\toclevel@subsection}{\the\numexpr\toclevel@section+1}
    \addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
    \addtocontents{toc}{%
       \begingroup
       \let\protect\l@chapter\protect\l@section
       \let\protect\l@section\protect\l@subsection
     }%
   }{}{}


\AfterEndEnvironment{appendices}{%
  \addtocontents{toc}{\endgroup}%  Close the group
}

\makeatother

\renewcommand\appendixtocname{Appendices}
\renewcommand\appendixpagename{Appendices}
\let\appendixpagenameorig\appendixpagename

\begin{document}

  \tableofcontents

  \chapter{Foo}

  \begin{appendices}


    \chapter{Chapter One}
    \section{Foo section}
    \chapter{Chapter Two} 
  \end{appendices}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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