First of all, \makeatletter
is unnecessary in .sty
or .cls
files, as the default catcode regime includes it; this is presumably to encourage package writers to hide their macros using @
-laden names. For this reason, I believe that using this command is harmless in package files.
However, using the pair of commands together is harmful, because unlike in a document, you do not want to return to the @ = other
setup within the package. These are document commands and the standard ordering \makeatletter \makeatother
assumes that \makeatother
is actually undoing the previous change, whereas in packages, it is the one making the change.
Edit: Here is a more informed answer. According to source2e.pdf
, the following scheme is used to load packages and classes:
- First, the options and such are gathered.
- Then the name of the current file (i.e.
mypackage.sty
), along with the catcode of @
, are saved on a stack.
- Then
\makeatletter
is run and, if appropriate, the requested file is loaded.
- Afterwards, the stack is popped and the pre-package-load state restored.
In other words, the following ignorant code has no effect at all:
\documentclass{article}
\usepackage{bad}
\begin{document}
\end{document}
bad.sty:
\makeatletter
\makeatother
\RequirePackage{unsuspecting}
However, it is quite possible that a package does not use \RequirePackage
, but just \input
. In that case, the catcode is not protected and indeed, errors can arise, as you can check yourself by making bad.sty
, for example:
\makeatletter
\makeatother
\input{pgfkeys.sty}
If that seems artificial, have a look at pgfkeys.sty
itself: it \input
s pgfkeys.code.tex
, and that file, in turn, \input
s pgfkeysfiltered.code.tex
. Presumably, the author felt himself safe once within his own package, but did not suspect that someone else might circumvent the package-loading protection mechanisms also!
Here is the definition of \markboth
from the LaTeX kernel:
\def\markboth#1#2{%
\begingroup
\let\label\relax \let\index\relax \let\glossary\relax
\unrestored@protected@xdef\@themark {{#1}{#2}}%
\@temptokena \expandafter{\@themark}%
\mark{\the\@temptokena}%
\endgroup
\if@nobreak\ifvmode\nobreak\fi\fi}
It takes two arguments, designed to aid in the setting of the headers in twoside
mode - the first is set as the left page header, while the second ends up in the right page header.
In contrast, \@mkboth
is used as an internal kernel tool and may take on multiple functions. From source2e
(section 65.3 marking conventions, p 310):
Commands like \tableofcontents
that should set the marks in some page
styles use a \@mkboth
command, which is \let
by the pagestyle command
(\ps@...
) to \markboth
for setting the heading or to \@gobbletwo
to do nothing.
For example, the empty
page style (in latex.ltx
) sets
\def\ps@empty{%
\let\@mkboth\@gobbletwo\let\@oddhead\@empty\let\@oddfoot\@empty
\let\@evenhead\@empty\let\@evenfoot\@empty}
while the headings
page style (in article.cls
) sets
\if@twoside
\def\ps@headings{%
\let\@oddfoot\@empty\let\@evenfoot\@empty
\def\@evenhead{\thepage\hfil\slshape\leftmark}%
\def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
\let\@mkboth\markboth
...
Best Answer
Using
\list
(or\trivlist
) for a display enviornment makes it a lot easier to handle things that are trickier to get right (or at least get like the rest of LaTeX) otherwise.In particular:
the code to handle how space is combined if one display environment immediately follows another;
the code that detects whether the text following the environment is to be set as a new paragraph or a continuation of the previous one;
The code to adjust the left and right margins in a way that flags to any nested list environments which margins to use.
None of the code for these things is impossibly difficult, but....