The packages environ
and newenviron
both provide an alternative to the standard environment macros included with LaTeX. The main difference is that they make it possible to refer to the environment body using a macro, but another difference is that macro expansion is affected as can be seen by (un)commenting the relevant lines in the following document:
\documentclass{article}
\usepackage{environ}
\usepackage{newenviron}
\def\speakify#1: #2\par{{\bfseries#1}: {\itshape``#2\unskip''}\par}
\newenvironment{interview}{\everypar{\speakify}}{\par}
%\NewEnviron{interview}{\everypar{\speakify}\BODY\par}
%\newenviron{interview}{}{\everypar{\speakify}\envbody\par}
\begin{document}
\begin{interview}
I: I have a question for you that I would really like to know the answer to. Could you please explain it in your own words while the moon is still high in the sky? That would be lovely thank you very much!
L: Of course I will answer gladly all questions you might have no matter how silly I feel they may be provided payment is made in full before commencement of the answering phase.
\end{interview}
\end{document}
What exactly is the change in macro expansion that occurs?
environ
is that you can access the content of an environment with the command \BODY. Standard environments do not have such a facility. – Arash Esbati Jul 8 '15 at 12:19NewDocumentEnvironment
fromxparse
package is, that the arguments can be accessed in theend code
section as well, which is not possible for the standard\newenvironment
– user31729 Jul 8 '15 at 18:08newenviron
previously but I am a big fan of\NewDocumentEnvironment
from xparse and\NewEnviron
from environ. The former gives much more control over the arguments to the environment and the latter makes it possible to work with the body of the environment. – user30471 Jul 9 '15 at 14:13environ
ornewenviron
codes just grab the environment's contents. You don't need them in this application. – egreg Jul 10 '15 at 9:56