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.

Sometimes people here use \verb!A SHORT COMMAND! and sometimes \textt{A SHORT COMMAND}. I'm unsure when to use which.

Are there any guidelines or arguments for \verbatim vs. \texttt?

share|improve this question

2 Answers 2

up vote 55 down vote accepted

The short answer is you use \verb where you need to write a small piece of inline verbatim material that contains characters TeX treats (or rather, is currently treating) as special. \texttt is for when you just want typewriter font.

\verb has some downsides, such as not working in moving arguments. In those cases, you're probably better off using \texttt (or related semantic markup) and performing the appropriate escaping.

share|improve this answer
I'd recommend using \texttt (or, better, a macro with semantic name that uses \texttt) unless you know it won't work for your particular string, such as with \verb|x=1%2|. And even then, using \texttt{1\%2} is probably just as good. –  Will Robertson Sep 6 '10 at 9:04
Another huge downside of \verb I think is it sometimes doesn't work with other environments. I think for instance you can't use \verb in a \section{} environment. –  CommuSoft Mar 12 '12 at 17:40

Sometimes using \verb|...| is better. For example if you copy paste a piece of code like __start: in a \texttt{} environment you might get an error as symbol "_" is not inside a math environment. And then you have to rewrite the code like this: "\texttt{\_\_start}". But why would you do this when you can just use:"\verb|__start|".

share|improve this answer
Notice that \verb{__start} will give tons of errors. I've fixed the delimiters: they should be identical characters that are not among those to typeset verbatim. –  egreg Mar 12 '12 at 17:21

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.