bug-texinfo
[Top][All Lists]
Advanced

[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: Gavin Smith
Subject: Re: spurious space after macro expansion in math mode for TeX output
Date: Tue, 8 Nov 2022 07:04:11 +0000

On Tue, Nov 08, 2022 at 03:57:48AM +0100, Vincent Lefevre wrote:
> 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.

Yes, but it is unlikely that this can be fixed.  If you use the code
I put in my previous message, that should work.

> 
> > 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).
> 

Have you tried this code and did it work?

> Anyway, 16.2 Invoking Macros says "The braces are required in the
> invocation even when the macro takes no arguments".

That text is for Texinfo macros, not for TeX macros defined with \gdef.

> 
> 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 {}.

I don't see that there's any benefit to changing the pre-existing TeX
operators to accept braces.  If you are using your own macros then the
inconsistency is something you will have to accept, I believe.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]