I know questions about grid typesetting have been asked before, and some packages (grid
, gridpos
) exist. The scenario I have at the moment is simpler than that, and is mostly a question about elastic lengths. I'm not claiming the result is excellent typography, but I'm curious whether and how it could be done :)
In typesetting my thesis, I have a page where \textheight
is an exact multiple of \baselineskip
, so I can fit exactly 34 lines of text into the page. The section and subsection commands are defined by the style file as
\renewcommand\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\def\baselinestretch{1.0}\reset@font\normalsize\bfseries\slshape}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\reset@font\normalsize\mdseries\itshape}}
(Which as far as I can tell have been copied and pasted from elsewhere on the web without any particular rhyme or reason. Why should the space around section headings have anything to do with the x-height of the font?)
On pages that have 0 or 2+ section headings, there is enough stretchability around the headings to account for their non-integral-multiple-of-\baselineskip
heights. On pages that have 1 section heading in the middle of the page, there is again enough stretchability before and after the heading. But on pages where the section heading is the first thing in the page, the before-heading space is elided, along with its stretchability, and I get underfull \vbox
es.
My question is, is there a way to change the spaces in these definitions so that when a section heading starts a page, it skips a full line, but when it is in the middle of the page, it uses these smaller stretchabilities? A manual solution is to insert \vspace*{0pt plus 0.5\baselineskip}
at each problematic section heading, which lets TeX "round up" to the next nearest line, but if I simply insert that spacing everywhere, then TeX will use that stretch even when it doesn't need to... I tried looking at the internal definitions of \@startsection
and \@ssect
, but I don't see any way for them to detect when the before-space is elided from the page.