There was a need to create an environment that uses a different environment inside. I can implement this, for example, like this:
\newenvironment{new}{ \begin{old} }{ \end{old} }
And everything works fine until old
becomes document
. In this case, the code stops working:
! LaTeX Error: \begin{Document} on input line 2 ended by \end{document}
Why does the above code work fine in the case of non-document
, but not in the case of document
?
P.S. I will also give a solution that was found on the vastness of this site:
\newenvironment{Document}{}{}
\AddToHook{env/Document/before}{ \begin{document} }
\AddToHook{env/Document/after}{ \end{document} }