4

I am using the memoir class.

I'm trying to ensure that new chapters happen on the same page as the last one, except in cases where parts of the chapter heading would have been split across two pages.

This is what I've tried:

\renewcommand{\clearforchapter}{}

Which gives me this:

good

But also this:

bad

Is there a simple solution so that the new chapter starts on a new page except in the case where part of it would be split across two pages, in which case there is a page break?

NOTE: here is my custom chapter heading code, although it might not be relevant at all and is not part of my question but is included for the sake of completeness:

\chapterstyle{default}
\renewcommand*{\chapterheadstart}{\vspace*{\beforechapskip}
  \mbox{}\\\mbox{}\rule[0pt]{\textwidth}{0.4pt}\par}
\setlength{\beforechapskip}{0pt}
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\chapnumfont}{\itshape\large}
\settoheight{\midchapskip}{\chapnumfont 1}
\renewcommand*{\printchapternum}{\centering \chapnumfont Chapter \thechapter}
\renewcommand*{\afterchapternum}{\par\nobreak\vskip 0.5\onelineskip}
\renewcommand*{\printchapternonum}{\centering \vphantom{\chapnumfont 1}\afterchapternum}
\renewcommand*{\chaptitlefont}{\scshape\Large}
\renewcommand*{\printchaptertitle}[1]{\centering \chaptitlefont #1
    \\\mbox{}\rule[5pt]{\textwidth}{0.4pt}}
\setlength{\afterchapskip}{1\onelineskip}
  • There is a way to do this, but not easy, but in my point of view, this is ugly: Chapter comes from capitulum, meaning (small) head --> a chapter should start on the head of a page, not somewhere in between – user31729 Jun 17 '15 at 20:08
  • @ChristianHupfer In general I agree, but this an unconventional book, it's actually a very long and rambling dialogue, where the chapters are only there for convenience so the reader can easily find a part of the discussion by topic. – sdegutis Jun 17 '15 at 20:10
  • I see. Well, I imagine, that one way is to put the chapter title into an unbreakable box. It must appear on the page if there is enough space or it will be placed on the next page. – user31729 Jun 17 '15 at 20:14
  • @ChristianHupfer Sounds like a good idea. I will research how to do this (I'm a LaTeX newbie) but in the meantime I hope someone posts this as a full solution with sample code, because it sounds reasonable. – sdegutis Jun 17 '15 at 20:17
  • I would say, a \parbox must be sufficient already – user31729 Jun 17 '15 at 20:20
2

You can use the \needspace macro (directly available in memoir, for other classes there's the needspace package).

\documentclass[b5paper]{memoir}

\usepackage{lipsum}

\renewcommand{\clearforchapter}{}
\pagestyle{plain}
\chapterstyle{default}
\renewcommand*{\chapterheadstart}{%
  \par
  \needspace{10\onelineskip}
  \vspace{\beforechapskip}
  \mbox{}\\\mbox{}\rule[0pt]{\textwidth}{0.4pt}\par}
\setlength{\beforechapskip}{0pt}
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\chapnumfont}{\itshape\large}
\settoheight{\midchapskip}{\chapnumfont 1}
\renewcommand*{\printchapternum}{\centering \chapnumfont Chapter \thechapter}
\renewcommand*{\afterchapternum}{\par\nobreak\vskip 0.5\onelineskip}
\renewcommand*{\printchapternonum}{\centering \vphantom{\chapnumfont 1}\afterchapternum}
\renewcommand*{\chaptitlefont}{\scshape\Large}
\renewcommand*{\printchaptertitle}[1]{\centering \chaptitlefont #1
    \\\mbox{}\rule[5pt]{\textwidth}{0.4pt}}
\setlength{\afterchapskip}{1\onelineskip}

\begin{document}

\chapter{Justin narrates the manner of his conversion}

\lipsum[1]

\chapter{Justin describes his studies in philosophy}

\lipsum[2]

\chapter{Justin does some other things}

\lipsum[2]

\end{document}

enter image description here

| improve this answer | |
  • This works amazingly! – sdegutis Jun 17 '15 at 20:49
  • Wish I could upvote a second time for chapter 3's title. – sdegutis Jun 17 '15 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.