TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I make an item in a description list verbatim? \verb in \item[] seems to be not allowed:

    \item[\verb+list comprehension [f a | a <- M a]+] bla bla bla
share|improve this question
up vote 13 down vote accepted

The package examplep provides several commands and environments for typesetting verbatim text. For instance, the robust commands \PVerb[options]{text}and \Q{text} can be used in macro arguments and in section titles as well.

Code example for your description list:

    \item[\Q{list comprehension [f a | a <- M a]}] bla bla bla
    \item[\PVerb{testing: \verb||{} #_$ }] item text


verbatim example

See Verbatim phrases and listings in LaTeX by Péter Szabó (or texdoc examplep) for further information. Escaping special characters (for instance with \Q) may be necessary as described in section 3.1 of the documentation.

Note, T1 font encoding has to be use to get a proper < symbol because it's unavailable in standard OT1 encoding.

share|improve this answer

The \verb command is not allowed inside arguments of other commands. One workaround is to use \SaveVerb from fancyvrb.

The following definition of \vitem is taken from the Companion. It has an optional argument taking styling parameters from the fancyvrb package.



    \vitem+list comprehension [f a | a <- M a]+ bla bla bla
share|improve this answer

Your Answer


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.