[Tex/LaTex] Is it \catcode or \catcode`

catcodestex-core

I've noticed that \catcode is poorly documented in the TeXbook. The primitive is defined as \catcode but every time it is used, it is used as \catcode` … the backquote is never discussed. ` itself is not active (right?) so I don't understand its function. Is it required for \catcode to work properly?

Best Answer

The backquote notation is discussed in the TeXbook, page 44.

\catcode takes as its first argument the character code of the character you want to change the catcode of. For example,

\catcode65=\active

will make ‘A’ an active character.

Instead of inserting the number ‘65’ directly, TeX allows the character code of a character to be inserted with the backtick notation you're referring to:

\catcode`A=\active

You need to escape the character if it happens to have a special catcode, though: `\%, for instance.

This backtick notation can be used wherever TeX expects a number. E.g.,

\number`A

will typeset ‘65’.

Related Question