Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
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
add comment

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.