3

I have a document like this:

\documentclass{article}

\begin{document}
\include{sect1}
\include{sect2}
\end{document}

Both files sect1.tex and sect2.tex begin with \section{...}. The output pdf file displays section 1 and section 2 on two different pages even though section 1 only occupies about 10 lines in the first page. Is there any way I can force section 2 to start right after section 1 one the same page?

3
  • And if those sections are so short why do you use include instead of put them inside the body of the document? I use \includewith big documents such as books and the most of times with chapters not sections.
    – Aradnix
    Aug 18, 2014 at 1:42
  • 3
    Regarding When should I use \input vs. \include?, you should use \input instead of \include. \include inserts a \clearpage, which creates a pagebreak.
    – dawu
    Aug 18, 2014 at 1:43
  • @Aradnix: There are some sections that are really long. The above example is just an overly simplified version of it. Aug 18, 2014 at 2:06

1 Answer 1

8

\include{filename} and input{filename} both import the file with the filename into the document. The most important difference of these commands in your case is, that \include inserts a \clearpage after the file (which creates a pagebreak), while \input only inserts the content of your file. So you should use \input to avoid pagebreaks.

More detailed information can be found at When should I use \input vs. \include?.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .