Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
Careful: \textstyle is not a macro that takes a argument that is set into text style but a switch. In your examples, text style is still active after {^2}. Also, if you replace \textstyle with {}, you will get the same effect. The \textstyle does not only activate the text style, it disconnects the superscript (and the subscript in the second example) from the operator, meaning, you could also use \displaystyle to get the same effect. Just grouping ^2 has the same effect. –  Qrrbrbirlbel Feb 23 '13 at 1:48
2  
Please read Why is \[\] preferable to $$? –  Werner Feb 23 '13 at 1:53

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer
    
Option 5 is precisely what I'm after. Thank you. –  Austin Mohr Feb 23 '13 at 1:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.