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.

What's the correct way to typeset the following to get the normal spacing you would expect were you to, for example, write the terms out by hand.

\documentclass[a4paper,11pt]{article}

\begin{document}
\[ \left( \prod_{i=1}^m X_i \right)^n \]
\[ O\left(\frac{1}{n}\right) \]
\end{document}

In the first case the space to the exponent 'n' is too large. In the latter case the space between the 'O' and the open bracket is too large.

share|improve this question
1  
I don't think the spacing looks that bad actually... You could manually adjust the spacing by adding a negative hspace. \[ O\hspace*{-.25em}\left(\frac{1}{n}\right) \] and the same for the exponent. –  Roelof Spijker Oct 12 '11 at 10:09
    
Regarding the space between the 'O' and the '(', this is discussed at great length in Spacing around \left and \right. –  Hendrik Vogt Jun 27 '12 at 19:45
add comment

2 Answers

up vote 7 down vote accepted

There are a number of ways to address spacing issues. In the first example you give, reproduced in the first gather* line in the code below, both the right large parenthesis and the exponent n indeed seem to be spaced too loosely.

Inserting a "negative thinspace", \!, before each of these two items (line 2) does eliminate the earlier looseness. Unfortunately, the overall expression now looks a bit cramped. In my view, the real culprits for making the expression in line 1 look unsatisfactory are (i) the near-collision between the opening (left) parenthesis and the subscript term below the product symbol and (ii) parentheses that are too tall relative to what they contain; see pp. 148-9 of the TeXbook for an explanation of this second point. In line 3 below, I therefore (a) insert a positive thinspace, \, after the opening parenthesis and (b) use \biggl and \biggr parentheses, as they are slightly smaller (and also a tiny bit less wide!) than those produced by \left( and \right). I think the result now looks both balanced and neither too loose nor too tight. :-)

The second example you provide is affected by the automatic additional spacing that's inserted when TeX creates \left- and \right parentheses. Switching to \biggl and \biggr parentheses, as in line 4 below, eliminates this excess space. If you do not wish to give up the convenience of automatic sizing of parentheses generated by \left-\right pairs, you could instead insert a negative thinspace, \!, between the O and the \left(.

\documentclass[a4paper,11pt]{article}
\usepackage{amsmath}
\begin{document}
\noindent
\begin {gather*}
\intertext{Original}
 \left( \prod_{i=1}^m X_i \right)^n  \\       %% "line 1"
\intertext{less space on \emph{right}:}
 \left( \prod_{i=1}^m X_i \!\right)^{\!n} \\  %% "line 2"
\intertext{more space on \emph{left}, biggl-biggr parens:}
 \biggl(\,\prod_{i=1}^m X_i\biggr)^n \\       %% "line 3"
\intertext{Left-right vs.\ biggl-biggr parentheses}
 O\left(\frac{1}{n}\right) \qquad O\biggl(\frac{1}{n}\biggr)  %% "line 4"
\end{gather*}
\end{document}

enter image description here

share|improve this answer
    
That's really great. Thanks. –  Raphael Oct 12 '11 at 11:17
    
Accepted. However the O{\left(\frac{1}{n}\right)} answer below is surprising, simple and elegant. –  Raphael Oct 18 '11 at 14:55
add comment

use it this way:

\documentclass{article}

\begin{document}
\[ \left( \prod_{i=1}^m X_i \right)^{\mkern-5mu n} \]
\[ O{\left(\frac{1}{n}\right)} \]
\end{document}

with {...} you do not get the delimiterspace. The exponent is correct but you can use \mkern to get it nearer to the parenthesis

share|improve this answer
    
@Herbet, That's really great, thanks. I have to ask, where is the {...} feature that you then don't get the delimiterspace documented? –  Raphael Oct 12 '11 at 10:35
2  
@Raphael Clifford: in the TeXbook, everything in math in {...} is like a so called math atom. See also mirror.ctan.org/info/math/voss/mathmode/Mathmode.pdf –  Herbert Oct 12 '11 at 10:38
    
That's an amazing document. Thanks again. –  Raphael Oct 12 '11 at 10:45
add comment

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.