* Collecting command arguments in a startstop environment
@ 2004-08-02 5:39 Brooks Moses
2004-08-02 8:37 ` Patrick Gundlach
2004-08-02 17:43 ` Brooks Moses
0 siblings, 2 replies; 5+ messages in thread
From: Brooks Moses @ 2004-08-02 5:39 UTC (permalink / raw)
There's a nice little problem that arises in LaTeX, of wanting to write a
bit of code like the following, to define an environment that passes the
contents of the environment to a command as an argument:
\newcommand{\foo}[1]{...}
\newenvironment{fooenv}{%
\foo\bgroup
}{%
\egroup
}
There's even a nice FAQ entry about this. [1] As it turns out, the amsmath
package defines a handy \collect@body command that handles collecting the
environment body to pass it to a command.
Anyhow, I'm finding myself wanting to do this in ConTeXt, with of course
replacing \newenvironment with \definestartstop. Is there by any chance a
built-in ConTeXt macro that can do this? Or even things that would make a
decent foundation for building such a thing?
Thanks much,
- Brooks
[1] http://www.tex.ac.uk/cgi-bin/texfaq2html?label=cmdasenv
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Collecting command arguments in a startstop environment
2004-08-02 5:39 Collecting command arguments in a startstop environment Brooks Moses
@ 2004-08-02 8:37 ` Patrick Gundlach
2004-08-02 8:46 ` Brooks Moses
2004-08-02 17:43 ` Brooks Moses
1 sibling, 1 reply; 5+ messages in thread
From: Patrick Gundlach @ 2004-08-02 8:37 UTC (permalink / raw)
[...]
> Anyhow, I'm finding myself wanting to do this in ConTeXt, with of
> course replacing \newenvironment with \definestartstop.
I didn't want to fiddle with \definestartstop, but here is a quick
hack:
--------------------------------------------------
\long\def\foo#1{ Hello #1!}
\long\def\startfoo #1 \stopfoo{\unskip \foo{#1}}
\starttext
\startfoo
World
\stopfoo
\startfoo
Brooks
\stopfoo
\startfoo
some
lines
\stopfoo
\stoptext
--------------------------------------------------
Patrick
--
ConTeXt wiki: http://contextgarden.net
texshow-web: http://texshow.contextgarden.net
List archive: http://archive.contextgarden.net
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Re: Collecting command arguments in a startstop environment
2004-08-02 8:37 ` Patrick Gundlach
@ 2004-08-02 8:46 ` Brooks Moses
0 siblings, 0 replies; 5+ messages in thread
From: Brooks Moses @ 2004-08-02 8:46 UTC (permalink / raw)
At 01:37 AM 8/2/2004, you wrote:
> > Anyhow, I'm finding myself wanting to do this in ConTeXt, with of
> > course replacing \newenvironment with \definestartstop.
>
>I didn't want to fiddle with \definestartstop, but here is a quick
>hack:
>
>--------------------------------------------------
>\long\def\foo#1{ Hello #1!}
>\long\def\startfoo #1 \stopfoo{\unskip \foo{#1}}
[...]
Oh, that's clever. I'll have to ponder at whether it's got some drawbacks
that mean it doesn't work for what I need, but it does seem promising. Thanks!
- Brooks
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Collecting command arguments in a startstop environment
2004-08-02 5:39 Collecting command arguments in a startstop environment Brooks Moses
2004-08-02 8:37 ` Patrick Gundlach
@ 2004-08-02 17:43 ` Brooks Moses
2004-08-02 20:14 ` Hans Hagen Outside
1 sibling, 1 reply; 5+ messages in thread
From: Brooks Moses @ 2004-08-02 17:43 UTC (permalink / raw)
To answer my own question:
At 10:39 PM 8/1/2004, I wrote:
>There's a nice little problem that arises in LaTeX, of wanting to write a
>bit of code like the following, to define an environment that passes the
>contents of the environment to a command as an argument:
>
> \newcommand{\foo}[1]{...}
> \newenvironment{fooenv}{%
> \foo\bgroup
> }{%
> \egroup
> }
>
>There's even a nice FAQ entry about this. [1] As it turns out, the
>amsmath package defines a handy \collect@body command that handles
>collecting the environment body to pass it to a command.
>
>Anyhow, I'm finding myself wanting to do this in ConTeXt, with of course
>replacing \newenvironment with \definestartstop. Is there by any chance a
>built-in ConTeXt macro that can do this? Or even things that would make a
>decent foundation for building such a thing?
The \grabuntil and \processbetween commands, as defined in syst-ext.tex, do
exactly what I'm asking for.
- Brooks
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Collecting command arguments in a startstop environment
2004-08-02 17:43 ` Brooks Moses
@ 2004-08-02 20:14 ` Hans Hagen Outside
0 siblings, 0 replies; 5+ messages in thread
From: Hans Hagen Outside @ 2004-08-02 20:14 UTC (permalink / raw)
Brooks Moses wrote:
> To answer my own question:
>
> At 10:39 PM 8/1/2004, I wrote:
>
>> There's a nice little problem that arises in LaTeX, of wanting to
>> write a bit of code like the following, to define an environment that
>> passes the contents of the environment to a command as an argument:
>>
>> \newcommand{\foo}[1]{...}
>> \newenvironment{fooenv}{%
>> \foo\bgroup
>> }{%
>> \egroup
>> }
>>
>> There's even a nice FAQ entry about this. [1] As it turns out, the
>> amsmath package defines a handy \collect@body command that handles
>> collecting the environment body to pass it to a command.
>>
>> Anyhow, I'm finding myself wanting to do this in ConTeXt, with of
>> course replacing \newenvironment with \definestartstop. Is there by
>> any chance a built-in ConTeXt macro that can do this? Or even things
>> that would make a decent foundation for building such a thing?
>
>
> The \grabuntil and \processbetween commands, as defined in
> syst-ext.tex, do exactly what I'm asking for.
If you want to play with low level features, it makes sense to look into:
syst-gen.tex
syst-ext.tex
(syst-new.tex)
supp-box.tex
supp-fun.tex
the interfaces of syst/supp modules are sort of 'public' and stable. These modules may also teach some tex tricks -)
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-08-02 20:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-02 5:39 Collecting command arguments in a startstop environment Brooks Moses
2004-08-02 8:37 ` Patrick Gundlach
2004-08-02 8:46 ` Brooks Moses
2004-08-02 17:43 ` Brooks Moses
2004-08-02 20:14 ` Hans Hagen Outside
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).