\input vs \include
\input for inline insertion. \include for chapter-level includes that work with \includeonly for fast iteration.
The decision matrix
| Use case | Use |
|---|---|
| Tiny snippet (custom commands) | \input |
| Section piece (no page break wanted) | \input |
| Inside math/tabular/figure | \input (only) |
| Chapter file | \include |
| Need to compile one chapter at a time | \include + \includeonly |
| Nested includes | \input only |
\input usage
% main.tex
\documentclass{article}
\input{preamble/packages}
\input{preamble/commands}
\begin{document}
\input{intro}
\input{methods}
\end{document}\include + \includeonly for iteration
% main.tex
\documentclass{book}
\usepackage{...}
% While iterating on chapter 3, compile only that:
\includeonly{chapters/03-results}
\begin{document}
\maketitle
\tableofcontents
\include{chapters/01-introduction}
\include{chapters/02-methods}
\include{chapters/03-results} % only this gets recompiled
\include{chapters/04-discussion}
\bibliography{references}
\end{document}With \includeonly, only the listed files are recompiled — but cross-refs, page numbers, and bibliography from previous full compiles are still respected via the .aux files. Speeds up iteration on long documents (10x+ on a thesis) since you skip recompiling chapters that haven't changed.
Typical thesis structure
my-thesis/
├── main.tex # entry point
├── references.bib
├── preamble/
│ ├── packages.tex # \usepackage commands
│ ├── commands.tex # \newcommand definitions
│ └── theorems.tex # theorem environments
├── frontmatter/
│ ├── titlepage.tex
│ ├── abstract.tex
│ └── acknowledgments.tex
├── chapters/
│ ├── 01-introduction.tex
│ ├── 02-background.tex
│ ├── 03-methods.tex
│ ├── 04-results.tex
│ ├── 05-discussion.tex
│ └── 06-conclusion.tex
└── appendices/
├── a-data.tex
└── b-proofs.tex
% In main.tex:
% \input{preamble/packages}
% \input{preamble/commands}
% \include{frontmatter/abstract}
% \include{chapters/01-introduction}
% etc.Common mistakes
- Using
\includeinside\begin{tabular}or math. Forces a page break — breaks the table/equation. Use\input. - Forgetting
\includeonlyin final compile. Always do a full compile (no\includeonly) for the final PDF. - Including .tex in the filename. Both commands auto-append.
\input{ch1}works;\input{ch1.tex}also works but is unconventional. - Nesting
\include. Doesn't work. Use\inputfor nested files.
#include "chapters/01-introduction.typ"
#include "chapters/02-background.typ"
// Or import a function/value from another file
#import "shared.typ": custom-styleNo \input vs \include distinction — Typst is one function. Plus #import for sharing functions across files. Try TypeTeX free.
Try TypeTeX freeFrequently Asked Questions
\input{file} inserts the contents of file.tex inline at the point of the command — like a literal copy-paste. \include{file} starts the included content on a new page and works with \includeonly to compile selected files only. Use \input for small fragments (preamble pieces, frequently-included snippets), \include for chapter-sized chunks.
For chapters in a book or thesis, where: (1) each chapter is large; (2) you want to compile only one chapter while iterating on it; (3) chapters should always start on a new page anyway. The corresponding \includeonly{ch1,ch3} compiles only chapters 1 and 3, dramatically speeding up iteration on long documents.
For small fragments: a custom commands file, a long preamble split into multiple files, individual figure-heavy sections, or anything that shouldn't force a page break. Also for any file inside a math environment, table, or other non-page-break-friendly context (\include forces page breaks).
\includeonly{file1,file3} in your preamble tells LaTeX to skip all \include commands except those listed. The page numbering and cross-references still work correctly because LaTeX uses .aux files from previous full compiles. After all chapters are stable, run a full compile (no \includeonly) for the final document.
No — both \input and \include automatically append .tex if needed. \input{chapter1} and \input{chapter1.tex} are equivalent. Convention is to omit the extension.
\input can be nested freely (\input inside an \input'd file). \include cannot be nested — \include inside another \include'd file fails. If you need nested structure, use \input throughout, or \include for the top level and \input for nested.
main.tex has the preamble, \begin{document}, \maketitle, \tableofcontents, then \include{frontmatter/abstract}, \include{chapters/01-introduction}, ..., \include{chapters/06-conclusion}, \bibliography{...}, \end{document}. Each chapter is its own .tex file in chapters/.
By design — \include is meant for chapter-level includes, where chapters always start on a new page. If you need an include without a page break, use \input instead. Or wrap your \include with content that doesn't have a page-break expectation.
Yes. For BibTeX/biblatex: \input{...} inside \if blocks works. Or use the standalone package's mode for switchable content. Most authors use \includeonly for selective compilation rather than runtime conditionals.
More LaTeX guides
Next step
Equations stay editable in Word's equation editor; tables and figures are preserved.
Paste LaTeX and get Typst back — no signup. Compiles in milliseconds instead of minutes.
Write, preview, and export in the browser with AI assistance built in.