I am trying to define a command for a math operator \mathcal P_\mathrm{ext}
. So I thought some candidates for this:
\mathcal P_\mathrm{ext}(H)
\operatorname{\mathcal P}_\mathrm{ext}(H)
\DeclareMathOperator{\Pm}{\mathcal P}
and\Pm_\mathrm{ext}(H)
There are some differences. I didn't expect the space between \mathcal P
and the subscript when I use commands like \operatorname
. I wonder what the right one is. Or should I put the subscript inside the \operatorname
? (but it seems strange to use like that…)
Here is the MWE:
\documentclass{article}
\usepackage{amsmath, amssymb}
\DeclareMathOperator{\Pm}{\mathcal P}
\begin{document}
\begin{align*}
&\mathcal P_\mathrm{ext}(H) \\
&\operatorname{\mathcal P}_\mathrm{ext}(H) \\
&\Pm_\mathrm{ext}(H)
\end{align*}
\end{document}
Best Answer
The specific example makes the answer a bit trickier than it would otherwise have been. I would say that the most logical markup would be
\mathop{\mathcal{P}_{\mathrm{ext}}}
as you want the subscripted term itself act as a\mathop
.However the reason that you see different spacing here is because you are on the right hand side of an alignment where implicitly the expression is prefixed by
{}
so you are getting a thin space from the\mathop
to separate it from the (invisible) preceding term. So it is like the second\log
example I added to the example here/ So why in the vast majority of cases the\mathop
spacing for\log
is the right thing the extra space here is probably not right and should be removed by\!
or by using a form that does not give a\mathop
, eg{\Pm}