How to have no pagebreak after \include in LaTeX
My LaTeX makes me pagebreaks after each subsection because my subsections are in separate files. I use the command \include{file}
which adds a pagebreak after the use of it.
I would like to have no pagebreak caused by the use of \include{file}
.
How can you no pagebreak after the use of include
-command?
\include
always uses \clearpage
, a not entirely sensible default. It is intended for entire chapters, not for subsections (why would you want subsections in separate files, anyway?).
You can fix it either by using \input{filename}
or loading the newclude
package and writing \include*{filename}
instead.
You can stop pagebreaks caused by \include
by placing \let\clearpage\relax
before it. So,
\let\clearpage\relax
\include{file1}
\include{file2}
\include{file3}
would put the contents of the three files (and any subsequently included files) together without a pagebreak between them. If you want to stop relaxing the \clearpage
command, then wrap the files to include without pagebreaks within a group like this:
\begingroup
\let\clearpage\relax
\include{file1}
\include{file2}
\endgroup
\include{file3}
This will stop a pagebreak between file1 and file2, but insert the normal pagebreak after file2. (Note: I do not know if this interferes with referencing and page numbering, though I imagine it should be OK.)