[Tex/LaTex] When should one use \verb and when \texttt


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?

Best Answer

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.