WeBWorK Main Forum

Why negative space in LaTeX

Re: Why negative space in LaTeX

by Alex Jordan -
Number of replies: 1

> I have given it some thought, and perhaps a better idea would be to use \mathopen{\left(...\right)} around the parenthesis group, and \mathclose{} following it so that the parentheses appear to work as open and close items. This will get the correct spacing for \sin(x) as well as 6(x^3-1). This could be done in both locations that identified by Alex.

I use a variant of that approach a lot, usually buried in macros, where the \mathopen{} is empty at the beginning. I have found one bad side effect worth noting (and you will know better if that matters for MathObjects). If you have something like:

\ln\mathopen{}\left(\frac{x}{2}\right)\mathclose{}^2

then the exponent positioning at the end is bad. It's worse than the spacing issues at the front. In your version, the exponent spacing is better, but the exponent vertical positioning is not great:

\ln\mathopen{\left(\frac{x}{2}\right)}\mathclose{}^2

At least in this example, the following looks good without the \mathclose{}:

\ln\mathopen{}\left(\frac{x}{2}\right)^2

Meanwhile this version brings back extra space at the front:

\ln\mathopen{\left(\frac{x}{2}\right)}^2


Even with \ln\mathopen{}\left(\frac{x}{2}\right)^2, it's still hard to feel secure that there is not some unforeseen bad side effect.

On rare occasions, I have seen the \! causing characters to actually overlap a little. Maybe it is font dependent. That seems worse than having excess space.


In reply to Alex Jordan

Re: Why negative space in LaTeX

by Davide Cervone -

> If you have something like: > > \ln\mathopen{}\left(\frac{x}{2}\right)\mathclose{}^2 > > then the exponent positioning at the end is bad.

You are correct, that is a bad side-effect. I think the solution is to do

\ln\mathopen{}\mathclose{\left(\frac{x}{2}\right)}^2

so that the CLOSE applies to the whole parenthetic group (instead of the OPEN, as in my example). That will allow the position of the square to be correct, and will get the correct spacing before it.