[texhax] `\vtop to 0pt' produces a vertical shift: is that normal?

Oleg Katsitadze olegkat at gmail.com
Wed Jun 24 06:40:56 CEST 2009


On Sun, Jun 21, 2009 at 04:54:43PM +0100, Rodolfo Medina wrote:
> With plain TeX: if I put a `\vtop to 0pt{}' after a `\par' command, that
> produces a vertical shift, whereas one would expect a vertical box of height
> zero to not produce any visible vertical effect at all.
>
> Why does this happen

TeX inserts glue between boxes in vertical list to keep the baselines
equal distance apart.  So your zero-height vbox actually adds non-zero
baseline skip.  You can see this for yourself by running the following
input through TeX and examining the log:

---------------->%----------------
1

\vtop to 0pt{}

2

3

\tracingonline=1
\showboxbreadth=10000
\showlists

\bye
----------------%<----------------

Notice that the baselines are exactly 12pt apart.

> and how to work it out?

You can try this:

---------------->%----------------
\newdimen\savedepth

y

\savedepth=\prevdepth
\nointerlineskip
\vtop to 0pt{}
\prevdepth=\savedepth

2

3

\tracingonline=1
\showboxbreadth=10000
\showlists

\bye
----------------%<----------------

However this kind of trickery is very troublesome.  There will be
issues with spacing/penalties when page break falls around the
injected material.

Best,
Oleg


More information about the texhax mailing list