# Error due to environment start and end in non-active mode

I am making a beamer presentation with a beamerarticle counterpart. On the article version, I want to display some parts side by side, so I created minipages in <article> mode that should not affect the <presentation> mode.

However, while the article compiles nicely, the presentation yields an error.

Here I stripped it all to a MWE, with a dummy environment instead of minipage :

\documentclass{beamer}
\newenvironment{machin}{begdef}{enddef}
\begin{document}
\begin{frame}
\begin{exampleblock}{Exemples}
\mode
<article>
\begin{machin}
whatever
\mode
<all>
blabla
\mode
<article>
whatever
\end{machin}
\mode
<all>
\end{exampleblock}
\end{frame}
\end{document}


Compiling this leads to Extra }, or forgotten \endgroup. \end{frame} at line 20.

Compiling this with the machin environments commented out is fine.

Compiling this, including the machin environments, with class scrartcl and package beamerarticle also works.

I am at a loss because in presentation mode, the lines about the machin environment should have been gobbled out and not executed.

Does somebody have a clue ?

In my actual file, the text is more complicated so I would like to avoid duplicating the whole thing for presentation/article.

• I would say it is a variant of the bug you already reported: github.com/josephwright/beamer/issues/543 – Ulrike Fischer Sep 18 '19 at 21:16
• Ah ! I had not thought that one would come back in disguise to bite me again ! I will add this to the report there and try to remember how I worked around the previous incarnation. – ysalmon Sep 19 '19 at 7:10