24.1 \endinput

Synopsis:

\endinput

When you \include{filename}, inside filename.tex the material after \endinput will not be included. This command is optional; if filename.tex has no \endinput then LaTeX will read all of the file.

For example, suppose that a document’s root file has \input{chap1} and this is chap1.tex.

\chapter{One}
This material will appear in the document. 
\endinput
This will not appear.

This can be useful for putting documentation or comments at the end of a file, or for avoiding junk characters that can be added if the file is transmitted in the body of an email. It is also useful for debugging: one strategy to localize errors is to put \endinput halfway through the included file and see if the error disappears. Now, knowing which half contains the error, moving \endinput to halfway through that area further narrows down the location. This process rapidly finds the offending line.

After reading \endinput, LaTeX continues to read to the end of the line, so something can follow this command and be read nonetheless. This allows you, for instance, to close an \if... with a \fi.


Unofficial LaTeX2e reference manual