Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}

share|improve this question
1  
Use \protect before \verb+@interface+ –  azetina Nov 23 '12 at 3:17
2  
1  
For simple spells like @interfcae I'd just write \subsubsection{The \texttt{@interface} Section}. When the spells have braces({}) in them, just escape them: \{` or \}. –  Marc van Dongen Nov 23 '12 at 4:09
    
Thanks to all for your helping. The type of document that I write is a report; I tried with all methods, but the only one that works for me is the \texttt{}, although I use the cprotectand fancyvrb packages. –  Isai Nov 23 '12 at 4:13

2 Answers 2

up vote 10 down vote accepted

Use the cprotect package:

\usepackage{cprotect}% http://ctan.org/pkg/cprotect
...
\cprotect\subsubsection{The \verb+@interface+ Section}

However, consider reading through the informative UK 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.

share|improve this answer

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}

enter image description here

share|improve this answer
1  
While this works, it still doesn't allow for adding special characters in the argument to \Verb, so the simpler \texttt might be better. –  egreg Nov 24 '12 at 10:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.