# Macro defining environment

How to write an environment such that

\begin{comment}
Bla, bla.
\end{comment}


produces no output, and instead defines a macro \@comment whose replacement text is everything that is inside the comment environment?

The environ package collects the environment into a macro \BODY, which you can save as whatever macro name you like (note: must be a global definition, since the envrionment is inside a group).

\documentclass{article}
\usepackage{environ}
\makeatletter
\NewEnviron{comment}{
\global\let\@comment\BODY
}
\makeatother
\begin{document}
\begin{comment}
Bla, bla.
\end{comment}
\makeatletter\texttt{\meaning\@comment}\makeatother
\end{document}


• You were two minutes earlier with the same example file. I have added an image and \texttt (the only difference) to match the image of my file. – Heiko Oberdiek Aug 10 '13 at 16:10
• An entertaining coincidence! – Ryan Reich Aug 10 '13 at 16:13
\documentclass{article}
\usepackage{comment}
\usepackage{etoolbox}
\appto\endcomment{replacement text}

\begin{document}

text

\begin{comment}
ignored
\end{comment}

\end{document}