Every char has the category code from 0 upto 15.
0 - Escape character; this signals the start of a control sequence. backslash \
(code 92) 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 beginningof-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 ASCII space character, code 32 and tab character (code 9).
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.
Thus it includes, for instance, digits, punctuation ans @
.
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; 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.
Any macro can only consist of letters (code 11). @
symbol has category code 12 and can not be included in the macro name. But 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 packeges change catcode of the @
to 11 and return it at the end.
\catcode`\@ = 12 % Macro \makeatother does the same
Note you can change catcode any charachter, not only @. For example, if you want to use [
, ]
as open and close group symbols write
\catcode`\[ = 1
\catcode`\] = 2