我正在使用一个针对我的大学论文格式要求的文档类模板。它是由一个学生几年制作的,而大学并没有保留它。制作模板的人没有附录(或者自几年前制作附录以来,附录格式已更改),因为当我尝试制作附录时,格式不符合当前的格式要求。制作附录的标准方法行不通,我在许多其他问题/帖子/博客/等等中发现的许多建议也行不通。
我正在使用Rmarkdown并通过Sweave从.Rnw文件编译PDF。
下面是现有模板产生的结果。我提供了两个版本,一个版本的\ chapter {}为空白,另一个版本的\ chapter {Appendices}。
我需要使TOC看起来像:
Appendices 128
Appendix A The CATE as a ratio of covariances .............. 128
Appendix B CATE in Morgan and Winship (2014) ............... 130
Appendix C Data-Generating Syntax .......................... 132
Appendix D Estimator Syntax ................................ 136
并且我需要文本以“ Appendix A”开头,并在页面顶部居中对齐(并以其他附录为基础,依次类推)。我不能将“附录”作为标头-它需要直接跳转以显示各个附录的名称。
我已经粘贴了我认为是文档类模板中的相关位。如果我还没有提供一些重要信息,请告诉我,我将编辑问题以包括该信息。
% table of contents configuration
\RequirePackage[nottoc]{tocbibind}
\RequirePackage{tocloft}
\renewcommand{\contentsname}{Table of Contents} % default: Contents
\renewcommand{\cftdotsep}{0.25} % default: 4.5
% Prefix chapter numbers with "Chapter " and add space as needed
\renewcommand{\cftchappresnum}{\@chapapp\ }
\newlength{\cftchappresnum@width}
\settowidth{\cftchappresnum@width}{\cftchappresnum}
\addtolength{\cftchapnumwidth}{\cftchappresnum@width}
% chapter heading configuration
% simplified version of the original from report.cls
\def\@makechapterhead#1{{%
\centering\headingsize
% print "Chapter N"
\@chapapp\space\thechapter
\par\nobreak
\vskip.25\baselineskip
\@makeschapterhead{#1}
}}
% star-chapter variation
\def\@makeschapterhead#1{{
\centering\headingsize
% prevent page break between following lines at all costs
\interlinepenalty=10000
\bfseries #1\par\nobreak
\vskip\baselineskip
}}
% toc/lot/lof heading configuration
\setlength{\cftbeforetoctitleskip}{\z@}
\setlength{\cftaftertoctitleskip}{.25\baselineskip}
\renewcommand{\cfttoctitlefont}{\headingsize\bfseries\hspace*{\fill}}
\renewcommand{\cftaftertoctitle}{\hspace*{\fill}}
% copy toc to lot
\setlength{\cftbeforelottitleskip}{\cftbeforetoctitleskip}
\setlength{\cftafterlottitleskip}{\cftaftertoctitleskip}
\renewcommand{\cftlottitlefont}{\cfttoctitlefont}
\renewcommand{\cftafterlottitle}{\cftaftertoctitle}
% copy toc to lof
\setlength{\cftbeforeloftitleskip}{\cftbeforetoctitleskip}
\setlength{\cftafterloftitleskip}{\cftaftertoctitleskip}
\renewcommand{\cftloftitlefont}{\cfttoctitlefont}
\renewcommand{\cftafterloftitle}{\cftaftertoctitle}
\newcommand{\maketableofcontents}{%
\clearpage
\tableofcontents
\clearpage
\listoftables
\clearpage
\listoffigures
\clearpage\pagenumbering{arabic}
}
\newcommand{\makeappendix}{%
\appendix
% ensure that the TOC picks up the redefined value of \@chapapp
\addtocontents{toc}{\protect\renewcommand\protect\cftchappresnum{\@chapapp\ }}
}
我可以使用蛮力解决方案(如果存在的话)。如果有人能够格式化模板,以便将来所有的硕士/博士学位学生都可以包括附录,我将很乐意拉出模板并将其分支,并在笔记中链接至该问题。
我在这里找到了所需的答案:https://tex.stackexchange.com/questions/172867/custom-toc-for-appendices
它非常接近我想要的,我只需要进行一些小改动就可以使它工作。