help-texinfo
[Top][All Lists]

[help-texinfo] Macros within @example and newlines, with TeX output

 From: Luca Saiu Subject: [help-texinfo] Macros within @example and newlines, with TeX output Date: Tue, 16 Apr 2013 19:10:44 +0200 User-agent: Gnus (Gnus v5.13), GNU Emacs 24.2.50.1, x86_64-unknown-linux-gnu

Hello.

I'm hesitating a little before reporting the following behavior as a
bug, since the thing is quite easy to observe, and the documentation
seems to give very weak guarantees in my case (section "Macro Details
and Caveats").

So, here's the problem.

Say that I have a simple macro definition, just returning some text.  We
can use the "identity" macro as an example, which is enough to trigger
the behavior I want to show:

--8<---------------cut here---------------start------------->8---
@macro q{text}
\text\
@end macro
--8<---------------cut here---------------end--------------->8---

This macro normally works fine, and does not introduce extra whitespace:
address@hidden expands to aabbaa, which is fine.

The thing misbehaves within @example, only with TeX output, where a
newline is inserted at the end of the expansion.  If I observed
correctly, one newline per macro nesting level (just one in the case of
q):

--8<---------------cut here---------------start------------->8---
@example
@end example
--8<---------------cut here---------------end--------------->8---

The @example above generates

aabb
aa

with TeX output, breaking the line after the macro expansion -- even if
it still does the right thing with info, plain text and HTML.  I'm only
writing about user-defined macros: markup @-commands such as @emph or
@strong work fine within @example, without generating extra whitespace.

Is this intended behavior?  I couldn't follow the internals of
texinfo.tex, but I guess the answer is there.

Important detail: invoking texi2pdf or texi2dvi using the option -E
works around the problem, and is a perfect solution in my personal case.
But maybe this interaction between @example and macros should be
documented clearly, or -E made the default.  Or is it not the default
just for compatibility's sake?

By the way, in practice when generating TeX (but not with makeinfo) I
can suppress the newline after the macro body, and move the closing
"@end macro" right after "\text\", on the same line.  That *doesn't*
affect the output.

I've attached a complete testcase, in case this is issue news for you --
but I doubt it.  The behavior I observe is the same with Texinfo 5.1 and
the old 4.13.

Thanks a lot.  Despite this kind of little warts, I've always liked
Texinfo.

Regards,

--
Luca Saiu