By design, macro expansion should not happen in the following contexts:
@macro
and @unmacro
lines;
@if...
lines, including @ifset
and similar;
@set
, @clear
, @value
;
@clickstyle
lines;
@end
lines when there is no macro expansion in the block
command.
Unfortunately, TeX may do some expansion in these situations, possibly yielding errors.
Also, quite a few macro-related constructs cause problems with TeX;
some of the caveats are listed below. Thus, if you get macro-related
errors when producing the printed version of a manual, you might try
expanding the macros with texi2any
by invoking
texi2dvi
with the ‘-E’ option (see Format with texi2dvi
). Or, more reliably, eschew Texinfo macros altogether
and use a language designed for macro processing, such as M4
(see External Macro Processors: Line Directives).
@example
environments, may behave unpredictably in TeX.
@macro Mac @iftex text for TeX output @end iftex @ifnottex text for not TeX output @end ifnottex @end macro
you can do the following instead:
@iftex @macro Mac text for TeX output @end macro @end iftex @ifnottex @macro Mac text for not TeX output @end macro @end ifnottex
@comma{}
must be used.
texi2any
. This is
not the case when processing with TeX. This was often done
to “comment out” an unwanted newline at the end of a macro body, but
this is not necessary any more, as the final newline before ‘@end
macro’ is not included in the macro body anyway.
@value
) call for Texinfo command arguments, even when the text
is the same. Texinfo is not M4 (or even plain TeX). It might work
with some commands, it fails with others. Best not to do it at all.
For instance, this fails:
@macro offmacro off @end macro @headings @offmacro
This looks equivalent to @headings off
, but for TeXnical
reasons, it fails with a mysterious error message (namely,
‘Paragraph ended before @headings was complete’).
@ifnottex @macro ctor {name, arg} @macro \name\ something involving \arg\ somehow @end macro @end macro @end ifnottex @tex \gdef\ctor#1{\ctorx#1,} \gdef\ctorx#1,#2,{\def#1{something involving #2 somehow}} @end tex
The following limitations are by design:
@,
(to produce a cedilla, see Inserting Accents), you have
to use @value
or another workaround. Otherwise, the comma
may be taken as separating the arguments. With texi2any
,
the comma can be escaped by a backslash. With TeX another workaround
need to be used, therefore we recommend using such a workaround.
For example,
@macro mactwo{argfirst, argsecond} \argfirst\+\argsecond\. @end macro @set fc Fran@,cois @mactwo{@value{fc},}
produces:
François+.
@verbatim
and macros do not mix; for instance, you can’t start
a verbatim block inside a macro and end it outside
(see @verbatim
: Literal Text). Starting any environment inside a macro
and ending it outside may or may not work, for that matter.
@macro
and @end macro
(likewise for @rmacro
) must be
correctly paired. For example, you cannot start a macro definition
within a macro, and then end that nested definition outside the macro.
In the makeinfo
implementation before Texinfo 5.0, ends of
lines from expansion of a @macro
definition did not end an
@-command line-delimited argument (@chapter
, @center
,
etc.). This is no longer the case. For example:
@macro twolines{} aaa bbb @end macro @center @twolines{}
In the current texi2any
, this is equivalent to:
@center aaa bbb
with just ‘aaa’ as the argument to @center
. In
the earlier implementation, it would have been parsed as this:
@center aaa bbb