10

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?

8

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.

  • Why couldn't I write \def\foo#1{#1: \the\prevdepth} instead? – Z.H. Dec 23 '14 at 3:44
  • @Z.H. it could, if you wanted the results typeset, rather that sent to the terminal – David Carlisle Dec 23 '14 at 10:12
2

Your two citations from two books solves slight different problem. The first one (from TeXbook) says that vertical material from \halign behaves as "normal" vertical material inside (may be greater) vertical list. It doesn't behave as \unvbox material where the lineskip before and after must be solved individually. The second one (from TeX by topics) says that lines from \halign including objects from \noalign material are connected each to next by right interlineskip. That the \noalign material isn't individual vertical list from this point of view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.