\makeatletter & \makeatother (LaTeX2e unofficial reference manual (November 2018))

Next: \@ifstar, Previous: \providecommand, Up: Definitions [Contents][Index]

### 12.3 `\makeatletter` & `\makeatother`

Synopsis:

    \makeatletter
      ... definition of commands with @ in their name ..
    \makeatother

Use this pair when you redefine LaTeX commands that are named with an at-sign character ‘``@``’. The `\makeatletter` declaration makes the at-sign character have the category code of a letter, code 11. The `\makeatother` declaration sets the category code of the at-sign to code 12, its default value.

As TeX reads characters, it assigns each one a category code, or catcode. For instance, it assigns the backslash character ‘``\``’ the catcode 0. Command names consist of a category 0 character, ordinarily backslash, followed by letters, category 11 characters (except that a command name can also consist of a category 0 character followed by a single non-letter symbol).

LaTeX’s source code has the convention that some commands use `@` in their name. These commands are mainly intended for package or class writers. The convention prevents authors who are just using a package or class from accidentally replacing such a command with one of their own, because by default the at-sign has catcode 12.

The pair `\makeatletter` and `\makeatother` changes the default code and then changes it back. Use them inside a `.tex` file, in the preamble, when you are defining or redefining commands named with `@`, by having them surround your definition. Don’t use these inside `.sty` or `.cls` files since the `\usepackage` and `\documentclass` commands already arrange that the at-sign has the character code of a letter, catcode 11.

For a comprehensive list of macros with an at-sign in their names see http://ctan.org/pkg/macros2e.

In this example the class file has a command `\thesis@universityname` that the user wants to change. These three lines should go in the preamble, before the `\begin{document}`.

    \makeatletter
    \renewcommand{\thesis@universityname}{Saint Michael's College}
    \makeatother

Unofficial LaTeX2e reference manual