I have a question about a Verbatim, I want to write a word inside of the subsubsection title. I got an error. How can I fix it?: \subsubsection{The \verb+@interface+ Section}
Asked
Active
Viewed 1.6k times
2 Answers
23
Use the cprotect package:
\usepackage{cprotect}% http://ctan.org/pkg/cprotect
...
\cprotect\subsubsection{The \verb+@interface+ Section}
However, consider reading through the informative TeX FAQ entry: Why doesn’t verbatim work within …? In particular, other alternatives like \texttt{...} also exist and are far more manageable. Even in your case, using
\subsubsection{The \texttt{@interface} Section}
works as-is.
barbara beeton
- 88,848
Werner
- 603,163
-
Tip: if the command contains non-letter characters, enclose it inside curly braces, e.g.,
\cprotect{\section*}{\verb"@ interface"}. – Eli4ph Apr 14 '22 at 08:55
15
The standard \verb command cannot be used in the argument of other commands. You can use \Verb from the fancyvrb package:
\documentclass{article}
\usepackage{fancyvrb}
\begin{document}
\subsubsection{The \protect\Verb+@interface+ Section}
\end{document}

Gonzalo Medina
- 505,128
-
2While this works, it still doesn't allow for adding special characters in the argument to
\Verb, so the simpler\textttmight be better. – egreg Nov 24 '12 at 10:48 -
There's also
\lstinlinewhich does allow adding special characters, but in an inconvenient syntax. (mentioned in https://tex.stackexchange.com/a/152412/250119 ) – user202729 Mar 30 '22 at 13:46
\protectbefore\verb+@interface+– azetina Nov 23 '12 at 03:17\verbcommand inside of\textbf{}block? – Werner Nov 23 '12 at 03:21@interfcaeI'd just write\subsubsection{The \texttt{@interface} Section}. When the spells have braces({}) in them, just escape them:{or}`. – Nov 23 '12 at 04:09\texttt{}, although I use thecprotectandfancyvrbpackages. – Isai Nov 23 '12 at 04:13