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}
\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.\chapter
does many things before it calls\chapterlinesformat
.