Multi-File LaTeX Projects: \input vs \include
Use \input{file} to insert content inline and \include{file} for chapters on a new page with selective compilation via \includeonly. Here's when to use each.
In a multi-file LaTeX project, use \input{file} to insert content inline with no page break, and \include{file} to insert a chapter on its own page with optional selective compilation. Splitting a long document into files makes each section editable on its own, reduces merge conflicts when co-authoring, and — with \includeonly — lets you recompile just the chapter you're working on. Here's how to structure it.
1. The project layout
main.tex ← preamble + document environment
sections/
intro.tex
method.tex
results.tex
frontmatter/
titlepage.tex
Keep the preamble (\documentclass, every \usepackage, \begin{document}) only in main.tex. The content files hold body text only.
2. \input — inline insertion
\input{frontmatter/titlepage}
\input{sections/intro}
\input pastes the file exactly where it appears, with no page break, and can be nested. Use it for title pages, small tables, repeated boilerplate, or any fragment.
3. \include — chapter-sized units
\include{sections/intro} % forces \clearpage before + after
\include{sections/method}
\include adds a page break around the content and supports selective compilation. It can't be nested inside another \include. Use it for chapters — the backbone of the thesis template.
4. Compile only what you're editing
\includeonly{sections/method} % in the preamble
LaTeX compiles only method.tex but keeps page numbers and cross-references from the others (via their .aux files). On a long thesis this turns a 30-second build into a 3-second one — provided every chapter was compiled at least once.
5. input vs include at a glance
| | \input | \include |
|---|---|---|
| Page break | No | Yes (before + after) |
| Nestable | Yes | No |
| Works with \includeonly | No | Yes |
| Best for | Fragments | Chapters |
Multi-file structure also reduces contention during real-time collaboration, since authors edit different files. When submitting to arXiv, flatten the files into one folder.
→ Manage multi-file projects with live preview and co-editing in LetX.
Written by Shihab Shahriar Antor — AI Engineer & Founder of Shahriar Labs, maker of LetX.
Frequently Asked Questions
What is the difference between \input and \include in LaTeX?
\input{file} pastes the file's content exactly where the command appears, with no page break, and can be nested freely — ideal for small fragments like a title page or a table. \include{file} forces a \clearpage before and after, so it's designed for chapters, and it works with \includeonly to compile only selected files. You cannot nest \include inside another \include. Use \input for fragments and \include for chapter-sized units.
How does \includeonly speed up compilation?
\includeonly{chapters/method} in the preamble tells LaTeX to compile only the listed \include files while preserving page numbers and cross-references from the others via the .aux files. For a 300-page thesis, this means you recompile just the chapter you're editing instead of the whole document, cutting compile time dramatically. The catch is that all chapters must have been compiled at least once so their .aux files exist.
Should I put the preamble in every file?
No. Keep one main file that has the \documentclass, all \usepackage lines, and the \begin{document}/\end{document}, then pull in content files with \input or \include. The included files contain only body content — no preamble, no document environment. This keeps package loading in one place and lets you compile the project from the single main file.