Why do LaTeX internal commands have an @ in them?

When Knuth originally published the language he used the @ to mark commands that a user should not normally use. This was in order to avoid overriding kernel commands by redefining them. Remember that a macro defined using \def will overwrite an earlier command with the same name. Lamport followed suit with LaTeX a few years later as well as countless other package writers. The @ can only be used in a command in a document only if you use \makeatletter so that it can change its \catcode.

For me it served also another purpose as a marker to split long commands, for example it is more readable to read \make@page@wider than \makepagewider.


Others have mentioned the protection against user definition / redefinition. Another aspect is that command names like \foo may only contain letters, so \mymacro is a valid command, \my!macro is not. So the normal user cannot redefine these commands, as \newcommand{\my!macro}{....} will throw an error. You can redefine the category code of e.g. ! to behave as a letter, so that \my!macro is considered as a valid command name (control word in TeX speak). This is what \makeatletter does for @, \makeatother changes the @ back to a symbol (category code 'other').


No, it does not mean anything specific; it is simply used to "namespace" code that shouldn't appear in a regular document. You can use almost any analphabetic symbol you like; ConTeXt also allows ? and !, while LaTeX3/expl3 uses _ and : instead.

While there are few conventions on how to use @ in LaTeX package code, for expl3 we recommend the syntax

\<module>_<function name>:<argument spec>

and

\<l/g/c>_<module>_<variable name>_<datatype>

for functions (macros that take arguments) and variables, respectively. For variables, the prefixes are l for ‘local’, g for ‘global’, and c for ‘constant’.

Tags:

Macros