\@ and @ in macro names

Macro names containing @ are internal to LaTeX, and without special treatment just don't work in ordinary use. An exemplar of the problems caused is discussed in "\@ in vertical mode".

The problems users see are caused by copying bits of a class (.cls file) or package (.sty file) into a document, or by including a class or package file into a LaTeX document by some means other than \documentclass or \usepackage. LaTeX defines internal commands whose names contain the character @ to avoid clashes between its internal names and names that we would normally use in our documents. In order that these commands may work at all, \documentclass and \usepackage play around with the meaning of @.

If you've included a file wrongly, you solve the problem by using the correct command.

If you're using a fragment of a package or class, you may well feel confused: books such as The LaTeX Companion are full of fragments of packages as examples for you to employ.

For example, there's a lengthy section in The Companion about \@startsection and how to use it to control the appearance of section titles. Page 15 discusses the problem; and suggests that you make such changes in the document preamble, between \makeatletter and \makeatother. So the redefinition of \subsection on page 26 could be:

\makeatletter
\renewcommand{\subsection}{\@startsection
  {subsection}%                    % name
  ...
  {\normalfont\normalsize\itshape}}% style
\makeatother

The alternative is to treat all these fragments as a package proper, bundling them up into a .sty file and including them with \usepackage. (This approach is marginally preferable, from the LaTeX purist's point of view.)

This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=atsigns