I would like to include verbatim in a caption of a figure. I only want part of it to be verbatim, not the entire caption. The simple approach does not work because verbatim is not allowed in arguments of other commands, as this answer explains. I tried using \SaveVerb
and \UseVerb
, but this does not work either. Is there a way to achieve this?
The code I used was the following:
\SaveVerb{term}|test|
\begin{figure}
\caption{This is a \UseVerb{term}.}
\end{figure}
This did not compile (I will update the error message when I get home, don't have access to it right now). However, I already fixed this, as I explain in my own answer to this question.
\SaveVerb
definitely works here. What exact code are you using and what error are you getting?