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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
    
What are the characters you have to escape? Can you make a "real life" example? – egreg Dec 8 '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 8 '12 at 21:18
    
Do you need typewriter type? Other special characters? – egreg Dec 8 '12 at 21:24
up vote 2 down vote accepted

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.

share|improve this answer
    
thanks, \cprotect works! – apexofservice Dec 8 '12 at 21:16

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.