To avoid unnecessary effort, please note that I'm asking specifically about the error's cause, as opposed to how to avoid it. Furthermore, I'm aware that \NewDocumentEnvironment
now offers the b
option.
Consider the following MNWE,
\documentclass[]{article}
\usepackage{newenviron}
\begin{document}
hylo
\end{document}
This fails to compile, claiming there's an extra \endgroup
, so that \document
ends with \endgroup
.
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./prawf.tex
LaTeX2e <2023-06-01> patch level 1
L3 programming layer <2023-10-10>
(/usr/local/texlive/2023/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/usr/local/texlive/2023/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2023/texmf-dist/tex/latex/newenviron/newenviron.sty
(/usr/local/texlive/2023/texmf-dist/tex/latex/catoptions/catoptions.sty))
! Extra \endgroup.
\document ->\endgroup
\let \BeforeStartOfDocument \@firstofone \cpt@beforest...
l.199 \begin{document}
?
What causes this error exactly?
newenviron
(opposing to theenviron
package) loadscatoptions
.catoptions
in turn redefines many of LaTeX's internals. Some few years ago changes in the LaTeX kernel finally lead tocatoptions
being incompatible with it in such a way that it actually breaks with an error. Previouslycatoptions
did break LaTeX, but silently... Search this site, there are a few questions regardingcatoptions
.catoptions
breaking stuff (before it became incompatible): tex.stackexchange.com/questions/461783/…newenviron
was to allow nested calls of environments defined with\newenviron
, in order to avoid some shortcomings ofenviron
which only used\BODY
. The idea was nice, but Bruno's implementation of theb
argument type for\NewDocumentEnvironment
is much better (and doesn't break LaTeX).