views:

777

answers:

3
+4  Q: 

LaTeX at symbol

What does the @ symbol mean in LaTeX? I'm looking at the source of apa.cls, and there's a declaration:

\newsavebox\gr@box

and later on

\sbox\gr@box{\includegraphics[width=\linewidth]{#2}}.

It seems like @ isn't acting as a normal character, but I can't figure out exactly what it's doing, and couldn't find anything after bit of googling (how I would love a Google regex feature!) Thanks.

EDIT: Thanks for the help; of the links I looked through I found http://www.tug.org/pipermail/tugindia/2002-January/000178.html to be very helpful and concise. To summarize, the @ character is not normally allowed in the names of macros, so as a hack for scoping, LaTeX packages declare it internally to be a valid name character and use it for their macros. You can use \makeatletter in a document to access these macros, but you obviously must be very careful since you have can now overwrite essential LaTeX kernel macros; use \makeatother to revert.

+1  A: 

Answered here.

The LaTeX commands are built using commands with the @ sign. In order to prevent these commands from being modified, @ is usually redefined to be a special symbol. Occasionally, if you know what you're doing, you can "make at letter" (\makeatletter) to do some fine tuning, and then you would "make at other" (\makeatother) again when you're finished.

John
+1  A: 

@ character in a macro name simply marks the macro as internal to the package, see http://www.tex.ac.uk/cgi-bin/texfaq2html?label=atsigns

tonio
+8  A: 

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
Alexey Malistov
perfect thanks!