Related Question:
Typesetting the square of a mathematical operator
\operatorname
converts its argument into a function symbol with appropriate spaces on the left and on the right. However, I often need sub- and superscripts applied on those symbols. So I'd like to define something like
\documentclass{article}
\usepackage{amsmath,amssymb}
\newcommand\f[2]{
\operatorname{\mathnormal{f}_{\mathnormal{#1}}^{\mathnormal{#2}}}
}
\begin{document}
\begin{equation*}
\f{2}{n}
\end{equation*}
\end{document}
Note that \operatorname{\mathnormal{f}}_{#1}^{#2}
(sub- and superscript outside \operatorname
) would place the subscript too far away from the letter f
.
Here the problem begins: Since \operatorname
internally applies \mathrm
to its argument, \f{2}{n}
typesets the exponent n
upright:
On the other hand, if I write
\newcommand\f[2]{
\operatorname{\mathnormal{f}_{\mathnormal{#1}}^{\mathnormal{#2}}}
}
then the numbers' font is changed:
This gets really tricky when combining letters (or other operators) and numbers like \f{2mn\cdot x}{\frac{c}{2}}
:
Is there a way to get the "right" letters and the "right" numbers at the same time? That is:
\operatorname
, instead of just typingf_2^n
?a\f{2}{n}+b
is different froma\f{2}{n}+b
.