I am trying to understand this syntax of primitive \def
\DeclareOption{man}{%
\def\def@man{\@manmode}
}
Why this primitive nesting? And I do not get to understand why there is two \def sentences concatenated.
I am trying to understand this syntax of primitive \def
\DeclareOption{man}{%
\def\def@man{\@manmode}
}
Why this primitive nesting? And I do not get to understand why there is two \def sentences concatenated.
Generally you'll see these \DeclareOption{<opt>}{<stuff>} declarations in style (.sty) and class (.cls) files. The allow the user to use the style/package or class with certain parameter specification which could influence the usage. In the above case, the option man is declared that \defines \def@man to be \@manmode, or in short
\def\def@man{\@manmode}
It should also be noted that inside a .sty or .cls, the @ character has special meaning, or TeXnically, a different category code. Specifically, @ acts like any other non-numeric letter, and can therefore form part of a macro name. That is, it makes \def@man a valid macro name, similar to \@manmode. Another way of stating the above inside a regular document would have required something like
\makeatletter
\def\def@man{\@manmode}
\makeatother
Above, \makeatletter and \makeatother perform the same task inherent to style and class files.
There are two ways how to read \def\def@man{...}. If catcode of @ is set to 11 (letter) at the time the text above is read from the file then the control sequence def@man is defined here.
If catcode of @ is set to 12 (other, this is more usual) then \def\def@man{...} redefines the TeX primitive \def as a macro with mandatory separator @man and (probably) the next TeX processing is broken because many macros use \def and assume that \def is primitive.
@is special and set to being similar to other letters inside a.styor.cls.-,_and.are not considered letters and therefore do not work out-of-the-box for macro names. It is possible to use them, but not using a straight\def. – Werner Jan 04 '15 at 15:21