add code macro usable inside other environments

This commit is contained in:
Maximilian Keßler 2022-02-10 01:13:34 +01:00
parent 394ecc310c
commit 371ce76a81

View file

@ -7,15 +7,18 @@ __NEW_IF__(pipe,false)
\catcode`_=13
\let_\_
\catcode`_=8
\newcommand\code{
\begingroup
\catcode`_=\active
\code@impl
\ExplSyntaxOn
\NewDocumentCommand{\code}{m}
{
\tl_set_rescan:Nnn \l_tmpa_tl
{
\char_set_catcode_active:N _
}
\newcommand\code@impl[1]{
\texttt{#1}
\endgroup
{ #1 }
\texttt{ \tl_use:N \l_tmpa_tl }
}
\ExplSyntaxOff
\newif\ifactive\activefalse
__IF__(pipe)