Every char has the category code from 0 up to 15.
- 0 - Escape character; this signals the start of a control sequence. backslash
\ (Unicode code point U+005C) is a default escape character.
- 1 - Beginning of group; such a character causes TeX to enter a new level of grouping. The open brace
{ is a beginning-of-group character.
- 2 - End of group; TeX closes the current level of grouping. TeX has the closing
brace
} as end-of-group character.
- 3 - Math shift; TeX uses the dollar sign
$ for this.
- 4 - Alignment tab; TeX uses the ampersand
&.
- 5 - End of line; a character that TeX considers to signal the end of an input line.
- 6 - Parameter character; this indicates parameters for macros. In TeX this is the hash sign
#.
- 7 - Superscript; default superscript is the circumflex
^.
- 8 - Subscript; default superscript is underscore
_.
- 9 - Ignored; characters of this category are removed from the input.
- 10 - Space; space characters receive special treatment. TeX assigns this category to the space (Unicode code point U+0020) and tab characters (U+0009).
- 11 - Letter; in TeX only the characters
a..z, A..Z are in this category. Often, macro
packages make some ‘secret’ character (for instance @) into a letter, see below.
- 12 - Other; TeX puts everything that is not in the other categories into this category.
It includes, for instance, digits, punctuation and
@.
- 13 - Active; active characters function as a TeX command, without being preceded by
an escape character. The tie character
~ has such category.
- 14 - Comment character; the default comment character is
%.
- 15 - Invalid character; this category is for characters that should not appear in the input. TeX causes an error in the case of such chars.
A macro name consists only of letters (code 11). The @ symbol has category code 12 and can therefore not be included in the macro name. However, you can change the category of any symbol
\catcode`\@ = 11 % Macro \makeatletter does the same
Now you can use @ as letter in your macro names. All LaTeX packages change catcode of the @ to 11 and return it to 12 at the end.
\catcode`\@ = 12 % Macro \makeatother does the same
Note you can change catcode any character, not only @. For example, if you want to use [, ] as open and close group symbols write
\catcode`\[ = 1
\catcode`\] = 2