I have seen \verb
's argument delimited by many characters. I started out with " "
, then I saw it done with # #
and verified it worked, and I just saw it done with | |
right here in egreg's answer. So I was wondering: what other characters can be used? Is there any difference in using one delimiter or another? In fact, seeing this makes me wonder: is there any symbol I can't use with \verb
?
1 Answer
*
makes \verb*
so can't be used for the non-star form without hacking internals, but apart from that any character may be used, the reason is that you need to choose a character that is not in the string that is being set verbatim.
Note that latex doesn't make all symbols safe in verbatim (or for the verb delimiter) If you try to use an ascii null (byte 0) as the delimiter you get
! Text line contains an invalid character.
l.6 \verb^^@
-
Which means if I change
"
to the\catcode
of^^@
(ASCII null) it will give the same error if I use"
for the\verb
delimiter, right?– MickGCommented Sep 28, 2014 at 14:36 -
@MickG yes the error is nothing to do with verb: latex sets \catcode0=15 so 0 is an illegal character pretty much anywhere and its verbatim code doesn't (but could) change that Commented Sep 28, 2014 at 14:40
*
is the only one (apart from a space, of course). But sticking to|
or!
or"
is better.\verb
as in the case of the linked question?=
is also quite common\catcode
11 (letter) can't be used, can they? What\catcode
s allow characters to delimit\verb
's argument?\verb
without tokenizing what follows. For example\makeatletter\@firstofone{\verb}a#%a