input and include

StartLaTeX Topics

1 input and include

The two commands input and include are used to include tex file into other tex files. Although both commands do exactly the same thing at first glance, there are some differences between them.
Why is it used at all?

The main reason why the commands input and include are used is to keep track within large documents. By using them, a document can be split into several smaller sections. This can be advantageous for troubleshooting, among other things. The following figure shows an example of the structure of a larger document using the input command. First of all the note that this could not have been realized with the include command.

Example for the organization of a larger document using the input command.
Figure 1: Example for the organization of a larger document using the input command. Own representation.

2 input

The command \input{filename} places the contents of the file filename.tex where it was set. For the representation of the content it makes no difference whether the content has been included via the input command or the content has been written directly into the target file. The command input can be set in the preamble (document header) as well as in the document (text body). In addition, the input command can also be nested. This means a file which is included in a target file by means of input, can in turn include file(s) by means of input.

Hints for input

Even though input can be set anywhere, files containing usepackage can only be included in the preamble. It is also important to note that only the file named Master.tex (see Figure 1) is compiled. With the other tex files you get the error message that they are not LaTeX root documents.

3 include

The \include{filename} command generates a page break before and after inserting content. For this reason, the command can only be set within the document (text body). The \include{filename} command cannot be nested. This means that a file that has been included into a target file cannot include any file(s).

Hint: In a file that has been included with input, another file can be included with include.
Why include?

The reason why there is include and why it was used earlier is the command \includeonly{File1,File3} which determines in the preamble which files should be recompiled. At a time when computers still had turbo keys, this saved a considerable amount of time. With the efficiency of the current computers this does not play however any more role.

4 Conclusion

Since the input can be used everywhere and can be nested, and the speed advantage today only plays a subordinate role with include, the use of input is recommended.

Contact   Privacy Policy   disclosures

accept decline

This website uses cookies and pixel tags to ensure you get the best experience on our website. By using this website, you consent to the use of cookies.learn more about cookies see also our privacy policy