How to force text block on first page of chapter to line up with other pages?

Hello fellow TeXnicians,

I am facing a frustrating problem when trying to typeset a book using the memoir class. I have designed a nice chapter and heading style, but I have broken it down to the following MWE:

% !TEX TS-program =xelatex
% !TEX encoding = UTF-8 Unicode
\documentclass[12pt,a5paper]{memoir}

\usepackage{lipsum}
\usepackage[ngerman]{babel}

\settypeblocksize{160mm}{100mm}{}
\setulmargins{*}{25mm}{*}
\setlrmargins{25mm}{*}{*}
\checkandfixthelayout
\flushbottom

\setlength{\parskip}{0\baselineskip}

\begin{document}
\chapter{Nice Chapter}
\section*{Good Section}
\lipsum*
\end{document}


Now there is one line of text too much on the first page, so that the textblocks are not lined up properly.

How do I force the first page to line up with the other pages? Which distances can I tweak to accomplish this?

The textblocks will actually line up when removing the settypeblocksize command, but then the text block does not have correct dimensions.

The desired output would look more like this:

The "good" example has been produced by removing settypeblocksize, but as you can see, the rest of the layout is completely different (and that's not desired.)

Following from @barbarabeeton in your MWE change

\checkandfixthelayout


to

\checkandfixthelayout[lines]


which will ensure that the text height is (slightly) adjusted such that an integral number of lines in the body font will fit exactly into the height. For further information on this see the memoir manual (> texdoc memoir).

• Wouldn't setting the singlespacing do the same? And of course do it before setting the layout, see my answer. – daleif Apr 7 '18 at 21:18

IMO, it is better to use memoir's own interface instead of \linespread.

This seems to do the trick

\setSingleSpace{1.2}
\SingleSpace

\settypeblocksize{160mm}{100mm}{}
\setulmargins{*}{25mm}{*}
\setlrmargins{25mm}{*}{*}
\checkandfixthelayout
\flushbottom


I verify by adding these lines as well (draws the textblock)

\pagestyle{showlocs}
\aliaspagestyle{chapter}{showlocs}


Ans then import the PDF into this doc:

\documentclass[a4paper,landscape]{memoir}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages=-,nup=2x1]{imf.pdf}
\end{document}


• I will check it out and see if it makes any difference. – Stefan Schroeder Apr 9 '18 at 8:05

You can add some stretchability to the \baselineskip to allow TeX to adjust to fit the page:

\setlength\baselineskip{\the\baselineskip plus 0.5pt minus 0.5pt}


This will allow the \baselineskip to stretch up to 0.5pt or shrink up to 0.5pt between lines. I tested and these values seem to be enough.

Also, I put the redefinition of the \baselineskip in an \AtBeginDocument hook because its definition happen somewhere in \begin{document}.

% !TEX TS-program =xelatex
% !TEX encoding = UTF-8 Unicode
\documentclass[12pt,a5paper]{memoir}

\usepackage{lipsum}
\usepackage[ngerman]{babel}

\settypeblocksize{160mm}{100mm}{}
\setulmargins{*}{25mm}{*}
\setlrmargins{25mm}{*}{*}
\checkandfixthelayout
\flushbottom

\setlength{\parskip}{0\baselineskip}

\AtBeginDocument{%
\setlength\baselineskip{\the\baselineskip plus 0.5pt minus 0.5pt}}

\begin{document}
\chapter{Nice Chapter}
\section*{Good Section}
\lipsum*
\end{document}

• wouldn't a better approach be to set the size of the text block to be an exact multiple of \baselineskip plus \topskip? (in other words, accommodating a grid.) stretchability in \baselineskip can lead to other kinds of misalignment. – barbara beeton Apr 7 '18 at 13:24
• how would you do that? – Stefan Schroeder Apr 7 '18 at 13:47
• I want to to thank you, Phelype, for the extensive answer. It helped me understand the issue much better. Nevertheless I marked the answer by Peter as 'the answer', because I feel that it is less intrusive. Thank you anyway for taking the time to explain it. – Stefan Schroeder Apr 7 '18 at 20:42