# Add an indent to appendix line in ToC for included appendix

I asked how to add an indent to a toc line for an appendix here.

In my real structure I am including the appendices:

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{tocloft}
\usepackage[title,toc,page]{appendix}

\begin{document}

\tableofcontents

\chapter{MyChapter}

\begin{appendices}
\include{appendix_a}
\include{appendix_b}
\end{appendices}

\end{document}


But this ends in:

Contents

1 My Chapter                      3
Appendices                        5


The indent does not work for the first include. Is there any solution?

• Whatever you have shared in the MWE part, after compiling that the output is pretty normal. – Mishra S Feb 22 at 12:57
• For the second appendix, you can try the command \noindent – Mishra S Feb 22 at 12:57
• @SibaMishra But I like to have the indent at the first ;) – S-Man Feb 22 at 13:04

You can fix that by borrowing Martin Scharrer's \immaddtocontents macro:

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tocloft}
\usepackage[title,toc,page]{appendix}

\makeatletter
\let\protect\@unexpandable@protect
\immediate\write\@auxout{\noexpand\@writefile{toc}{#1}}%
}}
\makeatother

\begin{document}

\tableofcontents

\chapter{MyChapter}

\begin{appendices}