Why is this red exponent so far away from the right parenthesis? To my eye it is too far away.


enter image description here


When TeX assembles the various "atoms" of a formula into a whole (a "molecule", if you will), it mainly keeps track of each atom's enclosing rectangular "box", and it arranges the boxes horizontally and vertically according to the rules listed in Appendix G of the TeXbook. In the process of arranging the boxes, TeX doesn't actually "know" what's inside each box. E.g., a box containing a closing "fence" symbol could contain a right round parenthesis, a right square bracket, a right angle bracket, a right curly brace, etc. All TeX knows at this stage of the typesetting process is (i) the outer limits of each atom's rectangular box and (ii) certain properties of each box, e.g., if it's a box of type ord, rel, bin, open, close, punct, etc.

It can thus happen that a positioning rule is not quite optimal ex post for a given fence symbol. In particular, while the fence-exponent positioning rule may be perfectly adequate for vertical bars and square brackets -- which have material in the upper-right corner of the box -- it may not be the case for right curly braces, right round parentheses and, even more so, right angle brackets -- for which the material at the top of the box is mostly in the left-hand corner. If need be, this deficiency can (and should) be corrected by inserting a negative thin space, \!, at the start of the material contained in the exponent.

The examples below illustrate this issue. The exponents in the first two lines, which feature a plain vertical bar and a right square bracket, look to be positioned just about right relative to the fence symbol. A slight improvement results from inserting \! after a right curly brace (line 3). The \! adjustment is arguably more necessary for right round parentheses (line 4) and right angle brackets (line 5). Finally, I'd say that inserting two \! directives in the right angle bracket case (line 5, far right) is probably too much of a good thing -- and hence no longer good...

A separate positioning issue arises from the fact that \left and \right also insert some white space before and after the material enclosed by this group (but not between the right-hand closing fence symbol and any immediately following superscript/subscript material). To avoid having TeX insert this extra whitespace, you could use explicit sizing instructions for the fence symbols (e.g., \Bigg and \bigg), or you could load the mleftright package and (i) issue the command \mleftright if you want to suppress the extra whitespace globally or (ii) use the commands \mleft and \mright if you want to address the matter in a case by case way.

enter image description here

&\left\lvert \myfrac \right\rvert^{\color{red}2}\\
&\left[  \myfrac \right]^{\color{red}2}\\
&\left\{ \myfrac \right \}^{\color{red}2} \text{ vs.\ }
 \left\{ \myfrac \right\}^{\!\color{red}2}\\
&\left(  \myfrac \right)^{\color{red}2} \text{ vs.\ }
 \left(  \myfrac \right)^{\!\color{red}2}\\
&\left\langle \myfrac \right\rangle^{\color{red}2} \text{ vs.\ }
 \left\langle \myfrac \right\rangle^{\!\color{red}2} \text{ vs.\ }
 \left\langle \myfrac \right\rangle^{\!\!\color{red}2}

The following image shows the boxes of each character as seen by tex, for each of the cases in egreg's answer.


You can clearly see how the boxes of the parenthesis are "too wide", which causes the exponent to be too far. In addition, using egreg's suggestion (\biggl() removes unwanted space before the box of the left parenthesis.

Note For generating the above image I used this answer slightly modified to work in math mode.

  • I wouldn't say that the rectangular box that encloses the parenthesis is "too wide"; in fact, its dimensions are correct (relative to the rules used in Appendix G of the TeXbook). The issue is, rather, that in the case of a right round parenthesis there's no material in the upper right-hand corner of the box, and it's this lack of material in the area of the box that's closest to the exponent that makes the positioning look wrong. – Mico Dec 11 '13 at 9:47
  • 1
    @Mico in other words, it's a slightly more specifig issue of missing kerning ;) – yo' Dec 11 '13 at 12:36
  • @tohecz - Yeah, I suppose one could call it that: Because TeX (by design) doesn't know the shape of the fence symbol that's contained in the box, it can't apply any fine-tuning to the placement of the box that contains the exponent w.r.t. to the box that contains the fence symbol. One might call it an issue of (lack of) "two-dimensional kerning" of the various math boxes -- as opposed to the more frequently encountered term of "one-dimensional kerning" of glyphs lined up along one and the same baseline. :-) – Mico Dec 11 '13 at 13:17

This is a case where manual adjustment is needed. The coloring has nothing to do with it. It has to do with the shape of the parenthesis, which is quite wide.

I'd recommend using \biggl and \biggr, in particular because of the coefficient in front of the open parenthesis.


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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