Closed dbitouze closed 1 year ago
You can use the same approach as with using \makeatletter ... \makeatother
in frames: define some wrapper macro outside of the frame environment and then use the wrapper inside the frame.
\documentclass{beamer}
\begin{document}
\ExplSyntaxOn
\newcommand{\foo}{
\tl_set:Nn \l_tmpa_tl { Foo }
\tl_use:N \l_tmpa_tl
}
\ExplSyntaxOff
\begin{frame}
\foo
\end{frame}
\end{document}
I didn't notice the same issue arises with \makeatletter
/\makeatother
: good to know, thanks!
And, sorry, I should have said that I knew there are such workarounds but if many wrapper macros have to be defined, it becomes tedious.
What is so specific to the frame
environment that is responsible of these issues?
What is so specific to the
frame
environment that is responsible of these issues?
I don't know for the expl case, but for \makeatletter ... \makeatother
the problem is catcodes, see https://tex.stackexchange.com/questions/161174/makeatletter-within-a-beamer-frame-how#comment368752_161174
don't know for the expl case, but for \makeatletter ... \makeatother the problem is catcodes,
expl3 is same just with_
and :
rather than @
What is so specific to the frame environment
It is evaluated multiple times so grabbed as a macro argument so \verb
fails as do all related catcode changes (sometimes fixable with [fragile]
which grabs the body in a more catcode tolerant way).
Using \ExplSyntaxOn
mid document is always somewhat suspicious abuse of the intended layering: expl3 is intended for low level code in which class/package layer commands can define document level functions. So @samcarter's solution should be prefered even though this works without error
\documentclass{beamer}
\begin{document}
\begin{frame}[fragile]
\ExplSyntaxOn
\tl_set:Nn \l_tmpa_tl { Foo }
\tl_use:N \l_tmpa_tl
\ExplSyntaxOff
\end{frame}
\end{document}
Context
beamer
2022/09/13 v3.68Issue
In the document body of a
beamer
file,\ExplSyntaxOn
/\ExplSyntaxOff
:Indeed, the following MCE:
compiles like a charm except if the
frame
environment is uncommented, the error message being: