[Tex/LaTex] Combining Textstyle and Displaystyle

math-modemath-operatorsspacingsubscriptssuperscripts

In my mathematics writing, I often use both superscripts and subscripts on the probability operator. The subscripts are generally lengthy, and I would like for them to appear underneath the operator, which is the default behavior in displaystyle. The superscripts are often just a single number, and I would like them to appear as a superscript (not above the operator), which is the default behavior in textstyle. If I write something like

$$\Pr_{long subscript}\textstyle{^2}$$

I get the behavior I want, but the superscript 2 appears very far to the right because the subscript is so long. If I write instead

$$\Pr\textstyle{^2}_{long subscript}$$

the superscript looks fine, but the long subscript displays as a textstyle subscript (not underneath the operator as I would like).

How can I get the long subscript to display underneath the operator and the superscript to display as a textstyle superscript immediately next to the operator?

Best Answer

Here is an option:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\noindent Wrong:
\[
  \Pr_{long subscript}\textstyle{^2}
\]
Wrong:
\[
  \Pr\textstyle{^2}_{long subscript}
\]
Problematic:
\[
  \Pr^2_{\text{long subscript}}
\]
Feasible:
\[
  \mathop{\Pr{}^2}_{\text{long subscript}}
\]
Best:
\[
  \mathop{\Pr\nolimits^2}_{\text{long subscript}}
\]
\end{document}

Both 1 & 2 are incorrect for a number of reasons. Not only is the positioning of the superscript incorrect (too far right), but the subscript (which is text) is not set as such. While 2 "corrects" the superscript, the use of \textstyle is incorrect. \textstyle is a switch, not a macro that takes an argument. As such, what follows \textstyle will be set in \textstyle until the end of the group.

The problematic output of option 3 is the placement of the superscript (on top of the operator), even though the subscript output has been properly set as text (thanks to amsmath's \text). Output for 4 uses \mathop as a momentary operator definition, setting the text underneath. The superscript is prevented from being set on top by not placing the any scripting immediately after it. Instead, {} acts as the base for the superscript.

Option 5, with \nolimits removes the additional operator spacing.