Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

When should I use \input vs. \include?

There are two different commands to incorporate another file into the source of some document, \input and \include. When should I use one or the other? What are the differences between them? Are there more things like them to be aware of?
by

2 Answers

sandhya6gczb
\input{filename} imports the commands from filename.tex into the target file; it's equivalent to typing all the commands from filename.tex right into the current file where the \input line is.

\include{filename} essentially does a \clearpage before and after \input{filename}, together with some magic to switch to another .aux file, and omits the inclusion at all if you have an \includeonly without the filename in the argument. This is primarily useful when you have a big project on a slow computer; changing one of the include targets won't force you to regenerate the outputs of all the rest.

\include{filename} 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.
RoliMishra
\input is a lower level macro that simply inputs the content of the given file like it was copy&pasted there manually. \include handles the file content as a logical unit of its own (like e.g. a chapter) and enables you to only include specific files using \includeonly{filename,filename2,...} to save times.

Login / Signup to Answer the Question.