# [texhax] \vskip at beginning of file

Thu Jul 21 14:09:25 CEST 2016

On Wed, Jul 20, 2016 at 18:34 (+0000), Daniel H. Luecking wrote:

> Jim Diamond wrote:
>> In the context of someone putting some space at the top of the page,
>> can anyone explain to me why we care about preserving \prevdepth ?

> When a line of text is placed on a page, TeX tries to place it
> With its baseline exactly one \baselineskip below the previous
> line, so TeX inserts enough extra vertical space to achieve that
> effect.

> This process ignores any vertical space you insert yourself, but
> does take into account the depth of the previous line (stored in
> \prevdepth). So the amount of extra space added is \baselineskip
> minus \prevdepth minus the height of the line being added, if
> that calculated value is positive.

> However, if \prevdepth is equal to exactly -1000pt then the extra
> space is not added. TeX sets \prevdepth to -1000pt at the start of
> page and after an \hrule.

> Thus,
> \hrule height 0pt
> \vskip -\topskip
> \vskip 5in
> %\prevdepth now -1000pt
> Text\vfil\eject
> will place "Text" with the top of the "T" at exactly 5 inches
> below \voffset.

> But
> \null % place an empty line
> \vskip-\topskip
> \vskip 5in
> %\prevdepth now 0pt
> Text\vfil\eject
> will place "Text" slightly lower (by the amount \baselineskip
> minus the height of the "T").

> HTH

Daniel,

thanks for the detailed description of the process.

However... I was focusing on the specific issue of using \topglue
("\topglue" was in the text I replied to, but not in my text itself).
Specifically, I was referring to the comment:

>>> \topglue uses \hrule height 0pt as the basic node to prevent the
>>> skip being discarded but takes care not to disturb \prevdepth,

Your example shows why we don't want to use \null to prevent a \vskip
from disappearing at the top of a page, but I'm still not clear on why
we care about preserving \prevdepth *in \topglue*.

Here are two pages, the first one done with the \vglue commands minus
the ones which save \prevdepth, and the second with \vglue.  They seem
to put the "Text" at the same spot on the page, even though the second
page preserves the page's initial \prevdepth.

So.. does \topglue really care about preserving \prevdepth, or is it
merely the case that \topglue (coincidentally) uses \vglue, and it is
other uses of \vglue that care about preserving \prevdepth ?

\nointerlineskip
\hrule height 0pt
\vskip-\topskip
\hrule height 0pt
\vskip 5in
Text\vfil\eject

\topglue 5in
Text\vfil\eject

\bye

Cheers.

Jim