1

I'm sure that this is TeX basics and I'm just being a fool, but I can't figure out for what/how the @ symbol is used. All I can tell is that to make sure it works you have to put it between \makeatletter...\makeatother. But I have no idea what it actually does. Thanks!

1 Answers1

6

It is conventional in TeX and LaTeX to include @ in private command names that shouldn't be used in documents. Normally a command name consists of either a single non-letter or one or more letters, e.g., \# or \sigma. Inside of class and package files, however, @ is treated as a letter so a command like \@startsection will be available to a class programmer while keeping it (mostly) inaccessible to document writers. On rare occasions, a document writer may need to access these private commands, so the commands \makeatletter and \makeatother are available to turn on and off access to the private commands.

Newer LaTeX code uses the expl3 syntax which allows commands to have _ and : in the names and has conventions around naming that I won't get into here. Access to this naming convention is controlled using \ExplSyntaxOn and \ExplSyntaxOff. Even in class and package files, this has to be turned on/off manually since it has other repercussions that may not be desired in most code (most notably all spaces are ignored).

The last naming convention is one that's inconsistently applied, but is to use CamelCase in command names for commands that are made available to document writers but that have some programming-level significance. The \ExplSyntaxOn/\ExplSyntaxOff commands are examples of this. Arguably, it should also be \MakeAtLetter and \MakeAtOther but those commands precede the adoption of the CamelCase convention.

Don Hosek
  • 14,078
  • OpTeX uses another naming convention: the _ is set as letter and can be used in control sequences every time. We need not to switch on/off to access such names. And the names \_foo are reserved for primitives and internal OpTeX sequences. The meaning of \_foo is doubled as \foo too (\_hbox is the same as \hbox), so users can access these meanings by normal way: use \hbox. Or they can re-define them without any catastrophic scenario inside the OpTeX macros because these macros are using only \_foo sequences. – wipet May 14 '21 at 18:40
  • Thanks!! This is exactly what I wanted to know. – generallyconfuzzled May 16 '21 at 18:33
  • @generallyconfuzzled Just to clarify, "to treat @ as a letter" means to make the catcode of @=11, whereas "to treat @ as other" means to make the catcode of @=12. The catcode of a character (which can be changed on the fly) is how TeX decides the function of various characters. See https://en.wikibooks.org/wiki/TeX/catcode – Steven B. Segletes May 17 '21 at 10:58