# Adding ToC line manually within appendix

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}
\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).

-

You are using article class and using \chapter which doesn't look correct. Use \section instead.

\documentclass{article}
\usepackage{xcolor}
%\usepackage{geometry}
\usepackage[toc,page,title]{appendix}

\begin{document}
\tableofcontents
\section{Week 1 - Intro \textcolor{blue}{\textbf{R}}}
\begin{appendices}
\section{Appendix A - \protect\textcolor{blue}{R} commando's}
\section{Appendix B - Begrippenlijst}
\end{appendices}
\end{document}


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. Use titletoc option for appendix

\documentclass{article}
\usepackage{xcolor}
%\usepackage{geometry}
\usepackage[titletoc,page,title]{appendix}   %% note titletoc

\begin{document}
\tableofcontents
\section{Week 1 - Intro \textcolor{blue}{\textbf{R}}}
\begin{appendices}