# Why can't I get the height of my memoir typeblock right?

I'm trying to define my own type area on A5 paper using the memoir commands, according to the following construction after Tschichold, where the text width is given by Høgholm's curve fitting of Bringhurst's copyfitting table:

If we ignore for the moment that the header should probably be considered part of the type area with the style used in the following MWE, the definition should be relatively straightforward:

\documentclass{memoir}
\renewcommand*{\sfdefault}{uop} % Classico (Optima clone) font
\renewcommand{\familydefault}{\sfdefault} % sans serif default
\setstocksize{210mm}{148.5mm}
\settrimmedsize{210mm}{148.5mm}{*}
\setlxvchars
\settypeblocksize{*}{\lxvchars}{1.41421356}
%\settypeblocksize{*}{289.25285pt}{1.41421356}
%\settypeblocksize{409.06398pt}{289.25285pt}{*} % should be the same as either definition above
\setulmargins{21.9mm}{*}{*}
%\setulmargins{*}{*}{2} % should be about the same as the definition above
\setlrmargins{*}{*}{2}
\setheaderspaces{*}{18.06749pt}{*} % keep standard head sep because I don't know how to determine the "right" one
\checkandfixthelayout
\pagestyle{ruled}
\usepackage{layouts}
\usepackage{lipsum}
\begin{document}
\chapter{Lorem Ipsum}
\section{Dolor Sit Amet}
\lipsum\lipsum
\newpage
\pagevalues
\begin{figure}
\currentstock
\oddpagelayouttrue
\stockdiagram
\caption{Odd page layout for this document}
\end{figure}
\end{document}


This is the output of \checkandfixthelayout:

Stock height and width: 597.50787pt by 422.52342pt
Top and edge trims: 0pt and 0pt
Page height and width: 597.50787pt by 422.52342pt
Text height and width: 418pt by 289pt
Spine and edge margins: 44.41833pt and 88.85223pt
Upper and lower margins: 62.80518pt and 116.7027pt
Headheight and headsep: 12pt and 18.06749pt
Footskip: 25.29494pt
Columnsep and columnseprule: 10pt and 0pt
Marginparsep and marginparwidth: 7pt and 74.85223pt
Sidecapsep and sidecapwidth: 7pt and 128pt
Sidebarhsep and sidebarwidth: 7pt and 128pt
Sidebarvsep and sidebartopsep: 12pt and 0pt
Sidebarheight: 548.39996pt
Sidefoothsep and sidefootwidth: 7pt and 128pt
Sidefootvsep and sidefootheight: 12pt and 548.39996pt


However, this is what the following values should look like:

\paperheight = 597.507874pt
\paperwidth = 422.523425pt
\textheight = 409.06530pt
\textwidth = 289.25285pt
\spinemargin = 44.1017717pt
\uppermargin = 62.3115354pt


The crucial difference is in \textheight which is about 9pt too large.

This is also visible when the diagonals from the construction are overlaid on top of the actual text:

It might well be that I made a stupid mistake or misunderstood the memoir manual. In either case, I'd be really glad if someone could tell me what causes the problem.

-
Memoir manual p23: \checkandfixthelayout[fixed]. You'll get underfull vboxes without \raggedbottom. – Lev Bishop Nov 4 '13 at 4:18
Memoir's description of the "classic" algorithm doesn't match its formula. It is claimed to get "as close to H as possible from below" (my emphasis). If so, the formula should be $b\lfloor(H-t)/b\rfloor + t$. That would produce 406pt in the given case. – Dan Nov 4 '13 at 18:46
@Dan True, especially since it makes it sound as if nearest is the only algorithm that will produce a larger actual than nominal textheight: "In contrast to classic, nearest will get as close to H as possible even if this means that T ends up being slightly larger than H." So I guess my best option will be to actually include the header in the type area and adjust \headsep to make \textheight a multiple of \baselineskip. – Christian Nov 6 '13 at 15:55

## 1 Answer

I put this in an answer so I can use images and stuff. It were the comments by Lev and Dan who pushed me in the right direction though so please feel free to provide a "proper answer" (i.e. not one by myself) and I'll gladly accept it.

So it turns out with all my construction stuff I didn't even think of the fact that text comes in these discrete units called "lines" and designing a type area to be say 34.09 lines high might be what the maths tells you but it has other drawbacks such as decreased legibility of the last line with 90% of it missing. (However, why memoir "fixes" this in ways that reading the documentation would never lead you believe is a totally different matter.)

Anyway, turns out there is an easy fix considering that I wanted to improve upon my first draft anyway by regarding the header a part of the type area. So now it includes a part that is not discrete which is the \headsep.

memoir makes it surprisingly complicated to layout a page where the header is not part of the upper margin (since it is part of \uppermargin … yeah). I will include the ugly code after the pretty picture. It's ugly not primarily because of memoir but because I am lazy and inconsistent with my variable names and looking up which internally used variables I could reuse. I also should be using more of those ugly temporary @ macro names instead of cluttering the name space with variations on variables that already exist. (Also I could just have calculated everything in advance but where would be the fun in that.)

The important part is: everything lines up wonderfully (oh the pun) and including the header in the type area makes all the calculations suddenly seem worthwhile. The \headsep shrank by about 30% but I personally think that this is totally acceptable and works even quite ok with the idea of the header being part of the type area (also the alternative would be to make it one whole \baselineskip larger which is obviously totally ridiculous).

\setlxvchars
\newlength{\typeareaheight}\setlength{\typeareaheight}{1.41421356\lxvchars} % this factor works for all A-series paper formats ... and only for those
\newlength{\minheadsep}\setlength{\minheadsep}{.8\baselineskip} % completely arbitrary minimal \headsep
\newlength{\correctedheadsep}
\newlength{\headerheight}\setlength{\headerheight}{\baselineskip}
\newlength{\correctedtextheight}
\setlength{\correctedtextheight}{\typeareaheight}
\makeatletter
\setlength{\@tempdima}{\typeareaheight}%
\addtolength{\@tempdima}{-\headerheight}%
\addtolength{\@tempdima}{-\minheadsep}%
\divide\@tempdima \baselineskip
\@tempcnta=\@tempdima
\setlength{\correctedtextheight}{\@tempcnta\baselineskip}%
\makeatother
\setlength{\correctedheadsep}{\typeareaheight}
\addtolength{\correctedheadsep}{-\correctedtextheight}
\addtolength{\correctedheadsep}{-\headerheight}
\settypeblocksize{\correctedtextheight}{\lxvchars}{*}
\newlength{\totaltopmargin}
\setlength{\totaltopmargin}{21.9mm}
\addtolength{\totaltopmargin}{\headerheight}
\addtolength{\totaltopmargin}{\correctedheadsep}
\setulmargins{\totaltopmargin}{*}{*}
\setlrmargins{*}{*}{2}
\setheaderspaces{*}{\correctedheadsep}{*}
\checkandfixthelayout[fixed]

-