[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: spurious space after macro expansion in math mode for TeX output
From: |
Vincent Lefevre |
Subject: |
Re: spurious space after macro expansion in math mode for TeX output |
Date: |
Tue, 8 Nov 2022 03:57:48 +0100 |
User-agent: |
Mutt/2.2.8+45 (c11015d0) vl-149028 (2022-11-06) |
On 2022-11-07 16:33:56 +0000, Gavin Smith wrote:
> On Mon, Nov 07, 2022 at 04:08:54PM +0100, Vincent Lefevre wrote:
> > Consider the following test.texi file:
> >
> > ------------------------------------------------------------
> > \input texinfo @c -*-texinfo-*-
> >
> > @tex
> > \gdef\atan{\mathop{\rm atan}}
> > @end tex
> >
> > @ifnottex
> > @macro atan
> > atan
> > @end macro
> > @end ifnottex
> >
> > @node Top
> > @node Test
> >
> > Spacing test with atan.
> >
> > @math{@atan{}(x)}
> >
> > @math{\atan(x)}
> >
> > @bye
> > ------------------------------------------------------------
> >
> > and run "texi2dvi --pdf test.texi".
> >
> > With \atan, everything is fine. But with @atan{}, I get a spurious
> > space between "atan" and "(x)" in the generated PDF, though the
> > result should be identical to \atan.
>
> This is not actually a Texinfo problem, as you are not using
> a Texinfo macro, but a TeX macro. The same output difference
> would occur even without macros.
OK. I thought that since {} is part of the macro syntax, its
was removed, i.e. that the Texinfo macro was converted to a
TeX macro.
Note that there is the same issue with a Texinfo macro, i.e. with
@iftex
@macro atan
\\mathop{\\rm atan}
@end macro
@end iftex
instead of the \gdef\atan{\mathop{\rm atan}}. This is even more
unexpected, and this seems to be a Texinfo problem.
> I suspect the braces are affecting the spacing in math mode. The
> empty {} is treated as a symbol.
>
> You may remove the braces thusly:
>
> @tex
> \gdef\atan#1{\mathop{\rm atan}}
> @end tex
>
> See how the #1 parameter will absorb the empty braces. With this
> definition, @atan{} must be used, not just @atan (without braces).
Anyway, 16.2 Invoking Macros says "The braces are required in the
invocation even when the macro takes no arguments".
However, the consequence is that if \atan is used, it must be followed
by {}, e.g. \atan{}(y/x).
So there are 2 issues:
1. This is inconsistent with the pre-existing TeX operators:
\sin(x) is OK, but not \sin{}(x).
2. This doesn't solve the issue with the pre-existing TeX operators:
@math{@sin{}(x)} yields a spurious space because the pre-existing
operators do not expect a {}.
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
- spurious space after macro expansion in math mode for TeX output, Vincent Lefevre, 2022/11/07
- Re: spurious space after macro expansion in math mode for TeX output, Gavin Smith, 2022/11/07
- Re: spurious space after macro expansion in math mode for TeX output,
Vincent Lefevre <=
- Re: spurious space after macro expansion in math mode for TeX output, Gavin Smith, 2022/11/08
- Re: spurious space after macro expansion in math mode for TeX output, Vincent Lefevre, 2022/11/08
- Re: spurious space after macro expansion in math mode for TeX output, Gavin Smith, 2022/11/08
- Re: spurious space after macro expansion in math mode for TeX output, Vincent Lefevre, 2022/11/08
- Re: spurious space after macro expansion in math mode for TeX output, Patrice Dumas, 2022/11/09
- Re: spurious space after macro expansion in math mode for TeX output, Vincent Lefevre, 2022/11/09
- Re: spurious space after macro expansion in math mode for TeX output, Vincent Lefevre, 2022/11/09
- Re: spurious space after macro expansion in math mode for TeX output, Vincent Lefevre, 2022/11/09
- Re: spurious space after macro expansion in math mode for TeX output, Gavin Smith, 2022/11/12
- Re: spurious space after macro expansion in math mode for TeX output, Vincent Lefevre, 2022/11/12