[tex-k] A44: definition of \% lacks a space

胡亚捷 (Hu Yajie) 2500418497 at qq.com
Mon Jul 26 09:31:30 CEST 2021


Page A44, line 11 gives the following temporary definition of \%
before introducing \chardef:

    \def\%{\char`\%}

But if you try this definition, you'll find that "50\% of" yields
"50%of", because TeX ignores the space after an alphabetic constant:

    <normal integer> ::= <internal integer>
        | <integer constant> <one optional space>
        | '_12 <octal constant> <one optional space>
        | "_12 <hexadecimal constant> <one optional space>
        | `_12 <character token> <one optional space>  // surprise!

So a rigorous definition should be \def\%{\char`\% }. The reader
probably knows that the extra space won't cause trouble because
A43 says "An optional space is ignored after constants like `98'"
and A44 says alphabetic constants are like numbers.



More information about the tex-k mailing list.