TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I'm debugging a big multifile project, it's often useful to make extensive use of \includeonly to narrow down where the problem is. but today I found myself using: \includeonly{chap1,chap2,chap4,chap5}. Surely \exclude{chap3} would be a simpler way to achieve this functionality? But that particular command doesn't seem to exist. Is there a command with this functionality?

share|improve this question
up vote 16 down vote accepted

The excludeonly package defines an \excludeonly command that does what you want. Package description:

The package defines an \excludeonly command, which is (in effect) the opposite of \includeonly. If both \includeonly and \excludeonly exist in a document, only files "allowed" by both will be included.

The package redefines the internal \@include command, so it conflicts with packages that do the same. Examples are the classes paper.cls (paper) and thesis.cls (thesis).

share|improve this answer
The link to CTAN is broken on that page. Here is one that works: ctan.org/tex-archive/macros/latex/contrib/excludeonly – Seamus Sep 7 '10 at 13:53
I'm actually surprised this is a package, rather than part of the core workings of LaTeX like \includeonly is... – Seamus Sep 7 '10 at 14:10
There are other cases like that - \@addtoreset is part of the LaTeX kernel, \@removefromreset needs (e.g.) the remreset package. – lockstep Sep 7 '10 at 14:17
@Seamus: Remember that in 1993/4 the amount of memory required by LaTeX as it is was already too much for many systems! – Joseph Wright Mar 17 '11 at 8:18

Just comment out \include{chap3}. The way I understand it, the purpose of \includeonly is when you'd like to include just one or two things, it's simpler to use \includeonly than to comment out a bunch of lines. But if you're keeping everything and just including one thing, why use a special command just to exclude something?

share|improve this answer
That's a bad idea, Aaron, the \include{chap3} is needed! Otherwise LaTeX doesn't include chap3.aux, and you get lots of undefined references. That's what \includeonly is all about: to get the correct references. – Hendrik Vogt Mar 17 '11 at 9:50
Good point. I stand corrected. Thanks – Aaron Mar 19 '11 at 3:34

Your Answer


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.