On 2022-11-09 12:47:38 +0100, Patrice Dumas wrote:
> On Tue, Nov 08, 2022 at 11:07:51PM +0100, Vincent Lefevre wrote:
> >
> > Well, let's try. :-)
> >
> > ------------------------------------------------------------
> > \input texinfo @c -*-texinfo-*-
> >
> > @tex
> > \gdef\texatan{\mathop{\rm atan}}
> > @end tex
> >
> > @iftex
> > @macro atan
> > \\mathop{\\rm atan}
> > @end macro
> > @end iftex
> >
> > Spacing test with atan.
> >
> > @math{\mathop{\rm atan}(x)}
> >
> > @math{\texatan(x)}
> >
> > @math{@atan{}(x)}
> >
> > @bye
> > ------------------------------------------------------------
> >
> > I get:
> >
> > Spacing test with atan.
> > atan(x)
> > atan(x)
> > atan (x)
and for the last line, also a space before "atan" in the PDF rendering.
> > So, one gets the expected behavior with the TeX macro (no space added).
> > But with the Texinfo macro, a space is added. This is unexpected: one
> > should have got the same behavior as with the Tex macro. This means
> > that Texinfo is adding something else in its macro expansion.
BTW, with a slight modification of the Texinfo macro, i.e. accepting
a dummy argument:
------------------------------------------------------------
\input texinfo @c -*-texinfo-*-
@tex
\gdef\texatan{\mathop{\rm atan}}
@end tex
@iftex
@macro atan {T}
\\mathop{\\rm atan}
@end macro
@end iftex
Spacing test with atan.
@math{\mathop{\rm atan}(x)}
@math{\texatan(x)}
@math{@atan{z}(x)}
@bye
------------------------------------------------------------
the space after "atan" is no longer there!!! But the space before
"atan" in the PDF rendering is still there.
If there is something before atan:
@math{k\mathop{\rm atan}(x)}
@math{k\texatan(x)}
@math{k@atan{z}(x)}
I get the correct output in all of these 3 cases.
> I am not sure that this can be easily fixed, there are lots of caveats
> put forward in the manual because macros in TeX is an area where things
> seems to be difficult to get right, but I agree that this is an issue as
> I can't see what in the macro definition would trigger an extra space
> (and the equivalent using texi2any macros would not have that space,
> though it is may not be relevant to the issue). If it cannot be fixed,
> maybe it could be documented?
I suggest to search for the explanation of the behavior. It seems
that Texinfo behaves as if did not check that there was something
empty (which makes TeX generate a space).
--
Vincent Lefèvre <[email protected]> - 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)