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

I'm using the fancyvrb package with the \DefineShortVerb{\|}. However, using | inside of any command doesn't work. MWE:




\section{|Pipe| doesn't work here}
THe |pipe| works here just fine. \marginpar{|Pipe| doesn't work here either.}


Is it possible to define a ShortVerb and have it work inside of other commands? I wasn't able to find anything about this in the documentation.

share|improve this question
Short answer: no. – egreg Jan 3 '13 at 20:33
@egreg what about a workaround? another package? – jlconlin Jan 3 '13 at 20:42
It doesn't depend on how many packages you load: verbatim material cannot go inside the argument to another command. If the characters to appear verbatim satisfy some restrictions, it can be done; but if you want arbitrary material, you're out of luck. – egreg Jan 3 '13 at 20:45
@egreg that's what I was afraid of. – jlconlin Jan 3 '13 at 20:52
fancyvrb comes with a \SaveVerb command and UseVerb command that let's you work around these sorts of issues. But as @egreg has said, the short aswer is "no". – A.Ellett Jan 3 '13 at 20:53

If you're really wedded to the idea of using verbatim and since you're already using fancyvrb you can do the following:'

\SaveVerb{verb:example}|\this is saved|

enter image description here

This will also work in a \section command if you prepend \protect\UseVerb{verb:example}. Though I'm not sure how this will effect TOC.

Otherwise, I would stick with @egreg's suggestions.

share|improve this answer
This is a good idea if I had to reuse the same thing many times, but is a little much for one-off formatting. – jlconlin Jan 3 '13 at 21:05

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.