Next: , Up: Conditionals


17.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.

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.