Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

spacing after \right) and before \left)

203 views
Skip to first unread message

Dave94705

unread,
Aug 12, 2010, 5:50:38 PM8/12/10
to
I have set up a macro for parentheses:

\newcommand{\of}[1]{\left( #1 \right)}

which works wonderfully within math equations, but I have noticed that
if I use a comma (or period, etc.) after it I get a little extra horz.
space after the \right) vs. just using ")" directly even when both
produce the same size symbol ")". Why is this and is there a way to
get rid of this extra space? Thanks, ds

Philipp Stephani

unread,
Aug 12, 2010, 5:59:38 PM8/12/10
to
Dave94705 <david.jobm...@gmail.com> writes:

> I have set up a macro for parentheses:
>
> \newcommand{\of}[1]{\left( #1 \right)}
>
> which works wonderfully within math equations, but I have noticed that
> if I use a comma (or period, etc.) after it I get a little extra horz.
> space after the \right) vs. just using ")" directly even when both
> produce the same size symbol ")". Why is this

\left...\right produces an inner formula. Between an inner formula and
a punctuation atom (class 6) a thin space is inserted in nonscript mode.

> and is there a way to get rid of this extra space?

Manually by inserting a negative thin space:

\nonscript\!

or by inserting a closing atom (class 5):

\right) \mathclose{} .

Spacing between inner and close and between close and punct is both 0.

--
Change “LookInSig” to “tcalveu” to answer by mail.

Mateus Araújo Santos

unread,
Aug 29, 2010, 12:10:39 AM8/29/10
to

I find that just enclosing the macro betwenn {}, like this

\newcommand{\of}[1]{{\left( #1 \right)}}

also works, except when I use an operator before \of, like \sin\of{x}.
Why is that so? It is a bug with amsmath?

I'm sorry, I just want a way to do it with a code less ugly than yours.

--
entropy happens

Heiko Oberdiek

unread,
Aug 29, 2010, 2:56:58 AM8/29/10
to

The curly braces generate a subformula, that is a math ordinary atom
(\mathord). TeX inserts a thin space between an operator and
a ordinary atom.

Again you need a \mathopen at the left and a \mathclose at the right:

\newcommand*{\of}[1]{%
\mathopen{}\left(#1\right)\mathclose{}%
}

> It is a bug with amsmath?

No, that's normal TeX behaviour.
See "The TeXbook" by D.E. Knuth, chapter "18 Fine Points of
Mathematics Typing", section "4. Spacing within formulas".
There is a table that shows the spacing between the different
math atoms.

--
Heiko Oberdiek

Mateus Araújo Santos

unread,
Aug 29, 2010, 12:49:55 PM8/29/10
to

Thanks! Now it doesn't look like a hack.

>
>> It is a bug with amsmath?
>
> No, that's normal TeX behaviour.
> See "The TeXbook" by D.E. Knuth, chapter "18 Fine Points of Mathematics
> Typing", section "4. Spacing within formulas". There is a table that
> shows the spacing between the different math atoms.


I've read, and although I understand how the code does what it does, I
can't understand why Knuth would want it that way. Is there any scenario
that it is desirable to have \left produce an inner atom? is there a
command equivalent to \left that produces an Ord atom?

I'm flabbergasted. I had a firm belief that TeX was perfect...


--
entropy happens

Heiko Oberdiek

unread,
Aug 29, 2010, 1:49:00 PM8/29/10
to
Mateus Araújo Santos <h137035....@yahoo.com.br> wrote:

> I'm flabbergasted. I had a firm belief that TeX was perfect...

There isn't a "perfect world". Good typesetting is the art to
find a good compromise.

--
Heiko Oberdiek

Donald Arseneau

unread,
Aug 29, 2010, 11:21:17 PM8/29/10
to
Mateus Araújo Santos <h137035....@yahoo.com.br> writes:
(et al.)

> >> > \nonscript\!
> >> >
> >> > or by inserting a closing atom (class 5):
> >> >
> >> > \right) \mathclose{} .

Indeed the best way.

> >> \newcommand{\of}[1]{{\left( #1 \right)}}

I like:

\newcommand\lft{\mathopen{}\left}
\newcommand\rgt{\aftergroup\mathclose\aftergroup{\aftergroup}\right}

and these can be used to replace the intrinsic \left and \right.

> I'm flabbergasted. I had a firm belief that TeX was perfect...

Then you haven't been paying attention.

--
Donald Arseneau as...@triumf.ca

Mateus Araújo Santos

unread,
Aug 30, 2010, 1:01:56 AM8/30/10
to
On Sun, 29 Aug 2010 20:21:17 -0700, Donald Arseneau wrote:

> Mateus Araújo Santos <h137035....@yahoo.com.br> writes: (et al.)
>> >> > \nonscript\!
>> >> >
>> >> > or by inserting a closing atom (class 5):
>> >> >
>> >> > \right) \mathclose{} .
>
> Indeed the best way.
>
>> >> \newcommand{\of}[1]{{\left( #1 \right)}}
>
> I like:
>
> \newcommand\lft{\mathopen{}\left}
> \newcommand\rgt{\aftergroup\mathclose\aftergroup{\aftergroup}\right}

Would you care to explain why

\newcommand\rgt{\right\matclose{}}

wouldn't work?

> and these can be used to replace the intrinsic \left and \right.
>
>> I'm flabbergasted. I had a firm belief that TeX was perfect...
>
> Then you haven't been paying attention.

Au contraire. I've been using TeX for three years, and I know quite a lot
of it. But all warts that I'd found were due to its old age; this is the
first that is plain and simple bad design.

--
entropy happens

Donald Arseneau

unread,
Aug 30, 2010, 2:19:31 AM8/30/10
to
Mateus Araújo Santos <h137035....@yahoo.com.br> writes:

> On Sun, 29 Aug 2010 20:21:17 -0700, Donald Arseneau wrote:
> > \newcommand\lft{\mathopen{}\left}
> > \newcommand\rgt{\aftergroup\mathclose\aftergroup{\aftergroup}\right}
>
> Would you care to explain why
>
> \newcommand\rgt{\right\matclose{}}
>
> wouldn't work?

because then \rgt) gives \right\mathclose{}) which is clearly wrong;
you want \right)\mathclose{}

Before you suggest

\newcommand\rgt[1]{\right#1\mathclose{}}

be aware that the rules for a delimiter and a macro parameter are different,
and only sometimes correspond.

\right\rangle check
\right\delimiter"5267309 oops


--
Donald Arseneau as...@triumf.ca

Mateus Araújo Santos

unread,
Aug 31, 2010, 9:42:26 PM8/31/10
to


I see that you did quite the homework with this macro; thank you very
much!

I'm posting this thread to http://tex.stackexchange.com/q/2607/1035


--
entropy happens

Mateus Araújo Santos

unread,
Sep 1, 2010, 2:00:55 AM9/1/10
to
On Sun, 29 Aug 2010 23:19:31 -0700, Donald Arseneau wrote:


actually, could you give an example where

\newcommand\rgt[1]{\right#1\mathclose{}}

fails?


--
entropy happens

Donald Arseneau

unread,
Sep 1, 2010, 4:28:50 AM9/1/10
to

Actually I did. \rgt\delimiter"5267309

--
Donald Arseneau as...@triumf.ca

Mateus Araújo Santos

unread,
Sep 1, 2010, 8:43:56 AM9/1/10
to
On Wed, 01 Sep 2010 01:28:50 -0700, Donald Arseneau wrote:

> Mateus Araújo Santos <h137035....@yahoo.com.br> writes:
>
>> > \right\rangle check
>> > \right\delimiter"5267309 oops
>
>> actually, could you give an example where
>>
>> \newcommand\rgt[1]{\right#1\mathclose{}}
>>
>> fails?
>
> Actually I did. \rgt\delimiter"5267309


oh indeed. sorry.


--
entropy happens

Mateus Araújo Santos

unread,
Sep 12, 2010, 2:50:54 AM9/12/10
to
On Sun, 29 Aug 2010 20:21:17 -0700, Donald Arseneau wrote:


Actually I've found a problem with your approach. If you use

\[ \lft\| A^2 \rgt\|_2 \]

the subscript will not accompany the growth of the \|, and you end up in
its center (which is awful).

The problem is not with your code, but with mathclose{}

\[ \left\| A^2 \right\|\mathclose{}_2 \]

also fails. There is something weird going on: \Bigl and \Bigr also use
opening and closing atoms (see latex.ltx), but they work correctly in
this example.

Can someone tell me where is the definition of \left and \right? Why does
it work so strangely?


--
entropy happens

Philipp Stephani

unread,
Sep 12, 2010, 4:15:25 AM9/12/10
to

\left and \right are primitives. _ is applied to the preceding
mathgroup, which in your case is the empty atom \mathclose{}, but it
should be the entire inner formula:

\mathopen{} \mathclose{\left\| A^2 \right\|}_2

Looks weird, but works.

Mateus Araújo Santos

unread,
Sep 12, 2010, 3:21:53 PM9/12/10
to

Well, shit. If that is the only way I guess there goes my hope of
defining a new macro to fix \left and \right.

--
entropy happens

Heiko Oberdiek

unread,
Sep 12, 2010, 4:16:25 PM9/12/10
to
Mateus Araújo Santos <h137035....@yahoo.com.br> wrote:

> On Sun, 12 Sep 2010 10:15:25 +0200, Philipp Stephani wrote:
>
> > Mateus Araújo Santos <h137035....@yahoo.com.br> writes:
> >
> >> On Sun, 29 Aug 2010 20:21:17 -0700, Donald Arseneau wrote:
> >>
> >>> I like:
> >>>
> >>> \newcommand\lft{\mathopen{}\left}
> >>> \newcommand\rgt{\aftergroup\mathclose\aftergroup{\aftergroup}\right}
> >>>
> >>> and these can be used to replace the intrinsic \left and \right.

> >> Actually I've found a problem with your approach. If you use


> >>
> >> \[ \lft\| A^2 \rgt\|_2 \]
> >>
> >> the subscript will not accompany the growth of the \|, and you end up
> >> in its center (which is awful).
> >>
> >> The problem is not with your code, but with mathclose{}
> >>
> >> \[ \left\| A^2 \right\|\mathclose{}_2 \]
> >>
> >> also fails. There is something weird going on: \Bigl and \Bigr also use
> >> opening and closing atoms (see latex.ltx), but they work correctly in
> >> this example.

> > \mathopen{} \mathclose{\left\| A^2 \right\|}_2

> Well, shit. If that is the only way I guess there goes my hope of

> defining a new macro to fix \left and \right.

Combining Donald's macros with Philipp's suggestion:

\newcommand\lft{\mathopen{}\mathclose\bgroup\left}
\newcommand\rgt{\aftergroup\egroup\right}

--
Heiko Oberdiek

Mateus Araújo Santos

unread,
Sep 12, 2010, 6:02:24 PM9/12/10
to

Quite ingenious! I was trying to do it with {}, but it obviously didn't
work. Thanks =)

--
entropy happens

Donald Arseneau

unread,
Sep 12, 2010, 8:10:45 PM9/12/10
to
Philipp Stephani <Look...@arcor.de> writes:

> Mateus Ara?jo Santos <h137035....@yahoo.com.br> writes:

> > \[ \lft\| A^2 \rgt\|_2 \]
> >
> > the subscript will not accompany the growth of the \|, and you end up in
> > its center (which is awful).
> >

> > \[ \left\| A^2 \right\|\mathclose{}_2 \]

Oh yes, very bad.

> \mathopen{} \mathclose{\left\| A^2 \right\|}_2

Wonderfully dirty! (Heiko too.)

--
Donald Arseneau as...@triumf.ca

Heiko Oberdiek

unread,
Sep 25, 2010, 6:43:15 PM9/25/10
to
Heiko Oberdiek <heiko.o...@googlemail.com> wrote:

> Combining Donald's macros with Philipp's suggestion:
>
> \newcommand\lft{\mathopen{}\mathclose\bgroup\left}
> \newcommand\rgt{\aftergroup\egroup\right}

I have now made a package `mleftright',
available temporarily (until next bundle update):
http://www.informatik.uni-freiburg.de/~oberdiek/tmp/mleftright.pdf
(See section "Installation" for details.)

--
Heiko Oberdiek

0 new messages