TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to make LaTeX automatically put parentheses around a \frac if it is followed by a superscript expression?

share|improve this question
up vote 12 down vote accepted

You could redefine \frac to look ahead:

 $\frac{1}{2}, \frac{1}{2}^2$. 

 \[\frac{1}{2}, \frac{1}{2}^2\]

This gives:

enter image description here

share|improve this answer
Genius!! I was about to comment that it can't be done, but thought it better to wait... Not that I think this is a good idea to do, but good to know that it can be done. – Peter Grill Feb 1 '12 at 2:24
Genius indeed! Thanks a lot! – Mehrdad Feb 1 '12 at 2:34
@PeterGrill: Funny thing is, I was also about to comment that it can't be done. I also agree that it isn't a good idea, but I didn't say that in my answer because I couldn't actually think of a concrete reason why. It just seems wrong. – Ryan Reich Feb 1 '12 at 2:43
I think it is a personal preference thing. I don't like seeing \frac12 even though it produces 1/2, but perhaps others do. – Peter Grill Feb 1 '12 at 2:47
Oh, I agree about that for sure, but the thing with parentheses seems more questionable. In other contexts I'd say it is enforcing a default choice you may not always want, but I really can't think of when one would want a fraction with a superscript but no parentheses; it's always ambiguous. – Ryan Reich Feb 1 '12 at 2:57

Your Answer


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.