12

Possible Duplicate:
Spacing around \left and \right

I'm having some problems with writing down an equation in LaTeX. It's only a minor issue regarding appearance, but I'm kind of a perfectionist. And isn't that why we use LaTeX anyway?

Consider the following equation:

\begin{equation}
f(x)=\exp[-\frac{x}{2}]
\end{equation}

The brackets following the exponential indicator \exp are closely placed next to "exp", clearly indicating that it's the variables for the exponential function. However, since the argument of the exponential function contains a fraction, it's appropriate to resize the brackets. So I let the brackets be resized automatically according to:

\begin{equation}
f(x)=\exp\left[-\frac{x}{2}\right]
\end{equation}

Indeed, the brackets are now automatically appropriately sized. However, for some reason, extra white space appears between "exp" and the first "[" bracket. It now looks like the function "exp" and the term in brackets are two independent components.

I haven't found a way to solve this issue. I'm quite surprised that a system like LaTeX, known for its excellent equation capabilities, exhibits this behavior.

powerup
  • 121
  • 3
    Possible duplicate: Spacing around \left and \right. Please see whether this modification (as a general solution) solves your problem and report back via adding a comment. There are other on-the-fly alternatives, like using \! on the outside which inserts a negative \thinspace to reduce the white space left by the \left and \right delimiter pair. – Werner Jan 12 '12 at 00:11

2 Answers2

7

Here are some of the possibilities, using the proposed solution of Spacing around \left and \right and adding \! (a negative \thinspace):

Spacing around left/right operators

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\begin{align*}
  f(x) &= \exp[-\tfrac{x}{2}] \\
  f(x) &= \exp\left[-\frac{x}{2}\right] \\
  f(x) &= \exp\!\left[-\frac{x}{2}\right]
\end{align*}

% https://tex.stackexchange.com/questions/2607/spacing-around-left-and-right
\let\originalleft\left
\let\originalright\right
\renewcommand{\left}{\mathopen{}\mathclose\bgroup\originalleft}
\renewcommand{\right}{\aftergroup\egroup\originalright}

\begin{align*}
  f(x) &= \exp[-\tfrac{x}{2}] \\
  f(x) &= \exp\left[-\frac{x}{2}\right] \\
  f(x) &= \exp\!\left[-\frac{x}{2}\right]
\end{align*}
\end{document}

In both examples, the first equation represents the regular delimiters, second show the traditional \left and \right pair, while the third shows the addition of a negative \thinspace using \!.

Moriambar
  • 11,466
Werner
  • 603,163
3

if you want the same spacing use

\begin{equation}
f(x)=\exp\kern\nulldelimiterspace[-\dfrac{x}{2}] 
\end{equation}
  • The space between \exp and \left[ is not \nulldelimiterspace but a thin space because \exp is \mathop and \left is \mathinner. – Philippe Goutet Jan 12 '12 at 08:24
  • I didn't said that! I said that that helps in this case .. –  Jan 12 '12 at 08:25
  • What you said is "if you want the same spacing", which is not what \nulldelimiterspace will give (with the standard value, it will be close, but as both \nulldelimiterspace and the thin space can be changed, there's no guarantee on that always being true). – Philippe Goutet Jan 12 '12 at 11:17
  • everything can be changed ... ;-) –  Jan 12 '12 at 11:47
  • ... but some things remain equal. Loading some math font packages (like fourier) will change the thin space. It's rarer, but some commands do set \nulldelimiterspace to 0pt in their argument (the only example I know is mathtool's \cramped). – Philippe Goutet Jan 12 '12 at 13:54
  • if commands set lengths locally to 0 is not of interest here! –  Jan 12 '12 at 14:24
  • Not quite true, as you could want to write $f(x)=\dfrac{1}{\cramped{\exp\kern\nulldelimiterspace[-\frac{x}{2}]}}$ and get the same result as with $f(x)=\dfrac{1}{\cramped{\exp\left[-\frac{x}{2}\right]}}$, which will not be the case. – Philippe Goutet Jan 12 '12 at 15:37
  • I know all that! And I also know when using \nulldelimterspace and when not! –  Jan 12 '12 at 15:41
  • Sorry for having bothered you, then. I only wanted to try to understand why you suggested using \nulldelimiterspace here even though it has absolutely nothing to do with the problem. It isn't really important anyway, since it's the contrary which must be done: suppress the space between \exp and \left[ instead of adding it between \exp and a normal [. – Philippe Goutet Jan 12 '12 at 20:10