The answer at When should I use \input vs. \include? mentions:

\include gets you the speed bonus, but it also can't be nested, can't appear in the preamble, and forces page breaks around the included text.

But I have written an example that seems to contradict this.





I could compile foo.tex successfully and I also see the title rendered in the generated PDF when I view it with a PDF reader.

$ pdflatex foo.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2015/dev/Debian) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2014/05/01>
Babel <3.9l> and hyphenation patterns for 2 languages loaded.
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
No file foo.aux.

LaTeX Warning: No \author given.

[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./foo.aux) )</usr/share
Output written on foo.pdf (1 page, 24969 bytes).
Transcript written on foo.log.

Why was I able to \include in the preamble when the answer I have linked to says it should not be possible?

  • The \clearpage that is mandatory in \include has no effect in the preamble`
    – user31729
    Jul 7, 2016 at 13:39

2 Answers 2


The \include command uses \clearpage at the beginning, however there's no page build up so far in the preamble, so it has no effect.

Here's some code from the latex.ltx file (shortened!)

    \@latex@error{\string\include\space cannot be nested}\@eha
  \else \@include#1 \fi}
\def\@include#1 {%
%.... much more ...

Since \title{foo} does only define (better set) another macro there is no typesetting content in the file used for \include.

This little document is effectively doing the same:

\clearpage% Does nothing here
\clearpage% Does nothing here, since there is no page yet!

But as soon as typesetting occurs (i.e. content that builds up a page) the \include operation must fail in the preamble, as if you would have written the content in the preamble directly.

So, don't use \include in preamble at all.

Of course, having typesetting code in another file and using \input of that file in the preamble the error would be the same one!


There are lots of incorrect latex input constructs that don't actually give an error, they just do whatever they do by accident and luck. \include only does anything useful if used after the preamble, if used before it probably works like an inefficient version of \input and you manage to avoid an error just the way it works out, but no part of the behaviour in that case is designed, it's just accidental expansion of incorrect input.

See for example


being written to the console, in the output you show, that is intended to be written to the main aux file but it can not be as the aux file is not opened until \begin{document}. As it happens, writing to an unopened stream is not an error in tex, it just writes to the console, but it is an error in all but name here.

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.