3

I have a document where I use \includeonly to only compile parts of it at a time. However I would still like the Table of Contents to display everything. Is this possible?

  • 1
    Yes, compile twice with all \includes enabled and then say \nofiles in the preamble, using \includeonly at will. This way, the toc won't be regenerated and is frozen to the full state. – user31729 Oct 31 '15 at 13:07
7

Using \nofiles will freeze (any!) generation of .toc etc. files:

Compile twice first with %\includeonly and then add \nofiles and remove the % in front of \includeonly to include the relevant parts at will.

\documentclass{book}

\begin{filecontents}{mychapter1.tex}
\chapter{First}
\section{First}
\subsection{First}
\end{filecontents}

\begin{filecontents}{mychapter2.tex}
\chapter{Second}
\section{Second}
\subsection{Second}
\end{filecontents}

\includeonly{mychapter1}

\nofiles

\begin{document}
\tableofcontents
\include{mychapter1}

\include{mychapter2}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.