我正在写一篇论文,我希望附录\chapter
在书签中被声明为分组在一章“附录”下,然后每个附录都作为一个部分出现。这个问题的答案已提供这里。这个想法是用来xpatch
将目录条目从 更改\chapter
为\section
。
\section
我现在正尝试将附录中的条目更改为\subsection
书签中的条目。这就是我遇到的问题。
下面的代码运行时没有错误,但将附录中的所有书签视为部分。
请注意,我使用的是样式文件(dissertation.sty,请参阅 .tex 文件下方的代码)。此样式文件定义了命令,\appendices
这就是我不使用该appendix
包的原因。
\documentclass[12pt]{report}
\usepackage{dissertation}
\usepackage[latin1]{inputenc}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{amsmath,amssymb,amsfonts,dsfont}
\usepackage{xpatch}
\usepackage[dvipdfm,hypertexnames=false,colorlinks,linktoc=page]{hyperref}
\begin{document}
\chapter{Chapter 1}
\section{Section 1}
\section{Section 2}
\chapter{Chapter 2}
\appendices
\chapter{Appendix 1}
\chapter{Appendix 2}
\section{Sub-appendix 1}
\section{Sub-appendix 2}
\end{document}
此代码编译所需的最小样式文件是:
\newlength{\regular@textheight}
\setlength{\regular@textheight}{\textheight}
%
\addtolength{\regular@textheight}{-\footskip}
\newlength{\short@textheight}
\setlength{\short@textheight}{\textheight}
\addtolength{\short@textheight}{-\footskip}
\def\short@page{%
\setlength{\textheight}{\short@textheight}
\global \pagestyle{plain}
\global \@colht\textheight
\global \@colroom\textheight
\global \vsize\textheight}
\def\regular@page{%
\setlength{\textheight}{\regular@textheight}
\global \pagestyle{plain}
\global \@colht\textheight
\global \@colroom\textheight
\global \vsize\textheight}
\newcounter{regular@short}
\def\doublespacing{%
\def\default@spacing{\baselineskip=23.5pt plus .5pt minus .2pt}}
\newlength{\one@num}\setlength{\one@num}{18pt}
\newlength{\two@num}\settowidth{\two@num}{9.9...}
\newlength{\three@num}\settowidth{\three@num}{9.9.9...}
\newlength{\four@num}\settowidth{\four@num}{9.9.9.9...}
\newlength{\five@num}\settowidth{\five@num}{9.9.9.9.9...}
\newlength{\six@num}\settowidth{\six@num}{9.9.9.9.9.9...}
\def\longtocentry{%
\settowidth{\two@num}{99.99...}
\settowidth{\three@num}{99.99.99...}
\settowidth{\four@num}{99.99.99.99...}
\settowidth{\five@num}{99.99.99.99.99...}
\settowidth{\six@num}{99.99.99.99.99.99...}}
\newlength{\c@onenum}
\setlength{\c@onenum}{\one@num}
\newlength{\c@twonum}
\setlength{\c@twonum}{\c@onenum}\addtolength{\c@twonum}{\two@num}
\newlength{\c@threenum}
\setlength{\c@threenum}{\c@twonum}\addtolength{\c@threenum}{\three@num}
\newlength{\c@fournum}
\setlength{\c@fournum}{\c@threenum}\addtolength{\c@fournum}{\four@num}
\newlength{\c@fivenum}
\setlength{\c@fivenum}{\c@fournum}\addtolength{\c@fivenum}{\five@num}
\def\l@section{\@dottedtocline{1}{\c@onenum}{\two@num}}
\def\l@subsection{\@dottedtocline{2}{\c@twonum}{\three@num}}
\def\l@subsubsection{\@dottedtocline{2}{\c@threenum}{\four@num}}
\def\l@paragraph{\@dottedtocline{4}{\c@fournum}{\five@num}}
\def\l@subparagraph{\@dottedtocline{5}{\c@fivenum}{\six@num}}
\def\nopage@addcontentsline#1#2#3{\addtocontents{#1}%
{\protect \contentsline {#2}{#3}{}}}
\newlength{\toc@chap@indent}
\settowidth{\toc@chap@indent}{\bf\@chapapp\space\thechapter.\hspace*{1em}}
\def\l@chapter#1#2{\addpenalty{-\@highpenalty}
\vskip 1.0em plus 1pt
\@tempdima=\toc@chap@indent
\begingroup
\parindent \z@
\rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\bf \leavevmode
\advance\leftskip\@tempdima \hskip -\leftskip #1\nobreak\hfil
\nobreak\hbox to\@pnumwidth{\hss #2}\par
\penalty\@highpenalty \endgroup}
\def\@makechapterhead#1{ \vspace*{0pt} {\parindent 0pt \centering
\ifnum \c@secnumdepth >\m@ne \Large\bf \@chapapp{} \thechapter
\par \vskip 15pt \fi \Large \bf #1\par \nobreak \vskip 35pt}}
\def\@makeschapterhead#1{\vspace*{0pt} {\parindent 0pt \centering
\Large \bf #1\par \nobreak \vskip 30pt}}
\def\chapter{%
\clearpage
\short@page \setcounter{regular@short}{0}
\default@spacing
\global\@topnum\z@ \@afterindenttrue
\secdef\@chapter\@schapter}
\def\shortchapter{%
\clearpage
\short@page \setcounter{regular@short}{1}
\default@spacing
\global\@topnum\z@ \@afterindenttrue
\secdef\@chapter\@schapter}
\newcount\chap@or@app\chap@or@app=1
\def\appendixname{Appendix}
\def\appendices{\clearpage\phantomsection
\typeout{Appendices.}
\short@page \setcounter{regular@short}{1}
\markboth{}{}\pagestyle{myheadings}
\thispagestyle{plain}
\vspace*{\fill}
\centerline{\large\bf Appendices}
\vspace*{\fill}
\addcontentsline{toc}{chapter}{Appendices}
\setcounter{chapter}{0}
\setcounter{section}{0}
\def\@chapapp{\appendixname}
\chap@or@app=2
\def\thechapter{\Alph{chapter}}
\makeatletter
\xpatchcmd{\Hy@org@section}{{toc}{section}}{{toc}{subsection}}{}{}%
\xpatchcmd{\Hy@org@chapter}{{toc}{chapter}}{{toc}{section}}{}{}%
\makeatother
}
\newcount\with@parts\with@parts=0
\def\@part[#1]#2{%
\short@page
\ifnum \c@secnumdepth >-2 \relax
\refstepcounter{part}
\addcontentsline{toc}{part}{\partname~\thepart\hspace{1em}#1}%
\else
\addcontentsline{toc}{part}{#1}
\fi
\markboth{}{}
{\centering
\interlinepenalty \@M
\reset@font
\ifnum \c@secnumdepth >-2 \relax
\huge\bfseries \partname~\thepart
\par
\vskip 20\p@
\fi
\Huge \bfseries #2\par}
\ifnum\value{part}=1 \pagenumbering{arabic}
\with@parts=1 \fi
\@endpart}
\newcounter{no@chapters}
\setcounter{no@chapters}{0}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}
\typeout{\@chapapp\space\thechapter.}
\addcontentsline{toc}{chapter}{\@chapapp\space\thechapter.\hspace*{1em}#1}\else
\addcontentsline{toc}{chapter}{#1}\fi
\addtocontents{lof}{\protect\addvspace{10pt}}
\addtocontents{lot}{\protect\addvspace{10pt}}
\@makechapterhead{#2} \@afterheading
\ifnum\chap@or@app=1 \ifnum\value{chapter}=1
\markboth{}{}\pagestyle{myheadings}
\ifnum\with@parts=0 \pagenumbering{arabic}\fi
\fi\fi
\thispagestyle{plain}}
\def\@schapter#1{\thispagestyle{plain}
\@makeschapterhead{#1} \@afterheading}
\def\section{%
\ifnum\value{no@chapters}=1 \fpage \fi%
\@startsection{section}{1}{\z@}%
{4.6ex plus -1ex minus -.2ex}{.3ex plus .2ex}{\large\bf}}
\def\subsection{\@startsection{subsection}{2}{\z@}%
{3.9ex plus -1ex minus -.2ex}{.2ex plus .2ex}{\normalsize\bf}}
\def\subsubsection{\@startsection{subsubsection}{2}{\z@}%
{3.9ex plus -1ex minus -.2ex}{.2ex plus .2ex}{\normalsize\bf}}
\doublespacing