# What do \makeatletter and \makeatother do?

Many LaTeX “hacks” begin with `\makeatletter` and end with `\makeatother`. What do these commands do?

-
As for a reference, tug.org/pipermail/tugindia/2002-January/000178.html – chl Jan 5 '11 at 20:53
– Tobias Kienzler Oct 15 '11 at 7:36
For the absolute beginners; the commands should be read as Make @ symbol a letter and Make @ symbol an "other".It's NOT Make when you encounter a letter and Make when you encounter others. – percusse Mar 14 '13 at 10:54
@percusse Hah. I've been compiling things in LaTeX since 2005 and I didn't know that. – isomorphismes Jun 4 '14 at 3:26
How bizarre and obscure. I love what LaTeX does, but the more I learn it, the more I realize what a crazy hack it is. – Dov Jul 14 '14 at 12:05

All characters in TeX are assigned a "category code" or catcode. There are 16 catcodes in all, some containing just a single character, e.g. `\` is (normally) catcode 0, `{`, catcode 1 etc. Normal characters are catcode 11; this category normally comprises all of the letter characters. The `@` symbol is given the catcode of 12, which means it is not treated as a normal letter. The effects of this are that `@` cannot normally be used in user document files as part of a multicharacter macro name. (All other non-letter characters are also forbidden in macro names: for example, `\foo123`, and `\foo?!` are not valid macro names.)

In LaTeX class and package files, however, `@` is treated as a normal letter (catcode 11) and this allows package writers to make macro-names with `@`. The advantage of this is that such macro names are automatically protected from regular users: since they cannnot use `@` as a normal letter, there is no accidental way for a user to override or change a macro that is part of the internal workings of a package.

However, it is sometimes necessary in user documents to have access to such package-internal macros, and so the commands `\makeatletter` and `\makeatother` change the catcode of `@` from 12 to 11 and 11 to 12, respectively.

In practical terms, if you need to modify a package internal macro that contains the `@` symbol in its name, you will need to surround your modifications by these commands:

``````\makeatletter % changes the catcode of @ to 11
\makeatother % changes the catcode of @ back to 12
``````

The commands should not be used within `.sty` and `.cls` files themselves as they may conflict with the catcode changes that occurs when package and class files are loaded. For more information on this see Is it really bad to use \makeatletter and \makeatother in a package or class file?.

-
@Caramdir: Not quite true. `\@` is a perfectly good macro. It's what Knuth calls a control symbol. If the category code of @ is 11, then `\@` becomes a control word. – TH. Jan 5 '11 at 21:11
@Philipp: Given the audience for this question, surely multiletter macro name is a much more understandable term. – Alan Munn Jan 5 '11 at 22:39
@Alan: We [computer scientists] do like to confuse things. =) In a sense, there are actually 17 catcodes. It's really not relevant for this question, but in the context of `\ifcat`, control sequences (which includes control words, control symbols, and control spaces) have category code 16. See TeX by Topic, Section 13.2.2. – TH. Jan 6 '11 at 1:37
@Alan: +1. Maybe give an explicit example like \@title? Per tug.org/pipermail/tugindia/2002-January/000178.html. To summarize, a normal user is not supposed to do \@title but a package author is allowed, so to speak, and \makeatletter makes \@title 'legal'. – Faheem Mitha Mar 3 '11 at 6:00
Thank you so much for that explanation. The way the command is phrased, I thought it was telling the compiler to make something execute at a specific letter. It's literally: "make the "at" symbol a letter. It's actually pretty funny. – user28374 Apr 3 '13 at 2:41