[OS X TeX] Embedding environment contents in a macro
Michael Jeffries
mj at cds.caltech.edu
Wed Aug 28 14:10:02 EDT 2002
Hi Ross and all,
Thanks for the explanation of why my old attempts were behaving as they
were; reading it was both satisfying and frustrating, the latter since
I'd really prefer it to work than understand why it doesn't. =) I've
tried comment.sty before and hit a dead end, but I'm giving it another
try, and I've hit another dead end.
The problem now is this: I've defined the environment
-------------
\newenvironment{env}{\begin{envcomment}\begin{innerenv}}
{\end{innerenv}\end{envcomment}}
-------------
Beforehand, I've included the comment.sty file and said
\includecomment{envcomment}. When I write in file eca-00-endexer.def the
following:
-------------
\begin{env}
MUCH DATA GOES HERE
\end{env}
-------------
I get
-------------
Runaway argument?
! File ended while scanning use of \next.
<inserted text>
\par
l.602 ...ut{eca-00-endexer.def}
-------------
Here, eca-00-endexer.def is being included in another file. When I write:
-------------
\begin{envcomment} \begin{innerenv}
MUCH DATA GOES HERE
\end{innerenv} \end{envcomment}
-------------
I have the same problem, but the perplexing thing is that when I write
-------------
\begin{envcomment}
\begin{innerenv}
MUCH DATA GOES HERE
\end{innerenv}
\end{envcomment}
-------------
it behaves as I want it to, respecting the \includecomment and
\excludecomment like it should. Isn't white space supposed to be
unimportant in LaTeX in most places? Any ideas on resolving this?
Michael
On Tuesday, August 27, 2002, at 07:09 PM, Ross Moore wrote:
>> 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.
-----------------------------------------------------------------
More information about the MacOSX-TeX
mailing list