According to the format of the output file, the macro package defines a given symbol:
latex when the output format is LaTeX,
html when the output format is HTML,
man when the output format is groff in conjunction with the
man macro package,
ms when the output format is groff with the ms package,
sgml when the output format is SGML,
txt when the output format is plain ASCII.
The defined symbol can be tested in a document to determine the conversion
type.
Furthermore, the package defines the following macros to send litteral text
(commands in the output format) to the output file:
latexcommand(cmd): sends the LaTeX command cmd when in LaTeX
conversion mode. The cmd is not further expanded.
htmlcommand(cmd): sends the HTML command cmd when in HTML
conversion mode. The cmd is not further expanded.
htmltag(tag)(onoff): sends <tag> to the output when onoff
is nonzero, or sends </tag> when onoff is zero. Only active in
HTML conversions.
mancommand(cmd): sends cmd to the output when in man
conversion mode. The cmd is not further expanded.
mscommand(cmd): sends cmd to the output when in ms
conversion mode. The cmd is not further expanded.
roffcmd(dotcmd)(trailer)(secondline)(thirdline): sends a command
to the output when in man or ms conversion mode. The dotcmd is
the typical groff command that starts with a dot. All other arguments
may be empty, but when given are interpreted as follows. The trailer
follows the dotcmd on the same line. The secondline is sent on a
separate line following the dotcmd and trailer. The thirdline
is sent after that. Of the four arguments, dotcmd and thirdline
are not subject to further expansion. All other arguments are further
expanded if necessary.
The roffcmd macro illustrates the complexity of dot-commands for the
divers groff macro packages. E.g., a section title for the man
package should look as
.SH "Section Title"
while the same command for the ms macro package must be sent as
.SH Section Title .PP
The roffcmd macro can be used to send these commands to the output
file as follows:
COMMENT(For the man output format:)
roffcmd(.SH)("Section Title")()()
COMMENT(For the ms output format:)
roffcmd(.SH)()(Section Title)(.PP)()
sgmlcommand(cmd): sends the SGML command cmd when in SGML
conversion mode. The cmd is not further expanded.
sgmltag(tag)(onoff): sends <tag> when onoff is nonzero,
or sends </tag> when onoff is zero. Only active in SGML
conversions.
txtcommand(cmd): implemented for compatibility reasons, though
a `command' in plain ASCII output doesn't make much sense. The usefulness
of this macro is rather in the fact that it only produces output when in
ASCII conversion mode.
The above commands can be used to quickly implement a macro. E.g., the macro
package implements the it macro (which starts an item in a list) as:
DEFINEMACRO(it)(0)(\
latexcommand(\item )\
htmlcommand(<li> )\
....)
Depending on the output format, it() will lead to one of the above
expansions.
The above described formatcommand() macros are implemented to send not
further expanded strings (i.e., commands) to the output. The macro package
also implements whenformat() macros to send any text, which is
then subject to further expansion. These when...() macros are:
whenlatex(text): sends text when in LaTeX conversion mode,
whenhtml(text): sends text when in HTML conversion mode,
whenman(text): sends text when in man conversion mode,
whenms(text): sends text when in ms conversion mode,
whentxt(text): sends text when in ASCII conversion mode,
whensgml(text): sends text when in SGML conversion mode.
Note again that the difference between the whenformat() macros
and the formatcommand() macros is, that the former will expand their
argument while the latter will not. As an example, consider the following code
fragment:
You are now reading
whenlatex(a LaTeX-generated
footnote(LaTeX is a great
document language!)
document)
whenhtml(a HTML document via your
favorite browser)
The whenformat() macros are used here to make sure that the
arguments to the macros are further expanded; this makes sure that the
footnote macro in the whenlatex block gets treated as a footnote.
Please send Yodl questions and comments to yodl@icce.rug.nl.
Please send comments on these web pages to (address unknown)
Copyright (c) 1997, 1998, 1999 Karel Kubat and Jan Nieuwenhuizen.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.