Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to add an inline verbatim into a \paragraph?

Was wondering how do you do that?

share|improve this question

1 Answer 1

up vote 14 down vote accepted

You need a work-around, since verbatim text is not allowed as arguments to a macro in general. verbdef is one such work-around:

enter image description here

\documentclass{article}
\usepackage{verbdef}% http://ctan.org/pkg/verbdef
\verbdef{\vtext}{verb text}
\begin{document}
\paragraph{Here is some \vtext.}
\end{document}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

Similar functionality is provided by fancyvrb. You could also try cprotect:

\usepackage{cprotect}% http://ctan.org/pkg/cprotect
%...
\cprotect\paragraph{Here is some \verb|verb text|.}
share|improve this answer
    
hmmm... is there another way that I don't have to install the package? I know its rather trivial to install it but just wondering... I'm using MacTex distribution –  chutsu Dec 6 '11 at 18:44
2  
Most of these package should be distributed with MacTeX. Moreover, the provided sources shows how to install the package (under the "Getting it" heading). –  Werner Dec 6 '11 at 18:48
    
Does verbdef support multiline statements? I'm getting Undefined control sequence } iff the second argument of ''\verbdef'' contains a line break. –  Karl Richter Nov 30 at 23:00
    
@KarlRichter: Off the cuff I would say yes. To get around that, you can store the content in a box, as in \newsavebox{\mybox}\begin{lrbox}{\mybox}\begin{verbatim} ... \end{verbatim}\end{lrbox} \usebox{\mybox}. But there are other packages you can use as well, like fancyvrb for example. –  Werner Dec 1 at 5:26

Your Answer

 
discard

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.