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
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
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?