Consider the following:
\documentclass{article}
\usepackage{environ}
\usepackage{verbatim}
\usepackage{color}
\NewEnviron{vred}{%
\color{red}
\begin{verbatim}
\BODY
\end{verbatim}
}
\begin{document}
\begin{vred}
test
\end{vred}
\end{document}
Compiling with pdflatex
gives the error:
Runaway argument?
\end {document}
! Paragraph ended before \next was complete.
<to be read again>
\par
l.16
Best Answer
In this particular case the problem is a typical one: You can't pass
verbatim
content as an argument to another macro. This is indeed the case with usingenviron
, since content is accumulated in the macro\BODY
for processing later.From the looks of your minimal example, it seems like you're after printing
verbatim
content using a specific colour (say red). For this I'd suggest defining a new verbatim environment with this specific quality/attribute. As such,fancyvrb
can come in handy. Here's a MWE that illustrates this concept (taken, virtually verbatim, from thefancyvrb
documentation (section 4.1.3 Customization of formatting, p 5 and 4.2.4 Personalized environments, p 18)):