next up previous
Next: Mathematics Up: The Basics of LATEX Previous: Text Styles

Verbatim Output

Sometimes you would like LATEX to output things exactly as you type them, without interpreting special characters in the input. This would be particularly useful when including some programming source code in your document, for example. You can do this with the verbatim environment. That is, if you put the command \begin{verbatim} at the beginning of some text and \end{verbatim} at the end, then LATEX will reproduce the text in the output, in typewriter style, exactly as it is typed in the input. Spaces and ends-of-line are copied to the output as well as other special characters.

If you want to include just a few words of verbatim output in the middle of a paragraph (as I do many times in this paper), you can use \verb. This command takes a special form: \verb=verbatim text=. The text between the two equal signs is copied directly to the output in typewriter style. This text can contain any character except an equal sign, but cannot extend over more than one line. (If the text you want to output does contain a =, you can replace the = in the \verb command with any other character.) One problem with \verb is that it doesn't work inside the parameters of other commands, such as \footnote.


next up previous
Next: Mathematics Up: The Basics of LATEX Previous: Text Styles
David Eck 2003-10-21