# [OS X TeX] Embedding environment contents in a macro

Michael Jeffries mj at cds.caltech.edu
Tue Aug 27 19:52:53 EDT 2002


Hi,

I'm told this is a great place to write and ask questions. I'd like to
define an environment, say env, that wraps its contents inside a macro.
Something like:
---------
\newenvironment{env}{\macroname \bgroup \begin{ anotherenv } }
{ \end{anotherenv} \egroup}
---------
so that \begin{env} MANY PARAGRAPHS OF INFO \end{env{}  is the same as
\macroname{MANY PARAGRAPHS OF INFO}.

When I do this, I get
---------
! Extra }, or forgotten \endgroup.
\env ->\end {anotherenv}\egroup

l.39 \end{env}
---------
I tried prefixing the \bgroup with \protect on hopes it might work, but
that seemed only to stop the effect of the macro. Any ideas or help on
how I can do this? I have a similar set up where anotherenv is defined
by newtheorem instead of newenvironment, and that works, but I don't see

The end goal is to have the macro display its contents if a flag is set,
or to execute other code if the flag is not set. If there is a better
way to do this, please let me know.

Thanks.

Michael

-----------------------------------------------------------------
Threaded list archives can be found at:
<http://www.masda.vxu.se/~pku/MacOSX_TeX/>
-----------------------------------------------------------------
To UNSUBSCRIBE, send email to <info at email.esm.psu.edu> with
"unsubscribe macosx-tex" (no quotes) in the body.
For additional HELP, send email to <info at email.esm.psu.edu> with
"help" (no quotes) in the body.
-----------------------------------------------------------------