A category code assignment is of the form
\catcode <number> = <number>
= are optional). The first
<number> is the character we want to assign the category code (so eight bit in legacy engines, up to
0x10FFFF for Unicode engines), the second one is the category code (four bit number).
The number can be expressed in any legal form understood by TeX: decimal, octal, hexadecimal or alphabetic. For instance, the usual category code 4 to
& can be assigned by
\catcode 38 = 4 % decimal
\catcode '46 = 4 % octal
\catcode "26 = 4 % hexadecimal
\catcode `& = 4 % alphabetic
In order to change the category code of
%, which is preassigned to 14 when INITEX starts off, so embedded in every format that doesn't change the assignment, we have a problem if we want to use the “alphabetic” representation:
\catcode `% = 12
cannot work, because the
% character has not yet been assigned a different category code, so it is still a comment character when the code is being read in. You can do it with the explicit number
\catcode 37 = 12
% is ASCII 37 (hexadecimal
0x25). But it would be much handier to use the character! There is an escape to this cul-de-sac: an alphabetic constant can also be designed by
where the backslash must be a character of category code 0 (as usual). In this case the one character control sequence is not interpreted as a macro, but just as the character it is named with. Hence
\catcode `\% = 12
will work. Similarly, if you want to temporarily change the category code of the backslash to 12 you can do
\catcode `\\ = 12
(the assignment will be done after having input the control sequence
\\ in order to interpret it as an alphabetic constant because of the backquote).
Other characters that must be denoted this way are those with category code 5 (end line), 9 (ignored) or 15 (invalid). Also category code 6 characters are better expressed this way, particularly when the category code assignment is in the replacement text of a macro.
Thus, when you have to change category code of a character (possibly) having category code 0 (escape), 5 (end line), 6 (parameter), 9 (ignored), 14 (comment) or 15 (invalid), use either the decimal form or the escaped form.