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

Uwe Lueck uwe.lueck at web.de
Sun Jun 26 19:50:41 CEST 2011


"Donald Arseneau" <asnd at triumf.ca> wrote 26.06.2011 02:42:33:
> 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.

Indeed, I do not get an error with \halign{}!
Doug, please present that minimal file that produces
the error you are reporting.

>> \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.

I guess TeX inserts the } and then considers it being the brace closing
delimiting the scope of \halign. Maybe the error message has not
been perfectly prepared for this case and is a little misleading.
I.e., it is something occurring earlier than "A" that produces the error,
but TeX mentions "A" because it has been the most recent input
that caused the error.

>> 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.

What about

    \halign{}#{\cr}

? I guess there is no problem with the template, also

    \halign{}}}}}}}#\cr}

is fine. I guess that braces in cells when they are typeset must match,
and so you cannot align anything with such templates, although
they are accepted when alone.

To summarize: I guess there is just no chance for Doug's idea.

Curious:

    Uwe.



More information about the texhax mailing list