[Tex/LaTex] \prevdepth and \noalign

tex-core

In The TeXBook it says

The value of \prevdepth at the time of the \halign is used at the
beginning of the internal vertical list, and the final value of
\prevdepth is carried to the enclosing vertical list when the
alignment is completed, so that the interline glue is calculated
properly at the beginning and end of the alignment.

In section 15.2 of TeX by Topic, it says

At the beginning of a vertical list \prevdepth is set to -1000pt,
except in an \halign and \noalign code contained therein, where it
is carried over from the surrounding list.

I'm able to understand the sentence in The TeXBook, but could not understand the sentence in TeX by Topic. Could someone give some examples about \prevdepth and \noalign?

Best Answer

this plain tex file

\def\foo#1{\edef\tmp{\immediate\write20{#1: \the\prevdepth}}\tmp}


\foo{1}
g


\foo{2}

\vbox{
\foo{3}

Q

\foo{4}
}

\foo{5}

a,

\foo{6}

\halign{#\hfil\cr
\noalign{\foo{7}}
 z\cr}

\foo{8}


\bye

produces

1: -1000.0pt
2: 1.94444pt
3: -1000.0pt
4: 1.94444pt
5: 1.94444pt
6: 1.94444pt
7: 1.94444pt
8: 0.0pt

showing that \prevdepth has the magic -1000pt value at the start of the main vertical list and at the start of a \vbox but not in the \noalign.