101

I am using report document class. When I create a new chapter, it starts it on a new blank page in which only the chapter name appears.

I want to be able to start new chapters on the same page as the old chapter ends. Is there any way to do it?

lockstep
  • 250,273
prakashkut
  • 1,265

3 Answers3

87

The \chapter command internally uses \cleardoublepage and \clearpage to add page breaks. Use the etoolbox package to selectively change the definition of \chapter.

\documentclass{book}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\makeatother

\begin{document}

\chapter{foo}

Some text.

\chapter{bar}

Some text.

\end{document}

Note: This etoolbox hack also works for the report class.

For KOMA-Script scrbook from version 3.19a (and most likely for other KOMA-Script classes, too), you need to patch \scr@startchapter instead of chapter:

\usepackage{etoolbox}
\makeatletter
\patchcmd{\scr@startchapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\makeatother
lockstep
  • 250,273
  • It is working only for the first chapter. Is it because, I have something like, \chapter{Introduction} \include{text/intro} . Is it because of the include block ? Sorry for the bad formatting – prakashkut Jul 25 '11 at 17:47
  • 1
    @Prakashkumar: Indeed. \include adds page breaks before and after it. – lockstep Jul 25 '11 at 17:49
  • Is there any way to remove page breaks before and after \include because, I have separated my document into almost 30 LATEX files and I include all of them inside the parent LATEX file. – prakashkut Jul 25 '11 at 17:52
  • 5
    Try to use \input instead. See When should I use \input vs \include? for details. – lockstep Jul 25 '11 at 17:56
  • So, it works now. After putting input instead of include. But another issue has come up. The Chapter names do not come in the new line. Instead some of the chapter names get attached to the content of the previous chapter. Is there any way I can make the Chapter names appear in a new line ? – prakashkut Jul 25 '11 at 18:13
  • 1
    @Prakashkumar: I'm not sure what you mean with "do not come in the new line". Please edit your question and add a compilable example that shows the problem like I did in my answer. (You may have to register at tex.sx in order to edit your question.) – lockstep Jul 25 '11 at 18:16
  • thank you so much ! I think earlier I was trying to put a lot of code to do the same thing. Just replacing include by input worked absolutely fine. – prakashkut Jul 25 '11 at 18:34
  • Using this approach in combination with the twocolumn documentclass option results in "Float(s) lost"...?!? – DevSolar Nov 13 '11 at 15:33
  • @DevSolar: The \chapter command is used somewhat different inside twocolumn, and so another approach may be needed. Please ask a new question so that other users might be able to answer (and to locate the answers.) – lockstep Nov 13 '11 at 15:38
  • That would be this question then, assuming it gets enough re-opening votes... – DevSolar Nov 13 '11 at 16:13
  • How could I do the same for a section. Meaning, if one section finishes with enough room left on the page, I would like to start the next section there. I tried just replacing \chapter with \section, but it didn't seem to work. Thanks! – spencerlyon2 Mar 10 '14 at 20:16
  • Replacing it to \par\relax would be better. – Ch'en Meng Apr 21 '15 at 02:02
  • With a KOMA-Script class use \RedeclareSectionCommand[style=section,indent=0pt]{chapter}. See also https://tex.stackexchange.com/q/443736/43317. – esdd Jul 29 '18 at 22:48
  • Not sure, but looks simulat to openany option – Alexey Shrub Jul 29 '20 at 17:46
  • I have a similar problem in KOMA, but I want the part to appear on the same page as the chapter, what would I have to patch in that case? – Aradnix Apr 24 '22 at 02:35
81
\documentclass{report}
\begin{document}

\chapter{foo}

{\let\clearpage\relax \chapter{bar}}
\chapter{baz}
\end{document}

use \cleardoublepage instead of \clearpage for a two sided document

  • 1
    This worked with KOMA-Script scrbook, too. – Kubo Jul 08 '18 at 13:08
  • This might not work with \part in scrbook (as for me) – NCH32 Jul 15 '20 at 08:07
  • This only affects a single chapter, right? So it would fit better to this question: https://tex.stackexchange.com/questions/131460/remove-pagebreak-after-a-chapter-only-for-one-chapter – xeruf Jun 17 '21 at 09:22
  • I was specially struggling to put an abstract at the bottom of the first page of my report, and this did the job \vspace*{\fill} {\let\clearpage\relax\chapter*{Abstract}} – Naghi Dec 18 '21 at 09:40
20

I have used this whenever I needed to add one chapter to the previous page:

\begingroup
\let\clearpage\relax
\chapter{My Chapter}
\endgroup

It doesn't change the rest of the chapters, or anything else in the document.

Tvde1
  • 439
  • This is essentially the same answer as above (https://tex.stackexchange.com/a/24068/94816). – Watson Sep 13 '22 at 12:54