Assume I want to typeset the square of some mathematical operator A. Using \operatorname
(amsmath
package), there are basically two ways to do that:
\(\operatorname{A^{2}}\)
(i.e., the exponent is considered part of the operator name)\(\operatorname{A}^{2}\)
(i.e., the exponent is not considered part of the operator name)
According to my tests, the above two formulae are not equivalent, though. In fact, the first formula has a smaller height than the second one. Minimal example:
\documentclass{article}
\usepackage{amsmath}
\newlength{\len}
\begin{document}
\begin{enumerate}
\item
\settoheight{\len}{\(\operatorname{A^{2}}\)}
\(\operatorname{A^{2}}\): height = \the\len
\item
\settoheight{\len}{\(\operatorname{A}^{2}\)}
\(\operatorname{A}^{2}\): height = \the\len
\end{enumerate}
\end{document}
Can anybody explain what is at the bottom of my observation?
Best Answer
The reason for the difference is that TeX typesets superscripts differently whether it follows a character or a box, as described in rule 18a of Appendix G of The TeXbook. As the macro
\operatorname
boxes its contents (because it calls\mathop
which does), that's why\operatorname{A}^2
and\operatorname{A^2}
differ (the first superscript concerns a box, whereas the second only the preceding A). You can easily see that an\operatorname
and an\hbox
behave similarly:Here are the technical details of the actual computations made by TeX in the present case: