2

Consider the code

\documentclass[openany]{book}
\usepackage{lipsum}
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}
\usepackage{xcolor}

\begin{document} \thispagestyle{empty} \Large \chapter{\textcolor{red}{1}} \lipsum[13] \chapter{\textcolor{red}{2}} \lipsum[19] \chapter{\textcolor{red}{3}} \lipsum[13] \chapter{\textcolor{red}{4}} \lipsum[19] \end{document}

which produces the output:

enter image description here

enter image description here

Here, a new chapter always begins on a new page. I would change this.

QUESTION: How may I begin a new chapter on the same page (space permitting) that the previous chapter ended (i) on a selective basis (i.e., for only certain chapters); and (ii), on a global basis (i.e., for all chapters)?

Thank you.

DDS
  • 8,816
  • 4
  • 9
  • 36
  • For the book class, a new \chapter usually starts on a new page. Have you considered using \section with, say, the article class? That said, if you must, this should help: https://tex.stackexchange.com/questions/24066/start-new-chapter-on-same-page – Ingmar Oct 26 '21 at 07:03

1 Answers1

3

The following hack works in your case:

\usepackage{etoolbox}
\patchcmd{\chapter}{\clearpage}{\par}{}{}

enter image description here

The complete code is

\documentclass[openany]{book}
\usepackage{lipsum}
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}
\usepackage{xcolor}

\usepackage{etoolbox} \patchcmd{\chapter}{\clearpage}{\par}{}{}

\begin{document} \thispagestyle{empty} \Large \chapter{\textcolor{red}{1}} \lipsum[13] \chapter{\textcolor{red}{2}} \lipsum[19] \chapter{\textcolor{red}{3}} \lipsum[13] \chapter{\textcolor{red}{4}} \lipsum[19] \end{document}

Jinwen
  • 8,518