[texhax] What's legal about \halign and backward braces?

Donald Arseneau asnd at triumf.ca
Sun Jun 26 02:42:33 CEST 2011

Doug McKenna <doug at mathemaesthetics.com> writes:

> \halign{}
> This unexpectedly (to those versed in usual computer language syntax) 
> leads to a runawy preamble error, because the '}' doesn't end the 
> command's parsing; a # and then a \cr must happen first, and they're 
> missing.

My immediate reaction is surprise.

> \halign{}#{\cr\omit A\cr}
> order has no effect, and hence the alignment executes fine.  But if one 
> omits the \omit, things go wrong: TeX's error message says there's a 
> missing \cr right after the "A", which is pretty confusing, since there 
> IS a \cr right after the "A", both in one's source code and in the line 
> shown in the error message.

You are misreading the error message.  The message says that there
is a missing \cr before the (template-inserted) brace, but TeX has
already read as far as the A before the error was detected.  Of
course that has to be the case because the u-template isn't inserted
until TeX sees the A.

> Can any cogniscenti here give an example of an alignment of the form
> \halign{}...#...{\cr}
> that (without suppressing the column's template with \omit) remains error 
> free? 

I hope not.  But then I am surprised about the template scanning.

Donald Arseneau                          asnd at triumf.ca

More information about the texhax mailing list