Next: , Previous: , Up: Quotations and Examples   [Contents][Index]

10.4 @example: Example Text

The @example environment is used to indicate an example that is not part of the running text, such as computer input or output. Write an @example command at the beginning of a line by itself. Mark the end of the example with an @end example command, also written at the beginning of a line by itself.

An @example environment has the following characteristics:

For example,

cp foo @var{dest1}; \
 cp foo @var{dest2}
@end example


cp foo dest1; \
 cp foo dest2

The lines containing @example and @end example will disappear from the output. To make the output look good, you should put a blank line before the @example and another blank line after the @end example. Blank lines inside the beginning @example and the ending @end example, on the other hand, do appear in the output.

Caution: Do not use tabs in the lines of an example! (Or anywhere else in Texinfo, except in verbatim environments.) TeX treats tabs as single spaces, and that is not what they look like. In Emacs, you can use M-x untabify to convert tabs in a region to multiple spaces.

Examples are often, logically speaking, “in the middle” of a paragraph, and the text that continues afterwards should not be indented, as in the example above. The @noindent command prevents a piece of text from being indented as if it were a new paragraph (see @noindent.

If you want to embed code fragments within sentences, instead of displaying them, use the @code command or its relatives (see @code).

If you wish to write a “comment” on a line of an example in the normal roman font, you can use the @r command (see Fonts).
