Why do I get this error in this very simple mwe?
You need to insert a paragraph break before the chapter line. As \par directly is not allowed, use \endgraf:
\documentclass[notoc]{tufte-book}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\begin{document}
\tableofcontents
\chapter{Introduction}
\startcontents[chapters]
\printcontents[chapters]{}{1}{}
\section{Historical Overview}
\section{The CUDA Model}
\section{A Lattice Boltzmann Solver}
\addtocontents{toc}{text\endgraf}
\chapter{chap3}
\section{My Overview}
\end{document}
It stems from the introduction of random text inside the .toc
file via
\addtocontents{toc}{text}
If you wish to do so, ensure that the text is on its own by issuing a \par
afterwards.
The following minimal example replicates the problem:
\documentclass{article}
\begin{document}
\tableofcontents
\section{A section}
\addcontents{toc}{text}% Error
%\addtocontents{toc}{text\par}% No error
\section{Another section}
\end{document}