Ah the \ifnum
funky brace groups beloved of TeX\halign
programmers:-)
`
is part of the syntax for a number in TeX.
125
is a decimal
"7D
is hex and
`}
is the character code of the specified character (which is also 125 as it happens).
So....
{\ifnum0=`}\fi
the inner \ifnum
is testing if 0=125 which is false so when expanded this is equivalent
to {
so starts a brace group. However if the tokens are not being expanded and TeX is just looking for matching {}
pairs then it sees that as a matching pair so you can go
\def\foo{ {\ifnum0=`}\fi }
but
\def\foo{ { }
is an error (or at least does not stop at that }
.
Usually you can use implicit brace groups \bgroup
and \egroup
to use an unmatched {
but some constructs demand an explicit {
token and so this trick (explained by Knuth in the TeXBook comes in useful).
Usually if you find that an environment that uses &
to separate alignment cells does not work in a nested alignment it is because the author forgot to use these groups in the definition.