I want to use verbatim in a caption of a figure. I have tried the cprotect package but it seems to work only with \caption and not with \captionof. Is there a workaround?
\documentclass{scrbook}
\usepackage[ngerman]{babel}
\usepackage[latin1]{inputenc}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{capt-of}
\begin{document}
\verb|works|
\afterpage{%
\begin{landscape}
\parbox[c][\textwidth][s]{\linewidth}{%
\vfill
\centering
\mbox{+++++++ a huge figure ++++++++}
\captionof{figure}{Syntaxbaum \verb|doesn't works|}
\vfill
}
\end{landscape}
}
\end{document}

\texttt{doesn't works}would do the trick? – John Wickerson Jun 05 '13 at 12:08\verbis useful for material that includes TeX's special characters; if it's not the case, use\textttand the result will be what's needed. – egreg Jun 05 '13 at 12:28\cprotectas mentioned in its documentation, or use mycprotectinsidepackage (although the question is closed, and the target question can already be easily solved withcprotect) – user202729 Jun 26 '22 at 12:51