在 Adobe Acrobat Reader 中,“附录”与各个附录章节处于同一级别。是否可以更改 Adobe 表示,使其看起来像目录中的样子(= 将第一章和第二章置于“附录”之下)?
平均能量损失:
\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}
答案1
整个麻烦是因为\chapter
在很多情况下使用了附录作为章节,但可以通过toclevel@chapter
增加一来改变书签级别。
\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}