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?
Asked
Active
Viewed 1,321 times
13
1 Answers
12
* 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^^@
David Carlisle
- 757,742
-
Which means if I change
"to the\catcodeof^^@(ASCII null) it will give the same error if I use"for the\verbdelimiter, right? – MickG Sep 28 '14 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 – David Carlisle Sep 28 '14 at 14:40
*is the only one (apart from a space, of course). But sticking to|or!or"is better. – egreg Sep 28 '14 at 13:41\verbas in the case of the linked question? – MickG Sep 28 '14 at 13:44=is also quite common – Joseph Wright Sep 28 '14 at 13:44\catcode11 (letter) can't be used, can they? What\catcodes allow characters to delimit\verb's argument? – MickG Sep 28 '14 at 13:47%if you want – David Carlisle Sep 28 '14 at 13:55\verbawill surely not be interpreted as\verbwithaas delimiter, right? And neither will\verb\be taken for a\-delimited\verb, right? But then if I (I certainly won't, but in the absurd hypothesis I did) changed%to catcode 11 or escape, it couldn't be used as a\verbdelimiter either, could it? So\catcodeis relevant, unless I wrote some bogus up there :). – MickG Sep 28 '14 at 14:33\verbwithout tokenizing what follows. For example\makeatletter\@firstofone{\verb}a#%a– Joseph Wright Sep 28 '14 at 15:08