## 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.

Note:
• 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
example.tex

\input{Preamble/preamble}
\begin{document}
This is my example document...
\include{Chapter1/chapter1}
\end{document}

preamble.tex

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{default}
\usepackage{amssymb}
\usepackage{graphicx}

chapter1.tex

\section{Chapter One}
This is the first chapter...\\
Here's a picture:\\
\includegraphics{Images/exampleimage.png}

Which generates this pdf.