Change Appendix formatting in LaTex

CRunyon picture CRunyon · Mar 20, 2020 · Viewed 7.3k times · Source

I am using a document class template that is specific to my university's dissertation formatting requirements. It was made by a student a few years, and the university does not maintain it. Whoever made the template did not have an appendix (or the appendix formatting has changed since it was made a few years ago), because when I try to make an appendix the formatting does not comply with current formatting requirements. The standard approaches to making an appendix do not work, nor do many of the suggestions I've found on dozens of other questions / posts / blogs / etc.

I am using Rmarkdown and compiling the PDF from a .Rnw file via Sweave.

Below is what is produced by the existing template. I have included two versions, one where the \chapter{} is blank, and one where I use \chapter{Appendices}.

toc1 text1 toc2 text2

What I need is to have the TOC to look like:

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

And I need the text to start with just "Appendix A" centered and justified at the top of the page (and so on for each other other appendices). I cannot have "Appendices" as a header - it needs to jump straight to displaying the individual appendix names.

I've pasted what I believe are the relevant bits from the document class template. If I have not included some important information, please let me know and I will edit my question to include that information.

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

A brute force solution is fine by me (if one exists). If someone is able to format the template so all future masters/doctoral students can include appendices, I'll gladly pull and branch the template and link to this question in the notes.

Answer

CRunyon picture CRunyon · Nov 30, 2020

This solution that I found elsewhere worked for me:

\appendix
\chapter*{Appendices}% If \appendix doesn't insert a \chapter
\addcontentsline{toc}{chapter}{Appendices}% Print Appendix in ToC
\setcounter{section}{0}% Reset numbering for sections
\renewcommand{\thesection}{\Alph{section}}% Adjust section printing (from here onward)
\section{First Appendix}
\section{Second Appendix}
\section{Third Appendix}