What are the differences between verb and verbatim? Other than syntax, of course.

  • 3
    There is always a certain character which cannot be part of \verb text. verbatim always starts and ends with a new line. – Stephan Lehmke Dec 11 '12 at 17:58
  • 4
    \verb is used "in line", while verbatim makes a display. – egreg Dec 11 '12 at 18:00

From source2e:

The verbatim environment uses the fixed-width \ttfamily font, turns blanks into spaces, starts a new line for each carriage return (or sequence of consecutive carriage returns), and interprets every character literally. I.e., all special characters \, {, $, etc. are \catcode'd to "other".

The command \verb produces in-line verbatim text, where the argument is delimited by any pair of characters. E.g., \verb #...# takes "..." as its argument, and sets it verbatim in \ttfamily font. The *-variants of these commands are the same, except that spaces print as the TeXbook's space character instead of as blank spaces.

In particular, the character used to delimit the contents of \verb cannot appear in the verbatim text. Additionally, \verb is meant for in-line verbatim expressions and doesn't admit carriage returns as verbatim does; a carriage return inside \verb triggers the error

! LaTeX Error: \verb ended by end of line.

The verbatim environment always starts and ends with a new line.

verbatim applies a series of additional precautions; for example, a previous use of \parshape won't affect the contents of the verbatim environment.

Your Answer

