0

Each time I produce a new chapter, I want to have a single page with the chapter title at the center of it. Following the KOMA-script documentation, and looking online, I've managed to do it by redefining \chapterlinesformat.

Here is what I don't understand:

  • If I use my code to center some content inside the document, everything works fine
  • If I use the same code to rewrite \chapterlinesformat, a blank page appears
  • So clearly \chapterlinesformat do something just before it writes the chapter.

Online searches quickly told me that a blank page before chapter was usually because of odd/even numbered pages or such, and that a quick fix was to use openany/oneside option. I've tried to look at KOMA-script documentation to understand where this blank page came from, without success.

Here is my MWE:

\documentclass[oneside, openany]{scrbook}
\usepackage{xparse}
\usepackage{blindtext}

\DeclareDocumentCommand\chapterheadstartvskip {}{}
\DeclareDocumentCommand\chapterheadendvskip {}{}

\DeclareDocumentCommand\chapterlinesformat {mmm}
    {
    \clearpage %need to be removed for no blank page before \chapter, why?
    \topskip0pt
    \vspace*{\fill}
    \begin{center}
    #3
    \end{center}
    \vfill
    \clearpage
    }

\begin{document}

\blindtext

% DO NOT PRODUCE BLANK PAGE BEFORE Test
\clearpage
\topskip0pt
\vspace*{\fill}
\begin{center}
Test
\end{center}
\vfill
\clearpage

\blindtext
%BLANK PAGE before Chapter, why?
\chapter{Chapter}

\blindtext

\end{document}
4
  • I've added a \blindtext before the first centered text and the problem is still the same. Even if I add \null before \clearpage in both cases, I still have the same issue. Nov 3, 2016 at 15:24
  • Sorry, I must have misunderstood the question. What is exactly bothering you? \clearpage does not mean "make a blank page". \chapter already issues a \clearpage (or \cleardoublepage), then does some typesetting, and that's why the second \clearpage in \chapterlinesformat makes another new page, effectively leaving one blank.
    – campa
    Nov 3, 2016 at 15:32
  • Ok I understand, now, \chapter already issues a \clearpage. Nov 3, 2016 at 15:38
  • \chapter does many things before it calls \chapterlinesformat.
    – esdd
    Nov 3, 2016 at 17:07

2 Answers 2

2

There is no need to redefine \chapterlinesformat. You can simple redefine \chapterheadstartvskip, \chapterheadendvskip, \raggedchapter and \chapterformat to get

enter image description here

\documentclass[oneside]{scrbook}
\usepackage{blindtext}

\renewcommand*\chapterheadstartvskip{\vspace*{-\topskip}\vfill}
\renewcommand*\chapterheadendvskip{\vfill\clearpage}
\renewcommand*\raggedchapter{\centering}
\renewcommand*\chapterformat{}

\begin{document}
\clearpage
\vspace*{-\topskip}
\vfill
\begin{center}
Test
\end{center}
\vfill
\clearpage
\blindtext
\chapter{Chapter}
\blindtext
\end{document}

You can redefine \chapterformat to change the layout of the chapter number. Simple example:

\documentclass[oneside]{scrbook}
\usepackage{blindtext}

\usepackage{tikzpagenodes}

\renewcommand*\chapterheadstartvskip{\vspace*{-\topskip}\vfill}
\renewcommand*\chapterheadendvskip{\vfill\clearpage}

\renewcommand*\raggedchapter{\centering}
\renewcommand*\chapterformat{%
  \tikz[remember picture,overlay]
    \path(current page text area.center)node[scale=30,lightgray]{\thechapter};%
}

\begin{document}
\clearpage
\vspace*{-\topskip}
\vfill
\begin{center}
Test
\end{center}
\vfill
\clearpage
\blindtext

\chapter{Chapter}
\blindtext
\end{document}

Result:

enter image description here

4
  • I'm also doing fancy things with the chapter number that wasn't relevant to the problems, adding it super-large to the background of the page with a tikzpicture Nov 3, 2016 at 16:45
  • You could redefine \chapterformat. See the example in my updated answer.
    – esdd
    Nov 3, 2016 at 17:04
  • So when to use \chapterlinesformat? Nov 3, 2016 at 17:16
  • You can use \chapterlinesformat to change the order of number and title or to put them together in a frame. You have to redefine this command if there should be a rule above and/or below of the chapter heading or if you want use \MakeUppercase for the chapter heading etc.
    – esdd
    Nov 3, 2016 at 17:39
1

The answer to my question is simply that \chapter issues a \clearpage or \cleardoublepage, so since there is already one \clearpage at the beginning in the command I created with \chapterlinesformat, this creates a blank page when I call \chapter

Thanks to campa for the answer.

1
  • 1
    note just calling \clearpage would not be enough to cause this (two consecutive \clearpage do not make a blank page) but the chapter code has already put something (a box or a \write for example) on to the page so the \clearpage that you add does cause a page that is all white (but not empty according to TeX's internal view) to be shipped out. Nov 3, 2016 at 16:17

You must log in to answer this question.

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