LaTeX Error: \include cannot be nested

A file loaded with \include contains another \include. Only the main file may \include; inside an included file use \input instead.

Help centre › LaTeX errors › Document structure · Error: the build stops or the output is wrong

What the log says

! LaTeX Error: \include cannot be nested.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.2 \include{chapter1-results}

What it means

\include starts a new page, keeps a separate .aux file for the included part and works with \includeonly; for that it must be used only from the main file. LaTeX found an \include inside a file that was itself loaded with \include.

Causes and fixes

Most common first. Each example is a complete document; the first fails with this message, the second is the same document fixed.

1. An included chapter \includes its sections

Change the inner \include to \input, which simply reads the file in place. Keep \include only in the main file.

Fails
\begin{filecontents*}[overwrite]{results.tex}
Yields rose with temperature.
\end{filecontents*}
\begin{filecontents*}[overwrite]{chapter1.tex}
\section{Results}
\include{results}
\end{filecontents*}
\documentclass{report}
\begin{document}
\include{chapter1}
\end{document}
Fixed
\begin{filecontents*}[overwrite]{results.tex}
Yields rose with temperature.
\end{filecontents*}
\begin{filecontents*}[overwrite]{chapter1.tex}
\section{Results}
\input{results}
\end{filecontents*}
\documentclass{report}
\begin{document}
\include{chapter1}
\end{document}

2. A template's main file was itself \included

A thesis or report assembled from parts sometimes includes a file that is a complete main file with its own \include lines. Load that file's parts directly from your main file, or use \input for the outer file.

In Manulyx

The editor shows the error beside the inner \include, with an explanation.

Write in Manulyx for free · Journal templates

More in document structure

Every example on this page was compiled with pdfLaTeX to check that it fails and is fixed as described. All LaTeX errors