[NTG-context] Environments

Hans Aberg haberg-1 at telia.com
Tue Jul 7 14:57:43 CEST 2015


> On 7 Jul 2015, at 11:05, luigi scarso <luigi.scarso at gmail.com> wrote:

> For  "LaTeX style environments" do you mean
> e.g.
> https://it.sharelatex.com/learn/Environments
> ?  (just to be sure )

Yes, the \begin{foo} … \end{foo} syntax. Technically, an environment means that variables are stacked in a syntactically local group, as in \begingroup … \endgroup.

The syntax in the example file is «foo· … ·» or «foo· … ·foo», so one does not have to write the ‘start' and ‘stop’ all the time, and does not have to write the name of the environment again at the end.

> In this case  context has the \define<something> commands as for example
> http://wiki.contextgarden.net/Command/definetyping

I think this corresponds (in pseudocode) to my
\new{Environment}{typing}%
  {}{<before code>}%
  {<after code>}{}

In LaTeX, if I remember correctly, it would expand to \begingroup<before code> … <after code>\endgroup.

I added so one can have 
\new{Environment}{typing}%
  {<before code>}{<begin code>}%
  {<end code>}{<after code>}
expanding to
  <before code>\begingroup<begin code> … <end code>\endgroup<after code>

So one has more control over designing the environment. One can then also define a new environment
\new{Environment}{typingmore}%
  {<code>}{<code>«typing·<args>}%
  {·typing»<code>}{<code>}
I think, to make specializations.

> Context has also 
> http://wiki.contextgarden.net/Command/startenvironment
> but I suppose it's not what you mean.

It looks like just adding a series of command names, rather than a stacked environment, or a namespace (module). If one wants to avoid name clashes, one can have names like in directory names, living without any local group.




More information about the ntg-context mailing list