Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
could you provide a MWE for folks to play with? :) –  cmhughes Nov 25 '12 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. –  Andrew Swann Nov 25 '12 at 16:46
add comment

1 Answer

up vote 7 down vote accepted

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.,

\documentclass{article}

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

\begin{document}
\maketitle
\tableofcontents

\input{chap1}
\input{chap2}
\input{app1}
\end{document}

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.

share|improve this answer
    
Now I understand the operation of '\includeonly' command. I think your idea is the best thing I can do. Thanks! –  Gitano Nov 25 '12 at 20:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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