You are here: Home / Przedsięwzięcia/Projects / TeX Pearls / 2007 Pearls / heiko-oberdiek / ShipoutLastkern.tex


TeX document icon ShipoutLastkern.tex — TeX document, 1 KB (1943 bytes)

File contents



  \texttt{\textbackslash #1}%

  Safe redefinition of \cs{shipout} (II)
  using \cs{lastkern} without \eTeX
\author{Heiko Oberdiek}
\date{27th April 2007}


Goal: Redefine \cs{shipout} to do something with its box.

First we catch its box by \cs{setbox} and \cs{afterassignment}:
\shipout := \afterassignment\@Test
There are two different cases:
(a) \shipout\box0      -> \setbox\@Box=\box0 \@Test
(b) \shipout\vbox{...} -> \setbox\@Box=\vbox{\@Test ...}
In the latter case we want to postpone macro \cs{@Test} after the
\cs{vbox} group by \cs{aftergroup}.
But how can we differentiate between these cases?

In case (b) we are at the start of a new box. Here \cs{lastkern}
always returns 0pt.
\shipout := \begingroup
                \global\setbox\@Box= % \global is necessary
\@Test   :=     \ifdim\lastkern=0pt
\@Output :=   \egroup
              % original \shipout ignores void boxes
              % do something with box \@Box
This is one of the methods implemented by package \xpackage{atbegshi}.

Document Actions