[Tex/LaTex] Spacing around \left and \right


Why does the addition of a \left and \right introduces an extra space around the formula? Specifically, why do $\cos(\theta)$ and $\cos\left(\theta\right)$ render differently?

Is there a way to use resizable delimiters without introducing the spurious spaces?

Why did Knuth design it like this?

Edit: This occurs too, if \operatorname{MYOP} or some other operator, like \lim, \min etc. is used. (This edit is basically to make it easier to find this answer.)

Best Answer

I've found an answer in a usenet post by Heiko Oberdiek and another by Donald Arseneau. Improved code thanks to shiznick.

The issue is that \left and \right introduces an inner atom (see The TeXbook, chapter 18, section 4), which has different spacing rules than ordinary atoms, produced by ( and ) (and the other delimiters).

To remove this spurious spacing, one has to manually insert opening and closing atoms in the formula. Specifically, $\cos(\theta)$ and $\cos\mathopen{}\left(\theta\right)\mathclose{}$ render exactly the same.

However, inserting it does make your formulas ugly. So a good solution would be to just redefine \left and \right:


Incidentally, this code also fixes the spacing of |, that is very fragile. Check for example $|+x|$ and $\left|+x\right|$. Also $\cos|\theta|$ and $\cos\left|\theta\right|$. This is due to the fact that both delimiters are equal, and TeX doesn't know if they're opening or closing the expression. The same logic applies to \|.

EDIT: The old code had a problem with subscripts and superscripts: they didn't accompany the growth of the delimiters. Fixed now thanks to Philipp Stephani and Heiko Oberdiek.

Related Question