In xparse
I want to define a command Command-One which calls a command Command-Two and calls the *ed version if and only if the *ed version of Command-One was called.
Specifically I would like to do something like:
\DeclareDocumentCommand{\CTwo}{s o m}
{\IfBooleanTF{#1}{#2}{#3}}
\DeclareDocumentCommand{\CTest}{s o}
{\CTwo#1[#2]{testing}}
\CTest*[work]
and have it output "work".
I realize I can do this with
\DeclareDocumentCommand{\CTest}{s o}
{\IfBooleanTF{#1}
{\CTwo*[#2]{testing}}
{\CTwo[#2]{testing}}}
but this is inelegant, plus I will be defining several distinct commands each with a different value of #3
in \CTwo
and it will get repetitive having to always copy If-Then statement multiple times (as well as having to copy the specific argument twice)
Here is a more detailed example using environments. Specifically I would like to be able to define an environment template which I can then use to define several different environments by simply passing it parameters.
\documentclass{amsart}
\usepackage{amsthm}
\usepackage{xparse, l3fp,l3tl}
\begin{document}
\ExplSyntaxOn
\def\TheoremDepth{section}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[\TheoremDepth]%
\newtheorem*{theoremstar}{Theorem}%
\DeclareDocumentEnvironment{TheoremTemplate}{s o m m}
{
\IfBooleanTF{#1}
{ Do something
\begin{#1}}
{ Do something else
\begin{#2} }
}
{
\IfBooleanTF{#1}
{ Do something
\end{#1}}
{ Do something else
\end{#2} }
}
\DeclareDocumentEnvironment{MyTheorem}{s o}
{
\begin{TheoremTemplate}#1[#2]{theorem}{theoremstar}
}
{
\end{TheoremTemplate}
}
\ExplSyntaxOff
\end{document}
I would then like to be able to call both \begin{theorem} and \begin{theorem}* and have them do the corresponding things.
o
argument, don't you?xparse
doesn't naturally fit what you're trying to do is a good indication that perhaps a re-think is required. I don't think we can provide a good answer without more detail given in the question (e.g., what\CTwo
is supposed to be doing).\documentclass
and ending with\end{document}
. That way (without any effort) you simplify our work