I have written 2 chapters an 1 appendix, and I would like to have 2 version of this book. So I use \includeonly in order to include only chapter 1 and 2, but the TOC also shows the appendix name.

Probably, this is the natural behavior of \includeonly, but how can I do this? I mean, in the short version I just want to print the chapters 1 and 2 (including the TOC), and in long version to print everything.

  • could you provide a MWE for folks to play with? :)
    – cmhughes
    Nov 25, 2012 at 16:45
  • You have to run LaTeX twice to get the TOC updated. If that is not the problem then please provide us with a minimal working example (MWE) to display the problem. Nov 25, 2012 at 16:46

1 Answer 1


The purpose of \include is to structure your document so that you can compile of only some of it (using \includeonly) while at the same time the cross-referencing information from the whole document remains available. The TOC is "cross-referencing" information as well, so if you compile the document with the TOC included it will show the TOC entries from all chapters.

What you are trying to do is to produce two different versions of the document, a full version and a version that contains only a subset including a TOC that then also contains only the compiled subset. This is not a use case for which \includeonly was designed.

The simplest way to achieve this is to put the various parts of your document in separate files and then build two master documents (with different names) that only load the parts you are interested in, e.g.,


\input{mypreamble}  % load your packages etc in here



If the above is your full master document then copy it to a second file and remove the line loading the appendix (and whatever you don't want in the smaller document). Compile both and you are done.

  • Now I understand the operation of '\includeonly' command. I think your idea is the best thing I can do. Thanks!
    – Gitano
    Nov 25, 2012 at 20:06

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.