Print

Print


At 21:54 +0100 2000/01/08, Frank Mittelbach wrote:
> > One way to allow hacks like this could be to define \newenvironment as
> >
> >   \newenvironment <name> <begin-code> <end-code> :=
> >     \def\<name>{
> >       \begingroup
> >       <begin-code>
> >     }
> >     \def\end<name>{
> >       <end-code>
> >       \endgroup
> >     }
> >
> > that is, to move the \begingroup, \endgroup from \begin and \end
> > into the \foo, \endfoo commands.
>
>That could be a solution to get the best of both (costing a few tokens per
>defined environment but this is not really an issue)

I have not followed this thread much.

But when I worked on "environments with hooks", I arrived at the conclusion
that the environment definition should be such that the user does not enter
the \begingroup and \endgroup commands explicitly. The reason is that in
order to control the nesting of environments, one needs to have some local
variables, so the group localities must always be present.

Further, in order to allow for proper nesting of environments also in the
environment definition, I had to make use of more local variables than the
current LaTeX. If one writes
  \newenvironment{list}{...}{...}
  \newenvironment{mylist}{...\begin{list}...}{...\end{list}...}
I thus had to keep track of both the ``list'' and ``mylist'' environments
when executing the ``mylist'' environment.

In order to properly accomodate for the use of environment hooks, I had to
make an additional difference with LaTeX: In LaTeX2, the \begingroup (resp
\endgroup) command is executed by the \begin{...} (resp. \end{...})
commands.

I had to change this, so that the \newenviroment{<name>}{...}{...} command
creates commands \<name>/begin containing the \begingroup command and
\<name>/end containing the \endgroup command. The \begingroup (resp
\endgroup) command then executes \<name>/begin (resp. \<name>/end) command.

-- Perhaps this is the change you are looking for.

  Hans Aberg