[Tex/LaTex] Using different \cftsetindents for Appendix entries in Table of Contents

appendicesformattingspacingtable of contentstocloft

Related to this question, which specified how to relabel the Chapter prefix for appendices. But now my spacing is off because it's still using the same indent. Can I do something similar to \addtocontents{toc}{\def\protect\cftchappresnum{}} but to redefine the \cftsetindents for the Appendix chapters in the TOC?

MWE: (note the large horizontal whitespace between "Appendix A1." and "Example")

\usepackage{tocloft} % customize TOC font/spacing
\renewcommand\cftchappresnum{Chapter } % prefix "Chapter " to chapter number in ToC
\renewcommand{\cftchapaftersnum}{.}    % add period after chapter number
\cftsetindents{chapter}{0em}{7em}      % set amount of indenting for chapter in TOC




\renewcommand{\thechapter}{A\arabic{chapter}} % Appendix A#
\addtocontents{toc}{\def\protect\cftchappresnum{}} % Appendix A1 instead of Chapter Appendix A1 in TOC


Best Answer

The tocloft manual specifies that the command \cftsetindents{entry}{indent}{numwidth} sets the entry’s indent and its numwidth. In my case, I needed to modify the numwidth. The following command worked for me (I put it right after the \begin{appendices} line):