Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Does the @ mean anything specific? For example, is it substituted? Does it split the command into parts, like \s@foo could internally mean "foo of type s"? Is the purpose of the @ only to make internal commands break when used outside a class definition or a package? If so, how is that a Good Thing?

share|improve this question

4 Answers 4

up vote 22 down vote accepted

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').

share|improve this answer

Some TeX internal commands have @ in them, too. IMO the idea is not so much to break when used "externally" as to keep the space of regularly available control sequences free for users.

Some of the original authors used @ in place of vowels, but more often nowadays people seem to use it as a word separator much like _ is used in Perl, C, PHP, Python, etc.

share|improve this answer
7  
Using @ for vowel sounds can get very tiresome: some of the LaTeX2e kernel has runs of internal functions with more and more @ symbols in them, making them more-or-less unreadable! –  Joseph Wright Nov 30 '10 at 17:17
    
@Joseph Wright: indeed. Viz. \z@ and \m@ne –  Matthew Leingang Nov 30 '10 at 19:03
2  
@JOseph Wright: in particular when you run out of \v@w@ls@iv. –  Ulrich Schwarz Nov 30 '10 at 19:55

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.

share|improve this answer

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’.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.