[OS X TeX] Embedding environment contents in a macro
Ross Moore
ross at ics.mq.edu.au
Tue Aug 27 22:09:18 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}
This approach cannot work, since the \egroup to match the \bgroup
would never be seen -- it is wrapped-up inside the \end{env}
and there is nothing to cause this to be expanded while trying to
match the argument to the \macroname .
In fact what happens here is that the \bgroup token becomes
the argument to \macroname and the {anotherenv} environment
will *always* be processed ...
> ---------
> 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}
... so that the closing \egroup is totally redundant, not matching
anything at all.
> how I can do this? I have a similar set up where anotherenv is defined
Have you tried comment.sty ?
> by newtheorem instead of newenvironment, and that works, but I don't see
> how that's helpful.
Hmm; that may be a bit harder to achieve.
> 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.
Have a look at the comment.sty package.
Your *flag* can be implemented as \includecomment and/or \excludecomment
calls, with the appropriate environment names.
Hope this helps,
Ross Moore
> 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.
> -----------------------------------------------------------------
-----------------------------------------------------------------
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.
-----------------------------------------------------------------
More information about the MacOSX-TeX
mailing list