Glue not needed in alignment templates?

Consider this simple alignment (note lack of \hfil in template)

\halign{#&#\cr
a&b\cr
aaaaaaaa&bbbbbbbbb\cr
}


To my surprise, this does not give Underfull \hbox in alignment error! The TeXBook, by my reading of Chapter 22, is quite clear that glue specs must be in templates, in order for narrower boxes to stretch to the maximum column width.

Can anyone explain my misunderstanding here? Thanks!

Initially the cell entries are set in a special "unset box" just used in alignments, at the point the widths are not known, and so no underful message is given then, and when the alignment widths are known and the unset boxes are re-set to the required widths the messages are suppressed. The TeXBook does mention a similar case when a target width for the alignment is given but doesn't explicitly document this I think.

\ddanger When an ^{alignment} is overfull'' or tight'' or loose'' or underfull,'' you don't get a warning message for every aligned line; you get only one message, and \TeX\ displays a {\sl^{prototype row}/}

Note it isn't just an template of # this apples to, you get no messages from the following where the template adds the text [] around the entry.

%\tracingonline1
%\tracingoutput1

\halign{[#]&#\cr
a&b\cr
aaaaaaaa&bbbbbbbbb\cr
}

\bye


Basically, TeX will not report underfull boxes generated by the “trivial template #”.

You can see that no warning is issued by

\halign{\hfil#\hfil&\hfil#\cr
aaaaa&bbbbbbbbb\cr
aaa&bbbbbb\cr
\omit aaa&bbbbb\cr
aaa&\omit bbbbb\cr
}

\bye


and the TeXbook explains in the first dangerous bend on page 240 that \omit clears the current template and “the trivial template # is used instead”. The trivial template is essentially equivalent to #\hfil.

Actually, TeX won't report underfull boxes in any case: you get no report also with

\halign{\hfil#\hfil&\hfil#\cr
aaaaa&bbbbbbbbb\cr
aaa&bbbbbb\cr
\omit aaa&bbbbb\cr
aaa&\omit bbbbb\cr
\hfilneg aaa\hfilneg&bbbbb\cr
}

\bye


where the \hfilneg tokens cancel the glue in the template.

• It isn't just the trivial # template this applies to. – David Carlisle Oct 23 '20 at 9:36
• @DavidCarlisle Just keeping it simple. Maybe too simple. ;-) – egreg Oct 23 '20 at 9:49