2

Using the verbatim environment inside an \enumsentence fails.

Here is a MWE:

\documentclass{article}
\usepackage{lingmacros}
\begin{document}
\enumsentence{
\begin{verbatim}
foo
\end{verbatim}
}
\end{document}

I can do a workaround using \texttt{ }, but then I have to escape a bunch of funny characters and in general I'd prefer verbatim for this.

Any suggestions?

Alan Munn
  • 218,180
  • What are the characters you have to escape? Can you make a "real life" example? – egreg Dec 08 '12 at 10:02
  • in this example, i was working with many underscores, I had used vim s//\/g and s/$/\\/ to put the underscores and explicit line breaks throughout. But I was hoping for a more elegant solution. \cprotect seems to work without issue for this. – apexofservice Dec 08 '12 at 21:18
  • Do you need typewriter type? Other special characters? – egreg Dec 08 '12 at 21:24

1 Answers1

3

Use the package cprotect. Here is the updated code:

\documentclass{article}
\usepackage{lingmacros}
\usepackage{cprotect}
\begin{document}
\cprotect\enumsentence{
\begin{verbatim}
foo
\end{verbatim}
}
\end{document}

FYI, here is where I found the answer to your question.

Vivi
  • 26,953
  • 31
  • 77
  • 79