[texhax] environment from command

Philip Taylor (Webmaster, Ret'd) P.Taylor at Rhul.Ac.Uk
Sat Nov 20 16:02:12 CET 2010



Barbara Sánta wrote:
> very sorry if I was unundrestandable, you are right, the first and
> third argument is not necessary.
> So transform a \command{arg} into a
> \begin{env}
>     arg
> \end{env}
> with defining env environment. My problem was that I could not find a
>    \newenvironment{env}{\command ?beginning a block? }{ ?end of the block? }
> solution, where ? signs my problem. But Heiko Oberdiek gave a perfect
> solution with a package.

OK, many thanks Barbara : your problem is now a lot clearer.

So in general what can be identified is that it not possible
to treat "arg" as a parameter to \command, as otherwise
catcode changes could not occur in setting up {environment}.
However, for the limits of "arg" to be known, it must be
set off by braces.  So the first thing that comes to mind
is :

	\def \command #{whatever}

where the trailing # indicates that \command must be followed
by an open brace (which will later be closed), and \command
takes no parameters so no catcode staticisation has yet
taken place.  \command can therefore be programmed to emit
"\begin {environment} :

	\def \command #{\begin {environment}}

The problem is how to insert the \end {environment} once
the closing brace is found.  As Fermat might have said
"I have a really ingenious solution, but this message is
too small to contain it".  In reality, I have to prepare
for guests and don't have time to add the final pieces;
more later, perhaps !

** Phil.


More information about the texhax mailing list