manpagez: man pages & more
info texinfo
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

18.1 Conditional Commands

Texinfo has an @ifformat environment for each output format, to allow conditional inclusion of text for a particular output format.

@ifinfo begins segments of text that should be ignored by TeX when it typesets the printed manual, and by makeinfo when not producing Info output. The segment of text appears only in the Info file and, for historical compatibility, the plain text output.

The environments for the other formats are analogous, but without the special historical case:

@ifdocbook … @end ifdocbook

Text to appear only in the Docbook output.

@ifhtml … @end ifhtml

Text to appear only in the HTML output.

@ifplaintext … @end ifplaintext

Text to appear only in the plain text output.

@iftex … @end iftex

Text to appear only in the printed manual.

@ifxml … @end ifxml

Text to appear only in the XML output.

The @if… and @end if… commands must appear on lines by themselves in your source file. The newlines following the commands are (more or less) treated as whitespace, so that the conditional text is flowed normally into a surrounding paragraph.

The @if… constructs are intended to conditionalize normal Texinfo source; see section Raw Formatter Commands, for using underlying format commands directly.

Here is an example showing all these conditionals:

This text will appear only in the printed manual.
@end iftex
However, this text will appear only in Info and plain text.
@end ifinfo
And this text will only appear in HTML.
@end ifhtml
Whereas this text will only appear in plain text.
@end ifplaintext
Notwithstanding that this will only appear in XML.
@end ifxml
Nevertheless, this will only appear in Docbook.
@end ifdocbook

The preceding example produces the following line:

And this text will only appear in HTML.

Notice that you only see one of the input lines, depending on which version of the manual you are reading.

In complex documents, you may want Texinfo to issue an error message in some conditionals that should not ever be processed. The @errormsg{text} command will do this; it takes one argument, the text of the error message, which is expanded more or less as if it were Info text.

We mention @errormsg{} here even though it is not strictly related to conditionals, since in practice it is most likely to be useful in that context. Technically, it can be used anywhere. See section External Macro Processors: Line Directives, for a caveat regarding the line numbers which @errormsg emits in TeX.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on October 2, 2013 using texi2html 5.0.

© 2000-2017
Individual documents may contain additional copyright information.