In TeXbook p.44, Knuth wrote:

For example, \char`b and \char`\b are also equivalent to \char98.

I know that for a special character like \, we must escape it, i.e. \char`\\. But since b is just a letter, why still can we "escape" it? Does the \b here is a macro?


The \<char> possibility is there for every character, because one can never be sure what category code a character has.

The escape is certainly necessary for every character of category code 0, 5, 9, 14 or 15, but you need it also for category 1, 2 when you don't want to affect the brace level counters and category 6 if used inside a definition.

The control sequence after ` should have a name consisting of a single character and it need not be defined. In this context the backslash is simply stripped off and the name is used as a character.

Just to mention the case, `\^^M is perfectly adherent to the syntax, because ^^M stands for a single character after tokenization.

A curiosity: TeX looks for a space also after an alphabetical constant (with expansion). Thus there is a difference between

\number`b \foo


\number`\b \foo

because in the first case \foo will only be expanded after \number has performed its complete action, whereas in the second case \foo will be expanded prior \number has finished. Here I'm assuming that b has its normal category 11.


"Why?" questions are hard to answer, it is just allowed because it is allowed. Note that tex doesn't have any inbuilt set of special characters, characters are only special if they have catcodes other than 11 or 12, and it was probably easier to always allow one-character csname than to make catcode checks and not allow it in some cases.

It can possibly be useful in that a package can use the \char`\b form without knowing the catcode of b at that point, although you would need to know that it is not catcode 15 and to be that useful you would need to know that c h a and r have catcode 11 so \char works, so in practice it is not that useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.