Next: , Up: Conditionals   [Contents][Index]


16.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:

@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 Raw Formatter Commands, for using underlying format commands directly.

Here is an example showing all these conditionals:

@iftex
This text will appear only in the printed manual.
@end iftex
@ifinfo
However, this text will appear only in Info and plain text.
@end ifinfo
@ifhtml
And this text will only appear in HTML.
@end ifhtml
@ifplaintext
Whereas this text will only appear in plain text.
@end ifplaintext
@ifxml
Notwithstanding that this will only appear in XML.
@end ifxml
@ifdocbook
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.

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 External Macro Processors, for a caveat regarding the line numbers which @errormsg emits in TeX.


Next: , Up: Conditionals   [Contents][Index]