Le 22/05/2013 17:28, Sensei a �crit :
>
> That's awesome, thanks! I didn't (obviously) know of \AtEndDocument!
>
> By the way, if document isn't an environment (but behaves and looks like
> one), what is then, technically?
Roughly speaking, an environment is the LaTeX concept for
TeX : \begingroup ... \endgroup so that :
\begin{envir} ... \end{envir} is pseudo-equivalent to:
\begingroup \envir ... \endenvir \endgroup
While \begin{document} ... \end{document} is pseudo-equivalent to :
\document ... \enddocument
so that \begin{document} is the command : \document
and \end{document} is the command : \enddocument
and finally {document} is not an environment, even if
it mimicks the syntax... I'm almost sure this is the only
exception (even if the grouping may be more complex in some
environment, for example {lrbox}).
Regards.