I'd like to programmatically create a new \NewDocumentEnvironment environment to create new environments using a simple command (a bit like how one can use\newtheorem to create a new kind of environment).
However, I'm not sure how to do that. Should I use some sort of expandafter, \csname...?
MWE
\documentclass[]{article}
\usepackage{xparse}
%% Environment generic but too verbose to use. (I need the +b)
\NewDocumentEnvironment{myenv}{O{}m+b}{
Foo (#1) Bar (#2) Baz (#3) Bise}{}
%% Create a command to create new environment to fix the options of the verbose env.
\NewDocumentCommand\newEnv{O{}mm}{
\NewDocumentEnvironment{#1}{O{}+b}{
\begin{myenv}[##1]{#2}
##3
\end{myenv}
}{}
}
%% Use it to create a new environment
\newEnv[dolphin]{myDolpinEnv}{I am a dolphin.}
\begin{document}
\begin{myenv}[I'm optional]{I'm mandatory}
I'm inside.
\end{myenv}
\begin{myDolpinEnv}[blue dolphin]
Psiooouu!
\end{myDolpinEnv}
\end{document}
+b? Unfortunately, I can't find any solution to avoid them in my use case https://github.com/leo-colisson/proof-at-the-end, and this issue seems quite fundamental (I remember helping someone having similar issues with verb and maybe theanswerspackage`, and the only solution we had we to use typeset verb content outside inside some sort of box and move the box back inside the answer later) . – tobiasBora Jan 28 '22 at 13:25\NewDocumentEnvironment{#1}{O{}+}{ \myenv[##1]{#2} }{ \endmyenv }– user202729 Jan 28 '22 at 13:58