[Tex/LaTex] Emphasize inline verbatim text (with \verb or equivalent)

verbatim

How can I emphasize inline verbatim text? \emph{\verb|$Text|} creates an error. Nothing else I tried works either, e.g. \Verb. Is there any easy way to do this? I would need all kinds of special latex characters in the verbatim text (which contains program code fragments), not only "$".

Of course one can do \emph{\$Text}. But having to escape every single special character takes a lot of time and changes the highlighted program code fragment in the latex source file, which is not desirable.

Best Answer

Use fancyvrb:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{fancyvrb}

\begin{document}

\Verb|$Text$|

\Verb[fontshape=it]|$Text|

\end{document}

enter image description here