Consider the following MWE:
Two chapters. The first chapter additional injects two items to toc
a) - One via \addcontentsline b) - A second via \addtocontents
- (a) behaves properly in respect of the partial toc
- (b) is carried through to the partial toc for chapter 2
Why is this happening?
What can I do to prevent it?
It has a number of side effects in my document which I won't elaborate here (suffice to say that I am injecting code into the toc via \addtocontents and this is repeated in subsequent chapters).
\documentclass{book}
\usepackage{titletoc}
\newcommand{\printmyminitoc}{%
\startcontents[mypart]
\printcontents[mypart]{}{1}[4]{}
}%
\begin{document}
\tableofcontents
\chapter{Chapter 1}
\printmyminitoc
\section{Sec1}
\subsection{Subsec1}
\subsection{Subsec2}
\section{Sec2}
\addcontentsline{toc}{section}{added via addcontentsline}
\addtocontents{toc}{{added via addtocontents\endgraf}}
\chapter{Chapter 2}
\printmyminitoc
\section{Sec1}
\subsection{Subsec1}
\subsection{Subsec2}
\section{Sec2}
\end{document}
