I'm trying to manually add the chapters
of my appendix to the ToC, but the result is horrible. The page number is placed directly next to the chapter name, instead of using the regular format where the page number aligns right.
My code:
\documentclass{article}
\usepackage{pgfplots}
\usepackage{geometry}
\usepackage[toc,page,title]{appendix}
\begin{document}
\tableofcontents
\section{Week 1 - Intro \textcolor{blue}{\textbf{R}}}
\begin{appendices}
\addcontentsline{toc}{chapter}{Appendix A}
\addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
\chapter{\large{\textbf{Appendix A - \textcolor{blue}{R} commando's}}} \\
\chapter{\large{\textbf{Appendix B - Begrippenlijst}}}
\end{appendices}
\end{document}
Screenshot of the code:
So what I want is to have the "regular" ToC format when adding these chapters to the ToC. All manuals I can find offer no explanation as to how the \addcontentsline
command works, but I'm almost certain the solution lies in that command, specifically in the "entry" part of the command (third argument).
Best Answer
You are using
article
class and using\chapter
which doesn't look correct. Use\section
instead.I have removed extra commands from the section arguments and modified. Note the
\protect
since\textcolor
is fragile..Further, you need not add
Appendix A
in the section title. Usetitletoc
option forappendix