2

This question already has an answer here:

I am editing a class-file (extension .cls) created by several authors to format a thesis according to my university standards.

In that file, there are many command (re)definitions. For example, the following:

\let\@ldquote=\quote
\let\@ldendquote=\endquote
\renewenvironment{quote}
   {\@ldquote\setlength{\baselineskip}{\z@}}
   {\@ldendquote}

ensures single-spacing in quotes regardless of text-spacing elsewhere in the chapters (usually double-spaced for corrections). There are many other similar examples.

In that example, as far as I can tell, the letter @ is used instead of o without obvious reason, ie \@ldquote instead of \oldquote. It is also used in the macros \z@, \@ne and \tw@, to define "constants" for zero, one and two respectively.

I would personally qualify such practice as deliberate obfuscation, but it is not the first time I see this in class-files. Is there a point to this usage that I missed, or is this just the LaTeX-way of doing things?

marked as duplicate by Sheljohn, David Carlisle macros Jul 19 '17 at 15:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    it's not silly but it is the latex (and plain tex) way – David Carlisle Jul 19 '17 at 14:55
  • 1
  • 1
    They avoid that users change the commands in their documents and break everything. Check some expl3 package for another system. – Ulrike Fischer Jul 19 '17 at 14:57
  • @UlrikeFischer Is that not achieved by using newcommand instead of def? – Sheljohn Jul 19 '17 at 15:01
  • 3
    No it is not achieved by newcommand. Users should be able to avoid errors by reading documentation not having to read the code, so you should know by reading a latex tutorial that you need \renewcommand if you want to define something called \section. but you don't want to document \@startsection in every tutorial so it is better just to make that name not available in a document. – David Carlisle Jul 19 '17 at 15:10
2

The @ sign in command names is meant for internal commands that should be protected from being used accidentally by the end user of a macro package or class file. So it is a distinction between "private" commands used by the macro package internally and "public" commands that are part of the user interface.

Note that the commands are not private and public as in higher programming languages; \makeatletter makes all internal commands of any macro package loaded available.

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