[texhax] making LaTeX-environment from existing command

Alexander Grahn A.Grahn at fzd.de
Thu Aug 16 11:25:17 CEST 2007


Dear list,

I'd like to create a LaTeX environment, using \newenvironment{}{}{},
that stores the commands between \begin and \end into a token register.

The following code fails with the message `! Missing { inserted.' :

--- 8< ---
\documentclass{article}

\newtoks\mytoks
\newenvironment{storetoks}{\global\mytoks}{}

\begin{document}

\begin{storetoks}%
  Hello!%
\end{storetoks}

\the\mytoks %exec token register

\end{document}
--- >8 ---

Unfortunately, I cannot put unbalanced {'s and }'s into the begdef and
enddef parameters of \newenvironment. Perhaps you have got an idea what
to do? There must be a way to accomplish this, since LaTeX defines,
e.g., the `lrbox' environment from the TeX command \setbox which seems
to be a similar task.

Help is greatly appreciated!

Yours,
Alexander


More information about the texhax mailing list