A more apt title to this is question may be "Jumping through hoops". My question is similar to this one.
I have the following requirements for the table of contents in my thesis:
- The title "Table of Contents" must be centered
- Every chapter, section, subsection, and appendix must have dots between the chapter/section/etc name and the page number
- The chapters must start out "Chapter #" for each entry in the ToC.
Following the second answer in the link above, I can get all three of these requirements using Tocloft, however it also puts "Chapter Appendix" which is not correct (see MWE below). Following the first answer, I no longer have this problem, but I can't get #2: there are no dots between the chapter name and the page number. Looking at the documentation for titletoc, it doesn't seem possible to include them (but maybe I'm missing something).
I would like to satisfy all three requirements but not have "Chapter Appendix". I am willing to use any package(s) to meet these.
MWE:
\documentclass{report}
\usepackage{titlesec,tocloft,calc}
\renewcommand{\cftchappresnum}{Chapter }
\AtBeginDocument{\addtolength\cftchapnumwidth{\widthof{\bfseries Chapter }}}
\renewcommand\cftchapdotsep{\cftdotsep}
\renewcommand{\contentsname}{\vspace*{-1.75in}\hfill\bfseries\Large Table of Contents\hfill}
\renewcommand{\cftaftertoctitle}{\hfill}
\begin{document}
\tableofcontents
\chapter{Asdf}
\section{Foo}
\chapter{Jkl;}
\section{Bar}
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
\titleformat{\chapter}[display]{\centering\Huge\bfseries}{\thechapter}{0pt}{}
\appendix
\renewcommand{\thechapter}{}
\begin{chapter}{APPENDIX}
\renewcommand{\thechapter}{A}
\end{chapter}
\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
\end{document}