TeX/catcode

< TeX

Synopsis
\catcode`\[char]=[num]

Description
\catcode is the command that's used to change the category code of a character. The category code tells TeX what to do when it encounters that character later in the text. A general assignment looks something like \catcode`\@=11 which defines the @ character to be a letter.

The category codes in TeX are as follows:
 * 0 = Escape character, normally \
 * 1 = Begin grouping, normally {
 * 2 = End grouping, normally }
 * 3 = Math shift, normally $
 * 4 = Alignment tab, normally &
 * 5 = End of line, normally
 * 6 = Parameter, normally #
 * 7 = Superscript, normally ^
 * 8 = Subscript, normally _
 * 9 = Ignored character, normally
 * 10 = Space, normally and
 * 11 = Letter, normally only contains the letters a,...,z and A,...,Z. These characters can be used in command names
 * 12 = Other, normally everything else not listed in the other categories
 * 13 = Active character, for example ~
 * 14 = Comment character, normally %
 * 15 = Invalid character, normally

Using category codes, it is possible to completely reconfigure TeX and allows support for international users.

A character of code 13 is called active. In a sense it is treated as if it were a command sequence in of itself, and definitions can be given in the normal fashion. Hence to define ~, Plain TeX has \def~{...}