Here's a fairly detailed explanation of what goes on in the execution of an \operatorname
instruction. Note that this explanation is simplified to the case of the use of this command without the *
("star") qualifier. (See amsopn.sty
for the full details.)
The \operatorname
instruction (without the "star" qualifier) is set up as
\DeclareRobustCommand{\operatorname}{{\qopname\newmcodes@ o}}
where \qopname
, in turn, is defined as
\DeclareRobustCommand{\qopname}[3]{%
\mathop{#1\kern\z@\operator@font#3}%
\csname n#2limits@\endcsname},
\operator@font
is given by
\def\operator@font{\mathgroup\symoperators},
and \newmcodes@
is given -- inside a TeX group for which "
has catcode 12 -- by
\gdef\newmcodes@{\mathcode`\'39\mathcode`\*42\mathcode`\."613A%
\ifnum\mathcode`\-=45 \else
\mathchardef\std@minus\mathcode`\-\relax
\fi
\mathcode`\-45\mathcode`\/47\mathcode`\:"603A\relax}
(Basically, the \newmcodes@
command modifies the meanings to the characters '
*
.
-
/
and :
from their "regular" math-mode settings.) Finally, the command \z@
is equivalent to 0pt
(zero length).
Hence, executing the command \operatorname{xyz}
is equivalent to executing
{\qopname\newmcodes@ o xyz}
which boils down to executing, after (i) recognizing that none of the special characters affected by the \newmodes@
command are involved in the current example, (ii) resolving the construct in the \csname ... \endcsname
complex to \nolimits
, and (iii) noting that \nolimits
has no effects if we don't specify limits:
{\mathop{\kern0pt \operator@font xyz}
Therefore, $\operatorname{A}^2$
resolves to
${\mathop{\kern0pt \operator@font A}^2$
whereas $\operatorname{A^2}$
resolves to
${\mathop{\kern0pt \operator@font A^2}$
If the "squaring instruction" is inside the \mathop
instruction, it appears that the height of the letter(s) that precede the superscript-2 do not affect the vertical positioning of the 2
. E.g., check out the positions of the 2
glyph in
$\mathop{\kern0pt \operator@font ln^2}$
$\mathop{\kern0pt \operator@font sin^2}$
$\mathop{\kern0pt \operator@font cos}^2$`
They're all the same.
Conversely, if the "squaring instruction" is not inside the \mathop
instruction, what comes into play is the height of the entire box that contains the "name" part of the \operatorname
instruction; if the "name" part contains letters with ascenders, the box's height increases, and this will affect the positioning of the superscript-2. E.g., for $\ln^2$
, $\det^2$
, and $\cos^2$
, the superscript is at different heights because of the differences in the heights of the boxes that contain ln
, sin
, and cos
, respectively.