Friday, January 17, 2014

include{} and input{} in Latex

This is just a quick note on the differences between the commands include{} and input{} in Latex. Both of them have essentially the same function: read some tex from a separate file to make writing large documents easier in Latex. There are some key differences.

  • with my setup neither command will work unless you leave off the .tex extension.
  • include{} has a \clearpage before and after it.

include{} is best used to include something like a chapter. In other words the file should be almost all of a stand alone document. It shouldn't include a \begin{document} or an \end{document}, headers, footers, or package inclusions. It should be noted that commands which have filepaths in them are referenced from the location of the file being executed, not the included file.

input{} is best utilized for importing the enormous list of \usepackage and custom commands that everyone seems to have at the top of their tex documents.

For example we might have a file system which looks like this:
  • example.tex
  • Images
    • exampleimage.png
  • Chapter1
    • chapter1.tex
  • Preamble
    • preamble.tex

This is my example document...




\section{Chapter One}
This is the first chapter...\\
Here's a picture:\\

Which generates this pdf.

No comments:

Post a Comment