I am trying to get a baseline grid in the background of every page. I am using the plain format with XeTeX. This is what I have tried:
\baselineskip=13pt
\topskip=0pt \parskip=0pt
\newbox\gridbox
\setbox\gridbox\line{%
\special{color push rgb .8 .8 1}%
\vrule height\baselineskip width0pt \hrulefill%
\special{color pop}}
\def\grid{\vbox to0pt{%
\vtop to\vsize{\leaders\copy\gridbox\vfil}}}
Now, the above works just fine if I want to have a grid on a single page, by just calling \grid
. However, I'd like it to be in every page, so I tried redefining plain's \pagebody
:
\def\pagebody{\vbox to\vsize{\boxmaxdepth=\maxdepth \grid\pagecontents}}
but the grid keeps drifting from page to page even though I've removed every vertical stretchability/shrinkability.
What am I doing wrong?
UPDATE
Finally I managed to figure out what was causing the weird behaviour in my actual document vs. the minimal: it was \lineskiplimit=-\maxdimen
. No-one could have guessed it of course. I don't know why it affects anything; the way I've understood, its only function is to figure out which one to use, \baselineskip
or \lineskip
, and since I have them both set the same, I had the \lineskiplimit
the way it was. But it seems it's doing something besides that (I've already removed it from the \displ@y
macro, for example).