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: Vincent Lefevre
Subject: Re: spurious space after macro expansion in math mode for TeX output
Date: Tue, 8 Nov 2022 11:27:08 +0100
User-agent: Mutt/2.2.8+45 (c11015d0) vl-149028 (2022-11-06)

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

The manual doesn't say that this is forbidden or that wouldn't work
as expected.

> If you use the code I put in my previous message, that should work.

It works for @atan, but it would not be possible to do this for @sin,
as this would need to redefine a pre-existing TeX operator, which is
discouraged by the manual:

   * It is not advisable to redefine any TeX primitive, plain, or
     Texinfo command name as a macro.  Unfortunately, this is a large
     and open-ended set of names, and the possible resulting errors are
     unpredictable.

So one would need to use something like @mysin{} (with a definition
to expand it to "sin"). But it would be better for source readability
and less confusing if either @math{@sin{}(x)} or @math{@sin(x)} were
allowed.

> > > 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?

Yes, but just because this is not a pre-existing TeX operator;
see above.

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

But if one generates several kinds of output (e.g. Info and PDF),
the braces are required for Info generation, thus will be there
for PDF generation too.

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

The braces are necessary if one wants to generate Info or HTML output
too.

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



reply via email to

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