# verbatim text inside italic block

I am trying the following:

\begin{frame}[fragile]{OCP en Exceptions}
If you throw a checked exception from a method in your code and the
\verb!catch! is three levels above, \textit{you must declare that
exception in the signature of each method between you and
the \verb!catch!}''
\end{frame}


Somehow I can't use the verbatim text inside the italic block. How do I solve this the right way?

You can't use verbatim material inside another macros argument. The already mentioned cprotect package works around that, but I would call it overkill using it here. Simply use a font declaration inside a group instead of a font macro, i.e. {\itshape text \verb+$%^+ text} instead of \textit{text \verb+$%^+ text}.

\begin{frame}[fragile]{OCP en Exceptions}
If you throw a checked exception from a method in your code and the
\verb!catch! is three levels above, {\itshape you must declare that
exception in the signature of each method between you and
the \verb!catch!}''
\end{frame}


Also using verbatim only to get the font effect is a misuse. Simply use tt font directly! For often used real verbatim material I would recommend to define them as macros using \verbdef of the verbdef package. (There is also \Verbdef of my newverbs package if you need it in an expandable form, but normally this is not the case.)

Use cprotect package. More details, see the manual.

\documentclass{article}
\usepackage{cprotect}
\begin{document}
\cprotect\textit{\verb|\LaTeX| is one of my primary weapons}
\end{document}