\verb char literal-text char \verb* char literal-text char
Typeset literal-text as it is input, including special characters
and spaces, using the typewriter (
This example shows two different invocations of
This is \verb!literally! the biggest pumpkin ever. And this is the best squash, \verb+literally!+
\verb has its literal-text surrounded with
!. The second instead uses plus,
because the exclamation point is part of
The single-character delimiter char surrounds
literal-text — it must be the same character before and
after. No spaces come between
char, or between char and literal-text, or between
literal-text and the second occurrence of char (the synopsis
shows a space only to distinguish one component from the other). The
delimiter must not appear in literal-text. The literal-text
cannot include a line break.
*-form differs only in that spaces are printed with a visible
The output from this will include a character showing the spaces.
The commands's first argument is \verb*!filename with extension! and ...
For typesetting Internet addresses, urls, the package
provides an option that is better than the
\verb command, since
it allows line breaks.
For computer code there are many packages with advantages over
\verb. One is listings, another is minted.
You cannot use
\verb in the argument to a macro, for instance in
the argument to a
\section. It is not a question of
being fragile (see \protect), instead it just cannot appear there.
cprotect package can help with this.)