[Tuglist] Makeatletter and Makeatother

Radhakrishnan CV tuglist@tug.org.in
Fri, 11 Jan 2002 18:38:31 +0530 (IST)

On Wed, 2 Jan 2002 at 13:05, K. N. Manoj wrote:

   What do the commands \makeatletter and \makeatother mean? I
   searched the four volume `TeX in Practice', but could not find

\makeatletter and \makeatother are LaTeX commands and you cant
expect that to be explained in TeX in Practice which deals with
plain TeX alone.

   anything. I have seen it being used regularly in LaTeX style

\makeatletter changes the category code of '@' character to 11 
(which is the catcode of ordinarary characters a-z,A-Z). 
\makeatother reverts this to its original catcode of 12.   

Knuth assigns a category code for each and every character like 0 
for escape '\', 1 for begining of a group `{', 2 for end of group 
`}', 3 for math shift `$', 4 for alignmet tab `&', 5 for end of 
line, 6 for paramter `#', 7 for superscript `^', 8 for subscript 
`_', 9 for ignored character, 10 for space, 11 for letters, 13 for 
active character `~', 14 for comment character `%', 15 for invalid 
character and 12 for characters other than the above.

Knuth gives the freedom to change the catcode of any character 
anywhere. You can change the catcode of \ to 11 (ie, letter) assign 
the catcode 0 to | so that |section becomes a function or control 

You might have noted that an escape character combined with the
characters of catcode 11 becomes a control sequence. As such, all
the user defined control sequences or macros will be of this nature.

This raises the problems of risks of an user defined macro having
the same name as that of a macro in a package or even LaTeX kernel.  
even. This can break down packages. 

In order to circumvent this foreseeable problem, package writers
always use the character '@' in their control sequences by changing
the cat code of `@' character to 11 which is the catcode of alpha
characters. This is accomplished by the command \makeatletter. 

At the end of the package, the author will revert the catcode of `@'
to 12 with the command \makeatother. So you will find lots of macros
with `@' like \@title, etc., which you cant define in a document
without changing the catcode. So novice users will not create macros
that might clash with kernal macros.

Hope you got the idea of this safety scheme.