[texhax] aliasing document environment

Heiko Oberdiek heiko.oberdiek at googlemail.com
Fri Feb 25 05:12:54 CET 2011

On Thu, Feb 24, 2011 at 10:35:46PM -0500, Moshe Kamensky wrote:

> When I try to latex the following:
> \documentclass{article}
> \newenvironment{foo}{\begin{document}}{\end{document}}
> \begin{foo}
> \end{foo}
> I get:
> LaTeX Error: \begin{foo} on input line 3 ended by \end{document}.
> Why is that?

The environment `document' uses some trickery to remove the
grouping level introduced by the \begin and \end.
(Memory reasons, save stack, ...)

> Is there a way to do this without errors?


Yours sincerely
  Heiko Oberdiek

More information about the texhax mailing list