summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-10-12 20:05:28 +0000
committerKarl Berry <karl@freefriends.org>2021-10-12 20:05:28 +0000
commitd13d9685115e059e52709bb5583d7a6e9031942d (patch)
tree7149f1f621cff1634b215bdbcd7d9f40ba51c32e /Master
parentf40b599d8fd00f859b7a44c7e4e0e177d51afa81 (diff)
cdcmd (12oct21)
git-svn-id: svn://tug.org/texlive/trunk@60742 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/cdcmd/README.md33
-rw-r--r--Master/texmf-dist/doc/latex/cdcmd/cdcmd-cn.pdfbin0 -> 79667 bytes
-rw-r--r--Master/texmf-dist/doc/latex/cdcmd/cdcmd-cn.tex175
-rw-r--r--Master/texmf-dist/doc/latex/cdcmd/cdcmd-test.tex161
-rw-r--r--Master/texmf-dist/doc/latex/cdcmd/cdcmd.pdfbin0 -> 530775 bytes
-rw-r--r--Master/texmf-dist/source/latex/cdcmd/cdcmd.dtx1053
-rw-r--r--Master/texmf-dist/source/latex/cdcmd/cdcmd.ins73
-rw-r--r--Master/texmf-dist/tex/latex/cdcmd/cdcmd.sty571
-rwxr-xr-xMaster/tlpkg/bin/tlpkg-ctan-check2
-rwxr-xr-xMaster/tlpkg/libexec/ctan2tds1
-rw-r--r--Master/tlpkg/tlpsrc/cdcmd.tlpsrc0
-rw-r--r--Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc1
12 files changed, 2069 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/cdcmd/README.md b/Master/texmf-dist/doc/latex/cdcmd/README.md
new file mode 100644
index 00000000000..8c4f7028e59
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/cdcmd/README.md
@@ -0,0 +1,33 @@
+Abstract
+----
+The `cdcmd` package provides some conditional command, just like `styledcmd`
+package. The difference is `cdcmd` can define expandable command.
+
+See `cdcmd.pdf` (in English) or `cdcmd-cn.pdf` (in Chinese) for more details.
+
+Contributing
+----
+[Issues](https://github.com/Sophanatprime/cdcmd/issues) and
+[pull requests](https://github.com/Sophanatprime/cdcmd/pulls)
+are always welcome.
+
+Copyright and license
+----
+Copyright (C) 2021--2021
+Wenjian Chern (Longaster) and any individual authors listed elsewhere in this file.
+--------------------------------------------------------------------------
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either
+version 1.3c of this license or (at your option) any later
+version. This version of this license is in
+ http://www.latex-project.org/lppl/lppl-1-3c.txt
+and the latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3 or later is part of all distributions of
+LaTeX version 2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained`.
+
+The Current Maintainers of this work are Wenjian Chern (Longaster).
+--------------------------------------------------------------------------
diff --git a/Master/texmf-dist/doc/latex/cdcmd/cdcmd-cn.pdf b/Master/texmf-dist/doc/latex/cdcmd/cdcmd-cn.pdf
new file mode 100644
index 00000000000..c99eb26d0c7
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/cdcmd/cdcmd-cn.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/cdcmd/cdcmd-cn.tex b/Master/texmf-dist/doc/latex/cdcmd/cdcmd-cn.tex
new file mode 100644
index 00000000000..09be66042cd
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/cdcmd/cdcmd-cn.tex
@@ -0,0 +1,175 @@
+\documentclass{ctxdoc}
+\usepackage{xcolor}
+\usepackage{cdcmd}
+\title{\pkg{cdcmd},一跟可扩展的条件化命令宏包}
+\author{雾月, Longaster\thanks{Email: \url{longaster@163.com}}}
+\date{\today v1.0}
+
+
+\begin{document}
+\maketitle
+
+\pkg{cdcmd} 提供了条件化命令的方式,与 \pkg{styledcmd} 宏包不同,该宏包的某些命令是可 \verb|f-|扩展的,这在某些情况下是有用的。
+
+\section{主要接口}
+
+\begin{function}{\newcondition,\setcondition,\clearcondition}
+ \begin{syntax}
+ \cs{newcondition} \marg{identifier} \marg{id(s)}
+ \cs{setcondition} + \marg{identifier=ids list}
+ \cs{clearcondition}\oarg{identifier(s)}
+ \end{syntax}
+ \cs{newcondition} 定义 \meta{identifier} 的 \meta{ids}。\meta{identifier} 两侧的空格将被移除。
+
+ \cs{setcondition} 设置在当前组中有效的 \meta{id}。不带 \verb|+| 的版本将局部地清除原先设置的 \meta{identifier} 的ids。
+
+ \meta{identifier}、\meta{id} 均不能为 \verb|*|。
+
+ \cs{clearcondition} 局部地清除指定的 \meta{identifiers},默认值为 \verb|*|,即清除所有。
+\end{function}
+
+\begin{function}{
+ \conditionif,\conditioncmd,
+ \econditionif,\econditioncmd,
+}
+ \begin{syntax}
+ \cs{conditionif} * \oarg{identifier=ids list} \marg{true} \marg{false}
+ \cs{conditioncmd} * \oarg{identifier=ids list} \marg{material}
+ \end{syntax}
+ 当 \meta{identifier=ids list} 的组合使得当前条件为真时,使用 \meta{true}、\meta{material},为假时,使用 \meta{false}。
+
+ 不带 \verb|*| 的版本为 \verb|any|,带 \verb|*| 的为 \verb|all|。详见下方的说明。
+
+ \cs{econditionif}、\cs{econditioncmd} 为可 \verb|f|-扩展的。
+ \cs{conditionif}、\cs{conditioncmd} 为不可扩展(\tn{protected})的。
+
+ \meta{identifier=ids list} 默认值为 \verb|*|,即在默认情况下将输出 \meta{true}、\meta{material}。
+\end{function}
+
+\begin{function}{
+ \conditioncase,\conditioncaseTF,
+ \econditioncase,\econditioncaseTF
+}
+ \begin{syntax}
+ \cs{conditioncaseTF} * !
+ ~~\{
+ ~~~~\marg{identifier-ids list case_1} \marg{code_1}
+ ~~~~\marg{identifier-ids list case_2} \marg{code_2}
+ ~~~~...
+ ~~~~\marg{identifier-ids list case_n} \marg{code_n}
+ ~~\}
+ ~~\marg{true code}
+ ~~\marg{false code}
+ \end{syntax}
+ \verb|!| 未给出时,依次计算 \meta{identifier-ids list cases},直到遇到第一个 \meta{case} 为\emph{真},输出对应的 \meta{code} 与 \meta{true code},若未成功匹配,则输出 \meta{false code}。
+
+ \verb|!| 给出时,依次计算 \meta{identifier-ids list cases},直到遇到第一个 \meta{case} 为\emph{假},输出对应的 \meta{code} 与 \meta{true code},若未成功匹配,则输出 \meta{false code}。
+\end{function}
+
+\begin{texnote}
+ 对 \meta{ids} 的处理使用的是 \LaTeX3 的 \cs{clist_map_...},它们将形如 \verb|{,}| 的list视为空,形如 \verb|{{},}| 视为非空。
+\end{texnote}
+
+假定已经使用了如下命令:
+\begin{verbatim}
+ \newcondition{defined}{}
+ \newcondition{paper}{a4,a5,b5}
+ \setcondition{paper={a5,b5}}
+\end{verbatim}
+即 \verb|defined| 已被 \cs{newcondition} 定义且无id,\verb|paper| 已被 \cs{newcondition} 定义且有 \verb|a4,b5,a5| 三个id,其中 \verb|a5,b5| 已被设置,\verb|undefined| 未被定义。
+
+\verb|any| 在满足如下条件之一为真:
+\begin{enumerate}
+ \item \meta{identifier=ids list} 为 \verb|*|;
+ \item \meta{identifier=ids list} 为一个已被定义的 \meta{identifier},且未给出 \meta{id} 值 ,即 \meta{identifier=ids list} 为 \verb|paper| 或 \verb|defined|;
+ \item \meta{identifier=ids list} 为一个已被定义的 \meta{identifier},且 \meta{id} 值为 \verb|*|,即 \meta{identifier=ids list} 为 \verb|paper=*| 或 \verb|defined=*|;
+ \item \meta{identifier=ids list} 为一个已被定义的 \meta{identifier},且给出的 \meta{ids} 中\emph{有}被设置的id,即 \meta{identifier=ids list} 为 \verb|paper=b5| 或 \verb|paper={a5,b5}| 或 \verb|paper={a5,a0}| (\verb|a0| 未设置,但 \verb|a5| 已设置)。注意 \verb|defined| 给出的任何除 \verb|*| 之外的 \meta{ids} 值都将使得条件为假,即使是空值(\verb|defined=|);
+ \item \meta{identifier=ids list} 中\emph{任意一项}满足如上4点之一,如 \verb|paper={a5,a0},undefined|。
+\end{enumerate}
+
+\verb|all| 在满足如下条件之一为真:
+\begin{enumerate}
+ \item \meta{identifier=ids list} 为 \verb|*|;
+ \item \meta{identifier=ids list} 为一个已被定义的 \meta{identifier},且未给出 \meta{id} 值 ,即 \meta{identifier=ids list} 为 \verb|paper| 或 \verb|defined|;
+ \item \meta{identifier=ids list} 为一个已被定义的 \meta{identifier},且 \meta{id} 值为 \verb|*|,即 \meta{identifier=ids list} 为 \verb|paper=*| 或 \verb|defined=*|;
+ \item \meta{identifier=ids list} 为一个已被定义的 \meta{identifier},且给出的 \meta{ids} \emph{均}被设置,即 \meta{identifier=ids list} 为 \verb|paper=b5| 或 \verb|paper={a5,b5}|。注意 \verb|defined| 给出的任何除 \verb|*| 之外的 \meta{id} 值都将使得条件为假,即使是空值(\verb|defined=|);
+ \item \meta{identifier=ids list} 中\emph{所有项均}满足如上4点之一,如 \verb|paper={a5,b5},defined|。
+\end{enumerate}
+
+\begin{function}{
+ \newconditioncommand,
+ \renewconditioncommand,
+ \provideconditioncommand,
+ \declareconditioncommand,
+ \neweconditioncommand,
+ \reneweconditioncommand,
+ \provideeconditioncommand,
+ \declareeconditioncommand,
+}
+ \begin{syntax}
+ \cs{newconditioncommand} * \meta{function} \oarg{arg nums} \oarg{default} \marg{code}
+ \cs{neweconditioncommand} * \meta{function} \oarg{arg nums} \marg{code}
+ \end{syntax}
+ 这些命令与 \LaTeXe{} 的命令相对应。\cs{newconditioncommand} 命令正如 \LaTeXe{} 的 \tn{newcommand} 命令。它们将定义形如 \verb|\foo+|\marg{identifier=ids list}\meta{args} 的命令。定义的命令的可选参数不可包含 \tn{par}。
+
+ \cs{neweconditioncommand} 命令定义的是可扩展的命令,不可设置默认参数。但可使用 \pkg{xparse} 形式的命令定义可设置默认值的参数。
+
+ 不带 |*| 的版本定义的命令是 \tn{long} 的。即其参数可以包含多个段落。
+\end{function}
+
+\begin{function}{
+ \NewConditionCommand ,
+ \RenewConditionCommand ,
+ \ProvideConditionCommand ,
+ \DeclareConditionCommand ,
+ \NewExpandableConditionCommand ,
+ \RenewExpandableConditionCommand ,
+ \ProvideExpandableConditionCommand ,
+ \DeclareExpandableConditionCommand ,
+}
+ \begin{syntax}
+ \cs{NewConditionCommand} \meta{function} \marg{arg spec} \marg{code}
+ \end{syntax}
+ 这些命令与 \pkg{xparse} 宏包的命令相对应。它们将定义形如 \verb|\foo+|\marg{identifier=ids list}\meta{args} 的命令。
+
+ \meta{arg spec} 应符合 \pkg{xparse} 宏包相应命令的规则。
+
+ 其中带 \verb|+| 的命令为 |all|,不带 \verb|+| 的为 |any|。\meta{identifier=ids list} 的含义如上所述。\meta{args} 为
+ 由 \meta{arg spec} 定义的参数。
+\end{function}
+
+
+\section{例子}
+
+\input{cdcmd-test.tex}
+
+
+\section{For package author}
+
+\begin{function}[pTF]{
+ \cdcmd_any_if:n,
+ \cdcmd_all_if:n,
+ \cdcmd_any_if:o,
+ \cdcmd_all_if:o,
+ \cdcmd_any_if:V,
+ \cdcmd_all_if:V,
+ \cdcmd_any_if:f,
+ \cdcmd_all_if:f,
+}
+ 它们的含义应该是显然的。
+\end{function}
+
+\begin{function}[TF]{
+ \cdcmd_any_case_true:n,
+ \cdcmd_any_case_false:n,
+ \cdcmd_all_case_true:n,
+ \cdcmd_all_case_false:n,
+}
+ 它们的含义应该是显然的。
+\end{function}
+
+\section{实现}
+
+见 \href{./cdcmd.pdf}{cdcmd.pdf}
+
+\end{document}
diff --git a/Master/texmf-dist/doc/latex/cdcmd/cdcmd-test.tex b/Master/texmf-dist/doc/latex/cdcmd/cdcmd-test.tex
new file mode 100644
index 00000000000..f0d5ed5a98f
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/cdcmd/cdcmd-test.tex
@@ -0,0 +1,161 @@
+{\color{red!90!black}
+\begin{verbatim}
+ \newcondition{defined}{}
+ \newcondition{paper}{a4,a5,b5}
+ \setcondition{paper={a5,b5}}
+\end{verbatim}
+}
+
+{
+\newcondition{defined}{}
+\newcondition{paper}{a4,a5,b5}
+\setcondition{paper={a5,b5}}
+\def\cdcmdtest#1->#2 /{\textcolor{red!90!black}{\detokenize{#1}}:~ #1 \newline}
+\parindent=0pt\ttfamily
+\cdcmdtest\conditionif[*]{t}{f}->t /
+\cdcmdtest\conditionif[defined]{t}{f}->t /
+\cdcmdtest\conditionif[defined=]{t}{f}->f /
+\cdcmdtest\conditionif[defined=*]{t}{f}->t /
+\cdcmdtest\conditionif[defined=a]{t}{f}->f /
+\cdcmdtest\conditionif[paper={a5,a0},undefined]{t}{f}->t /
+
+\cdcmdtest\conditionif*[*]{t}{f}->t /
+\cdcmdtest\conditionif*[defined]{t}{f}->t /
+\cdcmdtest\conditionif*[defined={,,}]{t}{f}->f /
+\cdcmdtest\conditionif*[defined=*]{t}{f}->t /
+\cdcmdtest\conditionif*[defined=a]{t}{f}->f /
+\cdcmdtest\conditionif*[paper={a5,a0},undefined]{t}{f}->f /
+\cdcmdtest\conditionif*[*,undefined]{t}{f}->f /
+\cdcmdtest\conditionif*[paper={a5,b5}]{t}{f}->t /
+\cdcmdtest\conditionif*[paper={a5,,b5}]{t}{f}->t /
+\cdcmdtest\conditionif*[paper={a5,b6,a5}]{t}{f}->f /
+\cdcmdtest\conditionif*[paper={a5,{ },45}]{t}{f}->f /
+\cdcmdtest\conditionif*[*,defined,paper={a5,b5}]{t}{f}->t /
+}
+
+{\color{red!90!black}
+\begin{verbatim}
+ \def\truetext{true} \def\falsetext{false}
+ \edef\testa{\econditionif[*]{true}{false}}
+ \ifx\testa\truetext t\else f\fi
+ \ifx\testa\falsetext t\else f\fi
+ \strcmp {\econditionif[*]{true}{false}} {true}
+ \strcmp {\econditionif[*]{true}{false}} {false}
+ \strcmp {\testa} {\truetext}
+ \strcmp {\testa} {\falsetext}
+\end{verbatim}
+}
+\def\truetext{true} \def\falsetext{false}
+\edef\testa{\econditionif[*]{true}{false}}
+\ifx\testa\truetext t\else f\fi
+\ifx\testa\falsetext t\else f\fi
+\strcmp{\econditionif[*]{true}{false}}{true}
+\strcmp{\econditionif[*]{true}{false}}{false}
+\strcmp{\testa}{\truetext}
+\strcmp{\testa}{\falsetext}
+
+{\color{red!90!black}
+\begin{verbatim}
+ \conditioncase{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+ }
+\end{verbatim}
+}
+\conditioncase{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+}
+
+{\color{red!90!black}
+\begin{verbatim}
+ \conditioncaseTF{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+ }{true}{false}
+\end{verbatim}
+}
+\conditioncaseTF{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+}{true}{false}
+
+{\color{red!90!black}
+\begin{verbatim}
+ \conditioncase!{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+ }
+\end{verbatim}
+}
+\conditioncase!{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+}
+
+{\color{red!90!black}
+\begin{verbatim}
+ \conditioncaseTF!{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+ }{true}{false}
+\end{verbatim}
+}
+\conditioncaseTF!{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+}{true}{false}
+
+{\color{red!90!black}
+\begin{verbatim}
+ \newconditioncommand\longprotectedcdcmd{longprotectedcdcmd}
+ \newconditioncommand\longprotectedcdcmdi[1]{longprotectedcdcmdi<#1>}
+ \newconditioncommand\longprotectedcdcmdio[1][DFT]{longprotectedcdcmdio<#1>}
+ \newconditioncommand*\shortprotectedcdcmd{shortprotectedcdcmd}
+ \newconditioncommand*\shortprotectedcdcmdi[1]{shortprotectedcdcmdi<#1>}
+ \newconditioncommand*\shortprotectedcdcmdio[1][DFT]{shortprotectedcdcmdio<#1>}
+
+ \setcondition{paper={a4,a5}}
+ \longprotectedcdcmd{*}
+ \longprotectedcdcmdi{*}{1\par arg}
+ \longprotectedcdcmdio{*}
+ \longprotectedcdcmdio{*}[1opt]
+ \longprotectedcdcmdio{paper=a4}[1opt a4]
+ \longprotectedcdcmdio+{paper={a4,a7}}[1opt a4a7]
+ \shortprotectedcdcmd{*}
+ \shortprotectedcdcmdi{*}{1\par arg}
+ \shortprotectedcdcmdio{*}
+ \shortprotectedcdcmdio{*}[1opt]
+ \shortprotectedcdcmdio{paper=a4}[1opt a4]
+ \shortprotectedcdcmdio+{paper={a4,a7}}[1opt a4a7]
+\end{verbatim}
+}
+\newconditioncommand\longprotectedcdcmd{longprotectedcdcmd}
+\newconditioncommand\longprotectedcdcmdi[1]{longprotectedcdcmdi<#1>}
+\newconditioncommand\longprotectedcdcmdio[1][DFT]{longprotectedcdcmdio<#1>}
+\newconditioncommand*\shortprotectedcdcmd{shortprotectedcdcmd}
+\newconditioncommand*\shortprotectedcdcmdi[1]{shortprotectedcdcmdi<#1>}
+\newconditioncommand*\shortprotectedcdcmdio[1][DFT]{shortprotectedcdcmdio<#1>}
+
+{\ttfamily\setcondition{paper={a4,a5}}\obeylines
+\longprotectedcdcmd{*}
+\longprotectedcdcmdi{*}{1\par arg}
+\longprotectedcdcmdio{*}
+\longprotectedcdcmdio{*}[1opt]
+\longprotectedcdcmdio{paper=a4}[1opt a4]
+\longprotectedcdcmdio+{paper={a4,a7}}[1opt a4a7]
+\shortprotectedcdcmd{*}
+\shortprotectedcdcmdi{*}{1arg}
+\shortprotectedcdcmdio{*}
+\shortprotectedcdcmdio{*}[1opt]
+\shortprotectedcdcmdio{paper=a4}[1opt a4]
+\shortprotectedcdcmdio+{paper={a4,a7}}[1opt a4a7]
+}
diff --git a/Master/texmf-dist/doc/latex/cdcmd/cdcmd.pdf b/Master/texmf-dist/doc/latex/cdcmd/cdcmd.pdf
new file mode 100644
index 00000000000..2ed91deeff1
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/cdcmd/cdcmd.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/cdcmd/cdcmd.dtx b/Master/texmf-dist/source/latex/cdcmd/cdcmd.dtx
new file mode 100644
index 00000000000..84205860970
--- /dev/null
+++ b/Master/texmf-dist/source/latex/cdcmd/cdcmd.dtx
@@ -0,0 +1,1053 @@
+%\iffalse meta-comment
+%<*internal>
+\iffalse
+%</internal>
+%<*readme>
+Abstract
+----
+The `cdcmd` package provides some conditional command, just like `styledcmd`
+package. The difference is `cdcmd` can define expandable command.
+
+See `cdcmd.pdf` (in English) or `cdcmd-cn.pdf` (in Chinese) for more details.
+
+Contributing
+----
+[Issues](https://github.com/Sophanatprime/cdcmd/issues) and
+[pull requests](https://github.com/Sophanatprime/cdcmd/pulls)
+are always welcome.
+
+Copyright and license
+----
+Copyright (C) 2021--2021
+Wenjian Chern (Longaster) and any individual authors listed elsewhere in this file.
+--------------------------------------------------------------------------
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either
+version 1.3c of this license or (at your option) any later
+version. This version of this license is in
+ http://www.latex-project.org/lppl/lppl-1-3c.txt
+and the latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3 or later is part of all distributions of
+LaTeX version 2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained`.
+
+The Current Maintainers of this work are Wenjian Chern (Longaster).
+--------------------------------------------------------------------------
+%</readme>
+%<*internal>
+\fi
+%</internal>
+%\fi
+%\iffalse
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\RequirePackage{expl3}[2021/05/11]
+%<package>\GetIdInfo$Id: cdcmd.dtx 1.0 2021/10/12 +0815 Longaster$
+%<package> {Expandable Conditional Command In LaTeX2e}
+%<package>\ProvidesExplPackage{cdcmd}
+%<package> {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
+%<*driver>
+\documentclass{l3doc}
+\usepackage{xcolor}
+\usepackage{cdcmd}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+ \DocInput{\jobname.dtx}
+ \PrintChanges
+ \PrintIndex
+\end{document}
+%</driver>
+%\fi
+%
+%\GetFileInfo{cdcmd.sty}
+% \title{The \pkg{cdcmd} package}
+%
+% \author{Wenjian Chern
+% (Longaster\thanks{Email: \url{longaster@163.com}}~)}
+%
+% \date{Released \today, version \fileversion}
+%
+% \maketitle
+%
+% \begin{documentation}
+% \ExplSyntaxOn \let\strcmp\tex_strcmp:D \ExplSyntaxOff
+%
+% \begin{abstract}
+% \pkg{cdcmd} is a package that allows you define `polymorphic' command. Like \pkg{styledcmd} package,
+% you can define \tn{protected} command, but \pkg{cdcmd} can define expandable conditional command as well.
+% \end{abstract}
+%
+%\section{Main Interface}
+%
+%\begin{function}{\newcondition,\setcondition,\clearcondition}
+% \begin{syntax}
+% \cs{newcondition} \marg{identifier} \marg{id(s)}
+% \cs{setcondition} + \marg{identifier=ids list}
+% \cs{clearcondition}\oarg{identifier(s)}
+% \end{syntax}
+% \cs{newcondition} new \meta{identifier} and its \meta{ids}.
+% The leading and trailing spaces in \meta{identifier} will be removed.
+%
+% \cs{setcondition} sets \meta{ids} of \meta{identifier} locally.
+% The un-\verb|+| version will clear \meta{ids} formerly set.
+%
+% Both \meta{identifier} and \meta{id} cannot be \verb|*|.
+%
+% \cs{clearcondition} will clear ids from given \meta{identifiers} locally. Default value is \verb|*|, that is, clear all.
+%\end{function}
+%
+%\begin{function}{
+% \conditionif,\conditioncmd,
+% \econditionif,\econditioncmd,
+%}
+% \begin{syntax}
+% \cs{conditionif} * \oarg{identifier=ids list} \marg{true} \marg{false}
+% \cs{conditioncmd} * \oarg{identifier=ids list} \marg{material}
+% \end{syntax}
+% When the \meta{identifier=ids list} makes \texttt{true} condition, leave \meta{true}/\marg{material} in the input stream.
+% Leaving \meta{false} when the condition is \texttt{false}.
+%
+% The starred version is \texttt{all}, unstarred version is \text{any}.
+% See below for more details.
+%
+% The \cs{econditionif} and \cs{econditioncmd} are expandable (\verb|f-|expandable).
+% \cs{conditionif}, \cs{conditioncmd} are \tn{protected}.
+%
+% The default value of \meta{identifier=id list} is \verb|*|, will leave \meta{true}/\meta{material} in the input stream.
+%\end{function}
+%
+%\begin{function}{
+% \conditioncase,\conditioncaseTF,
+% \econditioncase,\econditioncaseTF
+%}
+% \begin{syntax}
+% \cs{conditioncaseTF} * !
+% ~~\{
+% ~~~~\marg{identifier=ids list case_1} \marg{code_1}
+% ~~~~\marg{identifier=ids list case_2} \marg{code_2}
+% ~~~~...
+% ~~~~\marg{identifier=ids list case_n} \marg{code_n}
+% ~~\}
+% ~~\marg{true code}
+% ~~\marg{false code}
+% \end{syntax}
+% Evaluates in turn each of the \meta{identifier=ids list} until the first one that evaluates
+% to \texttt{true} or to \texttt{false}, for un-\verb|!| version or \verb|!| version, respectively.
+% The \meta{code} associated to this first case is left in the input stream, followed by the \meta{true code},
+% and other cases are discarded. If none of the cases match then only the \meta{false code} is inserted.
+%
+% The unstarred version is \verb|any|, starred version is \verb|all|.
+%\end{function}
+%
+%\begin{texnote}
+% The process in \meta{ids} is using \cs{clist_map_...} of \LaTeX3. It will view \verb|{,}| as empty,
+% while \verb|{{},}| are not. See \pkg{interface3.pdf} for more details.
+%\end{texnote}
+%
+% Supposing following commands have been used.
+%\begin{verbatim}
+% \newcondition{defined}{}
+% \newcondition{paper}{a4,a5,b5}
+% \setcondition{paper={a5,b5}}
+%\end{verbatim}
+% It will define an identifier named \verb|defined|, which has not id.
+% And define an identifier named \verb|paper|, which has three ids: \verb|a4, a5, b5|.
+% Then set two ids: \verb|a5,b5| for \verb|paper| identifier.
+%
+% \verb|any| will be evaluated to \texttt{true} if \meta{identifier=ids list}
+% matches any of one statement described followed:
+%\begin{enumerate}
+% \item \meta{identifier=ids list} is exactly \verb|*|;
+% \item \meta{identifier=ids list} is exactly a defined $\mathit{identifier}$, such as \verb|paper|, or \verb|defined|;
+% \item \meta{identifier=ids list} is a defined $\mathit{identifier}$, and its \meta{id} is \verb|*|, such as \verb|paper=*| or \verb|defined=*|;
+% \item \meta{identifier=ids list} is a defined $\mathit{identifier}$, and \emph{one of} item in \meta{ids} has been set, such as \verb|paper=b5| or \verb|paper={a5,b5}| or \verb|paper={a5,a0}| (\verb|a0| unset, but \verb|a5| already set. Any id set to \meta{identifier} \verb|defined| will evaluate to \texttt{false}, except \verb|*|, because the $\mathit{identifier}$ never have defined id, even the \meta{ids} is empty (\verb|defined=|);
+% \item \emph{Any} single item in \meta{identifier=ids list} matches any statements listed above, such as \verb|paper={a5,a0},undefined|.
+%\end{enumerate}
+%
+% \verb|all| will be evaluated to \text{true} if \meta{identifier=ids list}
+% matches any of one statement described followed.
+%\begin{enumerate}
+% \item \meta{identifier=ids list} is exactly \verb|*|;
+% \item \meta{identifier=ids list} is exactly a defined $\mathit{identifier}$, such as \verb|paper|, or \verb|defined|;
+% \item \meta{identifier=ids list} is a defined $\mathit{identifier}$, and its \meta{id} is \verb|*|, such as \verb|paper=*| or \verb|defined=*|;
+% \item \meta{identifier=ids list} is a defined $\mathit{identifier}$, and \emph{all of} the \meta{ids} has been set, such as \verb|paper=b5| or \verb|paper={a5,b5}|. The any id set to \meta{identifier} \verb|defined| will evaluate to \texttt{false}, except \verb|*|, because the $\mathit{identifier}$ never have defined id, even the \meta{ids} is empty (\verb|defined=|);
+% \item \emph{All} items in \meta{identifier=ids list} match any statements listed above, such as \verb|paper={a5,b5},defined|.
+%\end{enumerate}
+%
+%\begin{function}{
+% \newconditioncommand,
+% \renewconditioncommand,
+% \provideconditioncommand,
+% \declareconditioncommand,
+% \neweconditioncommand,
+% \reneweconditioncommand,
+% \provideeconditioncommand,
+% \declareeconditioncommand,
+%}
+% \begin{syntax}
+% \cs{newconditioncommand} * \meta{function} \oarg{arg nums} \oarg{default} \marg{code}
+% \cs{neweconditioncommand} * \meta{function} \oarg{arg nums} \marg{code}
+% \end{syntax}
+% Those commands are just like \tn{newcommand}, \tn{renewcommand}, etc. They will define command like
+% \verb|\foo+|\marg{identifier=ids list}\meta{args}. The optional argument cannot contain \tn{par}.
+%
+% The \verb|e|-version commands define expandable command, and cannot set default value.
+% However you can use \pkg{xparse}-like command illustrated followed,
+% which can set default value.
+%
+% Unstarred version is \tn{long}, just like \LaTeX's.
+%
+% The new \meta{function} will take one optional argument: \verb|+|, the function is just like
+% the \verb|*| in \cs{conditionif}, etc. And one mandatory argument \meta{identifier=ids list}.
+% After absorbing these two arguments, then absorb arguments of given \meta{arg nums}, or use \meta{default}, if given.
+%\end{function}
+%
+%\begin{function}{
+% \NewConditionCommand ,
+% \RenewConditionCommand ,
+% \ProvideConditionCommand ,
+% \DeclareConditionCommand ,
+% \NewExpandableConditionCommand ,
+% \RenewExpandableConditionCommand ,
+% \ProvideExpandableConditionCommand ,
+% \DeclareExpandableConditionCommand ,
+%}
+% \begin{syntax}
+% \cs{NewConditionCommand} \meta{function} \marg{arg spec} \marg{code}
+% \end{syntax}
+% Those commands are just like \pkg{xparse}'s \cs{NewDocumentCommand}, etc.
+% They will define command like \verb|\foo+|\marg{identifier=ids list}\meta{args}.
+%
+% \meta{arg spec} must follow the rules of the \pkg{xparse} package.
+%
+% The new \meta{function} will take one optional argument: \verb|+|, the function is just like
+% the \verb|*| in \cs{conditionif}, etc. And one mandatory argument \meta{identifier=ids list}.
+% After absorbing these two arguments, then absorb arguments of given \meta{arg spec}.
+%\end{function}
+%
+% \section{Examples}
+%
+% \input{cdcmd-test.tex}
+%
+% \section{For package authors}
+%
+% \begin{function}[pTF]{
+% \cdcmd_any_if:n,
+% \cdcmd_all_if:n,
+% \cdcmd_any_if:o,
+% \cdcmd_all_if:o,
+% \cdcmd_any_if:V,
+% \cdcmd_all_if:V,
+% \cdcmd_any_if:f,
+% \cdcmd_all_if:f,
+% }
+% The meaning should be obvious.
+% \end{function}
+%
+% \begin{function}[TF]{
+% \cdcmd_any_case_true:n,
+% \cdcmd_any_case_false:n,
+% \cdcmd_all_case_true:n,
+% \cdcmd_all_case_false:n,
+% }
+% The meaning should be obvious.
+% \end{function}
+%
+% \end{documentation}
+%
+% \begin{implementation}
+%
+% \section{Implementation}
+%
+% \begin{macrocode}
+%<*package>
+% \end{macrocode}
+% \begin{macrocode}
+%<@@=cdcmd>
+% \end{macrocode}
+% \begin{macrocode}
+\str_const:Nn \c_cdcmd_all_str { * }
+\clist_new:N \g__cdcmd_clist
+\bool_new:N \l__cdcmd_clear_set_bool
+\msg_new:nnn { cdcmd } { condition-exist }
+ { The~ condition~ `#1'~ you~ try~ to~ new~ already~ exists. }
+\msg_new:nnn { cdcmd } { condition-not-exist }
+ { The~ condition~ `#1'~ not~ exists. }
+\msg_new:nnn { cdcmd } { condition-id-not-exist }
+ { The~ id~ `#2' of~ condition~ `#1'~ not~ exists. }
+% \end{macrocode}
+% \begin{macro}[pTF]{\cdcmd_if_exist:n}
+% Condition \meta{indentifier} if exist.
+% \begin{macrocode}
+\prg_new_conditional:Npnn \cdcmd_if_exist:n #1 { p, T, F, TF }
+ {
+ \clist_if_exist:cTF { c__cdcmd_condition@ #1 _clist }
+ { \prg_return_true: } { \prg_return_false: }
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}[TF]{\cdcmd_cd_id_if_exist:nn}
+% ID \meta{id} of condition \meta{indentifier} if exist.
+% \begin{macrocode}
+\prg_new_conditional:Npnn \cdcmd_cd_id_if_exist:nn #1#2 { T, F, TF }
+ {
+ \clist_if_in:cnTF { c__cdcmd_condition@ #1 _clist } {#2}
+ { \prg_return_true: } { \prg_return_false: }
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{
+% \cdcmd_new:nn,
+% \cdcmd_set:nn,
+% \cdcmd_set_cdcmd_single:nn,
+% \cdcmd_set_cdcmd_all:n,
+% \cdcmd_set:n,
+% \cdcmd_clear_set:n,
+% }
+% \begin{macrocode}
+\cs_new_nopar:Npn \cdcmd_new:nn #1#2
+ {
+ \cdcmd_if_exist:nTF {#1}
+ { \msg_error:nnn { cdcmd } { condition-exist } {#1} }
+ {
+ \clist_gput_right:Nn \g__cdcmd_clist {#1}
+ \clist_const:cn { c__cdcmd_condition@ #1 _clist } {#2}
+ \clist_new:c { l__cdcmd_curr_condition@ #1 _clist }
+ }
+ }
+\cs_new_nopar:Npn \cdcmd_set:nn #1#2
+ {
+ \cdcmd_if_exist:nTF {#1}
+ {
+ \bool_if:NT \l__cdcmd_clear_set_bool
+ { \clist_clear:c { l__cdcmd_curr_condition@ #1 _clist } }
+ \clist_map_inline:nn {#2}
+ {
+ \str_if_eq:eeTF {##1} { \c_cdcmd_all_str }
+ { \clist_map_break:n { \cdcmd_set_cdcmd_all:n {#1} } }
+ { \cdcmd_set_cdcmd_single:nn {#1} {##1} }
+ }
+ }
+ { \msg_warning:nnn { cdcmd } { condition-not-exist } {#1} }
+ }
+\cs_new_nopar:Npn \cdcmd_set_cdcmd_single:nn #1#2
+ {
+ \cdcmd_if_exist:nTF {#1}
+ {
+ \cdcmd_cd_id_if_exist:nnTF {#1} {#2}
+ { \clist_put_right:cn { l__cdcmd_curr_condition@ #1 _clist } {#2} }
+ { \msg_warning:nnnn { cdcmd } { condition-id-not-exist } {#1} {#2} }
+ }
+ { \msg_warning:nnn { cdcmd } { condition-not-exist } }
+ }
+\cs_new_nopar:Npn \cdcmd_set_cdcmd_all:n #1
+ {
+ \cdcmd_if_exist:nTF {#1}
+ {
+ \clist_set_eq:cc
+ { l__cdcmd_curr_condition@ #1 _clist }
+ { c__cdcmd_condition@ #1 _clist }
+ }
+ { \msg_warning:nnn { cdcmd } { condition-not-exist } {#1} }
+ }
+\cs_new_nopar:Npn \cdcmd_set:n
+ { \keyval_parse:NNn \cdcmd_set_cdcmd_all:n \cdcmd_set:nn }
+\cs_new_nopar:Npn \cdcmd_clear_set:n #1
+ {
+ \bool_set_true:N \l__cdcmd_clear_set_bool
+ \keyval_parse:NNn \cdcmd_set_cdcmd_all:n \cdcmd_set:nn {#1}
+ \bool_set_false:N \l__cdcmd_clear_set_bool
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}[pTF]{
+% \cdcmd_any_if:n,
+% \cdcmd_any_if:o,
+% \cdcmd_any_if:V,
+% \cdcmd_any_if:f,
+% }
+% \begin{macrocode}
+\cs_new:Npn \cdcmd_any_if:nTF #1
+ {
+ \bool_if:nTF
+ {
+ \keyval_parse:NNn
+ \__cdcmd_any_i:n \__cdcmd_any_ii:nn {#1}
+ \c_false_bool
+ }
+ }
+\cs_new:Npn \cdcmd_any_if_p:n #1
+ {
+ \bool_if_p:n
+ {
+ \keyval_parse:NNn
+ \__cdcmd_any_i:n \__cdcmd_any_ii:nn {#1}
+ \c_false_bool
+ }
+ }
+\cs_new:Npn \cdcmd_any_if:nT #1#2 { \cdcmd_any_if:nTF {#1} {#2} { } }
+\cs_new:Npn \cdcmd_any_if:nF #1 { \cdcmd_any_if:nTF {#1} { } }
+\cs_new:Npn \cdcmd_any_if:nFT #1#2#3 { \cdcmd_any_if:nTF {#1} {#3} {#2} }
+\prg_generate_conditional_variant:Nnn \cdcmd_any_if:n { o, V, f } { p, T, F, TF }
+\cs_new:Npn \__cdcmd_any_i:n #1
+ {
+ \str_if_eq:eeTF {#1} { \c_cdcmd_all_str }
+ { \c_true_bool || }
+ { \cdcmd_if_exist:nT {#1} { \c_true_bool || } }
+ }
+\cs_new:Npn \__cdcmd_any_ii:nn #1#2
+ {
+ \cdcmd_if_exist:nT {#1}
+ {
+ \clist_map_tokens:nn {#2}
+ { \__cdcmd_any_ii_aux:nn {#1} }
+ }
+ }
+\cs_new:Npn \__cdcmd_any_ii_aux:nn #1#2
+ {
+ \str_if_eq:eeTF {#2} { \c_cdcmd_all_str }
+ { \clist_map_break:n { \tex_the:D \c_true_bool || } }
+ {
+ \__cdcmd_clist_if_in:cnT { l__cdcmd_curr_condition@ #1 _clist } {#2}
+ { \clist_map_break:n { \tex_the:D \c_true_bool || } }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}[pTF]{
+% \cdcmd_all_if:n,
+% \cdcmd_all_if:o,
+% \cdcmd_all_if:V,
+% \cdcmd_all_if:f,
+% }
+% \begin{macrocode}
+\cs_new:Npn \cdcmd_all_if:nTF #1
+ {
+ \bool_if:nTF
+ {
+ \keyval_parse:NNn
+ \__cdcmd_all_i:n \__cdcmd_all_ii:nn {#1}
+ \c_true_bool
+ }
+ }
+\cs_new:Npn \cdcmd_all_if_p:n #1
+ {
+ \bool_if_p:n
+ {
+ \keyval_parse:NNn
+ \__cdcmd_all_i:n \__cdcmd_all_ii:nn {#1}
+ \c_true_bool
+ }
+ }
+\cs_new:Npn \cdcmd_all_if:nT #1#2 { \cdcmd_all_if:nTF {#1} {#2} { } }
+\cs_new:Npn \cdcmd_all_if:nF #1 { \cdcmd_all_if:nTF {#1} { } }
+\cs_new:Npn \cdcmd_all_if:nFT #1#2#3 { \cdcmd_all_if:nTF {#1} {#3} {#2} }
+\prg_generate_conditional_variant:Nnn \cdcmd_all_if:n { o, V, f } { p, T, F, TF }
+\cs_new:Npn \__cdcmd_all_i:n #1
+ {
+ \str_if_eq:eeF {#1} { \c_cdcmd_all_str }
+ { \cdcmd_if_exist:nF {#1} { \c_false_bool && } }
+ }
+\cs_new:Npn \__cdcmd_all_ii:nn #1#2
+ {
+ \cdcmd_if_exist:nTF {#1}
+ {
+ \bool_lazy_and_p:nn
+ { \int_compare_p:n { \clist_count:n {#2} > 0 } }
+ {
+ \int_compare_p:n
+ { \clist_map_tokens:nn {#2} { \__cdcmd_all_ii_aux:nn {#1} } 1 > 0 }
+ } &&
+ }
+ { \c_false_bool && }
+ }
+\cs_new:Npn \__cdcmd_all_ii_aux:nn #1#2
+ {
+ \str_if_eq:eeF {#2} { \c_cdcmd_all_str }
+ {
+ \__cdcmd_clist_if_in:cnF { l__cdcmd_curr_condition@ #1 _clist } {#2}
+ { \clist_map_break:n { - } }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}[pTF]{
+% \__cdcmd_clist_if_in:Nn,
+% \__cdcmd_clist_if_in:NV,
+% \__cdcmd_clist_if_in:No,
+% \__cdcmd_clist_if_in:cn,
+% \__cdcmd_clist_if_in:cV,
+% \__cdcmd_clist_if_in:co,
+% \__cdcmd_clist_if_in:nn,
+% \__cdcmd_clist_if_in:nV,
+% \__cdcmd_clist_if_in:no,
+% }
+% \begin{macrocode}
+\prg_new_conditional:Npnn \__cdcmd_clist_if_in:Nn #1#2 { p, T, F, TF }
+ {
+ \int_compare:nTF
+ { 0 \clist_map_tokens:Nn #1 { \__cdcmd_if_eq_break:ee {#2} } > 0 }
+ { \prg_return_true: } { \prg_return_false: }
+ }
+\prg_generate_conditional_variant:Nnn \__cdcmd_clist_if_in:Nn
+ { NV, No, cn, cV, co } { p, T, F, TF }
+\prg_new_conditional:Npnn \__cdcmd_clist_if_in:nn #1#2 { p, T, F, TF }
+ {
+ \int_compare:nTF
+ { 0 \clist_map_tokens:nn {#1} { \__cdcmd_if_eq_break:ee {#2} } > 0 }
+ { \prg_return_true: } { \prg_return_false: }
+ }
+\prg_generate_conditional_variant:Nnn \__cdcmd_clist_if_in:nn { nV, no } { p, T, F, TF }
+\cs_new:Npn \__cdcmd_if_eq_break:ee #1#2
+ {
+ \str_if_eq:eeT {#1} {#2} { \clist_map_break:n { 1 } }
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}[TF]{
+% \cdcmd_any_case_true:n,
+% \cdcmd_any_case_false:n,
+% \cdcmd_all_case_true:n,
+% \cdcmd_all_case_false:n,
+% }
+% Conditional case, see also \cs{bool_case_true:n} and \cs{bool_case_false:n} in \pkg{source3.pdf}.
+% \begin{macrocode}
+\scan_new:N \s__cdcmd_mark
+\scan_new:N \s__cdcmd_stop
+\cs_new:Npn \cdcmd_any_case_true:nTF { \exp:w \__cdcmd_any_case_true:nTF }
+\cs_new:Npn \cdcmd_any_case_true:n #1 { \exp:w \__cdcmd_any_case_true:nTF {#1} { } { } }
+\cs_new:Npn \cdcmd_all_case_true:nTF { \exp:w \__cdcmd_all_case_true:nTF }
+\cs_new:Npn \cdcmd_all_case_true:n #1 { \exp:w \__cdcmd_all_case_true:nTF {#1} { } { } }
+\cs_new:Npn \cdcmd_any_case_false:nTF { \exp:w \__cdcmd_any_case_false:nTF }
+\cs_new:Npn \cdcmd_any_case_false:n #1 { \exp:w \__cdcmd_any_case_false:nTF {#1} { } { } }
+\cs_new:Npn \cdcmd_all_case_false:nTF { \exp:w \__cdcmd_all_case_false:nTF }
+\cs_new:Npn \cdcmd_all_case_false:n #1 { \exp:w \__cdcmd_all_case_false:nTF {#1} { } { } }
+\cs_new:Npn \__cdcmd_any_case_true:nTF #1#2#3
+ {
+ \__cdcmd_case:Nw \cdcmd_any_if:nTF #1 { * } { }
+ \s__cdcmd_mark {#2} \s__cdcmd_mark {#3} \s__cdcmd_stop
+ }
+\cs_new:Npn \__cdcmd_all_case_true:nTF #1#2#3
+ {
+ \__cdcmd_case:Nw \cdcmd_all_if:nTF #1 { * } { }
+ \s__cdcmd_mark {#2} \s__cdcmd_mark {#3} \s__cdcmd_stop
+ }
+\cs_new:Npn \__cdcmd_any_case_false:nTF #1#2#3
+ {
+ \__cdcmd_case:Nw \cdcmd_any_if:nFT #1 { * } { }
+ \s__cdcmd_mark {#2} \s__cdcmd_mark {#3} \s__cdcmd_stop
+ }
+\cs_new:Npn \__cdcmd_all_case_false:nTF #1#2#3
+ {
+ \__cdcmd_case:Nw \cdcmd_all_if:nFT #1 { * } { }
+ \s__cdcmd_mark {#2} \s__cdcmd_mark {#3} \s__cdcmd_stop
+ }
+\cs_new:Npn \__cdcmd_case:Nw #1#2#3
+ { #1 {#2} { \__cdcmd_case_end:nw {#3} } { \__cdcmd_case:Nw #1 } }
+\cs_new:Npn \__cdcmd_case_end:nw #1#2#3 \s__cdcmd_mark #4#5 \s__cdcmd_stop
+ { \exp_end: #1 #4 }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\newcondition,\setcondition,\clearcondition}
+% Conditional setting command for document.
+% \begin{macrocode}
+\NewDocumentCommand \newcondition { >{ \TrimSpaces } m } { \cdcmd_new:nn {#1} }
+\NewDocumentCommand \setcondition { t+ }
+ { \IfBooleanTF {#1} { \cdcmd_set:n } { \cdcmd_clear_set:n } }
+\NewDocumentCommand \clearcondition { !O{*} }
+ {
+ \clist_map_inline:nn {#1}
+ {
+ \str_if_eq:eeTF {##1} { \c_cdcmd_all_str }
+ {
+ \clist_map_break:n
+ { \exp_after:wN \clearcondition \exp_after:wN [ \g__cdcmd_clist ] }
+ }
+ {
+ \cdcmd_if_exist:nTF {##1}
+ { \clist_clear:c { l__cdcmd_curr_condition@ ##1 _clist } }
+ { \msg_warning:nnn { cdcmd } { condition-not-exist } {##1} }
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\NewExpandableDocumentCommand \econditionif { s O{*} +m +m }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_if:nTF }
+ { \cdcmd_any_if:nTF }
+ {#2} {#3} {#4}
+ }
+\NewExpandableDocumentCommand \econditioncmd { s O{*} +m }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_if:nTF }
+ { \cdcmd_any_if:nTF }
+ {#2} {#3} { }
+ }
+\NewExpandableDocumentCommand \econditioncase { s +m }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_case:n {#2} }
+ { \cdcmd_any_case:n {#2} }
+ }
+\NewExpandableDocumentCommand \econditioncaseTF { s +m }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_case:nTF {#2} }
+ { \cdcmd_any_case:nTF {#2} }
+ }
+\NewDocumentCommand \conditionif { s O{*} +m +m }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_if:nTF }
+ { \cdcmd_any_if:nTF }
+ {#2} {#3} {#4}
+ }
+\NewDocumentCommand \conditioncmd { s O{*} +m }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_if:nTF }
+ { \cdcmd_any_if:nTF }
+ {#2} {#3} { }
+ }
+\NewDocumentCommand \conditioncase { s t! +m }
+ {
+ \IfBooleanTF {#2}
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_case_false:n {#3} }
+ { \cdcmd_any_case_false:n {#3} }
+ }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_case_true:n {#3} }
+ { \cdcmd_any_case_true:n {#3} }
+ }
+ }
+\NewDocumentCommand \conditioncaseTF { s t! +m }
+ {
+ \IfBooleanTF {#2}
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_case_false:nTF {#3} }
+ { \cdcmd_any_case_false:nTF {#3} }
+ }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_case_true:nTF {#3} }
+ { \cdcmd_any_case_true:nTF {#3} }
+ }
+ }
+% \end{macrocode}
+% \begin{macro}{}
+% Define new \pkg{xparse} like conditional command.
+% \begin{macrocode}
+\str_const:Nn \c_cdcmd_pair_u_str { cdcmd@u@ }
+\str_const:Nn \c_cdcmd_pair_n_str { cdcmd@n@ }
+\cs_new_nopar:Npn \__cdcmd_cs_pair_u:N #1
+ { \c_cdcmd_pair_u_str \cs_to_str:N #1 }
+\cs_new_nopar:Npn \__cdcmd_cs_pair_n:N #1
+ { \c_cdcmd_pair_n_str \cs_to_str:N #1 }
+\cs_new:Npn \__cdcmd_arg_spec_from_num:nn #1#2
+ {
+ \if_case:w 0#1 \exp_stop_f:
+ \or: #2 \or: #2#2 \or: #2#2#2 \or: #2#2#2#2 \or: #2#2#2#2#2 \or: #2#2#2#2#2#2
+ \or: #2#2#2#2#2#2#2 \or: #2#2#2#2#2#2#2#2 \else: #2#2#2#2#2#2#2#2#2 \fi:
+ }
+\cs_new_nopar:Npn \__cdcmd_cs_pair_u:Nn #1#2
+ {
+ \c_cdcmd_pair_u_str
+ \cs_to_str:N #1 :
+ \__cdcmd_arg_spec_from_num:nn {#2} { n }
+ }
+\cs_new_nopar:Npn \__cdcmd_cs_pair_n:Nn #1#2
+ {
+ \c_cdcmd_pair_n_str
+ \cs_to_str:N #1 :
+ \__cdcmd_arg_spec_from_num:nn {#2} { n }
+ }
+% do not check cs_if_free, let xparse do it
+\cs_new:Npn \__cdcmd_new_cdcmd_command:NN #1#2
+ {
+ \cs_new_protected:Npn #1 ##1##2##3
+ {
+ #2 ##1 { t+ m }
+ {
+ \IfBooleanTF {####1}
+ { \cdcmd_all_if:nTF }
+ { \cdcmd_any_if:nTF }
+ {####2}
+ { \use:c { \__cdcmd_cs_pair_u:N ##1 } }
+ { \use:c { \__cdcmd_cs_pair_n:N ##1 } }
+ }
+ \exp_args:Nc #2
+ { \__cdcmd_cs_pair_u:N ##1 } {##2} {##3}
+ \exp_args:Nc #2
+ { \__cdcmd_cs_pair_n:N ##1 } {##2} { }
+ }
+ }
+\seq_const_from_clist:Nn \c__cdcmd_Command_seq
+ {
+ \NewDocumentCommand ,
+ \RenewDocumentCommand ,
+ \ProvideDocumentCommand ,
+ \DeclareDocumentCommand ,
+ \NewExpandableDocumentCommand ,
+ \RenewExpandableDocumentCommand ,
+ \ProvideExpandableDocumentCommand ,
+ \DeclareExpandableDocumentCommand ,
+ }
+\seq_const_from_clist:Nn \c__cdcmd_COMMAND_seq
+ {
+ \NewConditionCommand ,
+ \RenewConditionCommand ,
+ \ProvideConditionCommand ,
+ \DeclareConditionCommand ,
+ \NewExpandableConditionCommand ,
+ \RenewExpandableConditionCommand ,
+ \ProvideExpandableConditionCommand ,
+ \DeclareExpandableConditionCommand ,
+ }
+\seq_mapthread_function:NNN
+ \c__cdcmd_COMMAND_seq
+ \c__cdcmd_Command_seq
+ \__cdcmd_new_cdcmd_command:NN
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{}
+% Define \LaTeX{} like command.
+% \begin{macrocode}
+% do not check cs_if_free, let xparse do it
+\cs_new:Npn \__cdcmd_new_cdcmd_cmd_no:nnn #1#2#3
+ {
+ \cs_new_protected:Npn #1 ##1##2##3
+ {
+ #3 ##1 { t+ m }
+ {
+ \IfBooleanTF {####1}
+ { \cdcmd_all_if:nTF }
+ { \cdcmd_any_if:nTF }
+ { ####2 }
+ { \use:c { \__cdcmd_cs_pair_u:Nn ##1 {##2} } }
+ { \use:c { \__cdcmd_cs_pair_n:Nn ##1 {##2} } }
+ }
+ #2 { \__cdcmd_cs_pair_u:Nn ##1 {##2} } {##3}
+ #2 { \__cdcmd_cs_pair_n:Nn ##1 {##2} } { }
+ }
+ }
+\cs_generate_variant:Nn \__cdcmd_new_cdcmd_cmd_no:nnn { xxx }
+\seq_const_from_clist:Nn \c__cdcmd_cmd_no_seq
+ {
+ \cs_set_protected:cn , \cs_set_protected_nopar:cn ,
+ \cs_set_protected:cn , \cs_set_protected_nopar:cn ,
+ \cs_set_protected:cn , \cs_set_protected_nopar:cn ,
+ \cs_set:cn , \cs_set_nopar:cn ,
+ \cs_set:cn , \cs_set_nopar:cn ,
+ \cs_set:cn , \cs_set_nopar:cn ,
+ }
+\seq_const_from_clist:Nn \c__cdcmd_Cmd_no_seq
+ {
+ \NewDocumentCommand , \NewDocumentCommand ,
+ \RenewDocumentCommand , \RenewDocumentCommand ,
+ \DeclareDocumentCommand , \DeclareDocumentCommand ,
+ \NewExpandableDocumentCommand , \NewExpandableDocumentCommand ,
+ \RenewExpandableDocumentCommand , \RenewExpandableDocumentCommand ,
+ \DeclareExpandableDocumentCommand , \DeclareExpandableDocumentCommand ,
+ }
+\seq_const_from_clist:Nn \c__cdcmd_CMD_no_seq
+ {
+ \__cdcmd_new_cdcmd_p_l_num:Nnn , \__cdcmd_new_cdcmd_p_nl_num:Nnn ,
+ \__cdcmd_renew_cdcmd_p_l_num:Nnn , \__cdcmd_renew_cdcmd_p_nl_num:Nnn ,
+ \__cdcmd_declare_cdcmd_p_l_num:Nnn , \__cdcmd_declare_cdcmd_p_nl_num:Nnn ,
+ \__cdcmd_new_cdcmd_np_l_num:Nnn , \__cdcmd_new_cdcmd_np_nl_num:Nnn ,
+ \__cdcmd_renew_cdcmd_np_l_num:Nnn , \__cdcmd_renew_cdcmd_np_nl_num:Nnn ,
+ \__cdcmd_declare_cdcmd_np_l_num:Nnn , \__cdcmd_declare_cdcmd_np_nl_num:Nnn ,
+ }
+\int_step_inline:nn { 6 }
+ {
+ \__cdcmd_new_cdcmd_cmd_no:xxx
+ { \seq_item:Nn \c__cdcmd_CMD_no_seq {#1} }
+ { \seq_item:Nn \c__cdcmd_cmd_no_seq {#1} }
+ { \seq_item:Nn \c__cdcmd_Cmd_no_seq {#1} }
+ }
+\tl_new:N \l__cdcmd_arg_spec_tl
+\cs_new:Npn \__cdcmd_generate_arg_spec:nnn #1#2#3
+ {
+ \tl_set:Nn \l__cdcmd_arg_spec_tl { O{#2} }
+ \if_int_compare:w #1 > 1 \exp_stop_f:
+ \int_step_inline:nn {#1-1} { \tl_put_right:Nn \l__cdcmd_arg_spec_tl {#3} }
+ \fi:
+ }
+\cs_new:Npn \__cdcmd_new_cdcmd_cmd_o_aux:nn #1#2
+ {
+ \cs_new_protected:Npn #1 ##1##2##3##4##5
+ {
+ #2 ##1 { t+ m }
+ {
+ \IfBooleanTF{####1}
+ { \cdcmd_all_if:nTF }
+ { \cdcmd_any_if:nTF }
+ {####2}
+ { \use:c { \__cdcmd_cs_pair_u:N ##1 } }
+ { \use:c { \__cdcmd_cs_pair_n:N ##1 } }
+ }
+ \__cdcmd_generate_arg_spec:nnn {##2} {##3} {##5}
+ \exp_args:NcV #2 { \__cdcmd_cs_pair_u:N ##1 } \l__cdcmd_arg_spec_tl {##4}
+ \exp_args:NcV #2 { \__cdcmd_cs_pair_n:N ##1 } \l__cdcmd_arg_spec_tl { }
+ }
+ }
+\seq_const_from_clist:Nn \c__cdcmd_CMD_o_seq
+ { \NewDocumentCommand , \RenewDocumentCommand , \DeclareDocumentCommand }
+\seq_const_from_clist:Nn \c__cdcmd_cmd_o_seq
+ {
+ \__cdcmd_new_cdcmd_o_num:Nnnnn ,
+ \__cdcmd_renew_cdcmd_o_num:Nnnnn ,
+ \__cdcmd_declare_cdcmd_o_num:Nnnnn ,
+ }
+\seq_mapthread_function:NNN
+ \c__cdcmd_cmd_o_seq
+ \c__cdcmd_CMD_o_seq
+ \__cdcmd_new_cdcmd_cmd_o_aux:nn
+\cs_new_protected:Npn \__cdcmd_new_cdcmd_cmd_ne_aux:n #1
+ {
+ \exp_args:Nc \NewDocumentCommand { #1 conditioncommand } { s m O{0} o +m }
+ {
+ \IfBooleanTF{##1}
+ {
+ \IfNoValueTF{##4}
+ { \use:c { __cdcmd_ #1 _cdcmd_p_nl_num:Nnn } ##2 {##3} {##5} }
+ { \use:c { __cdcmd_ #1 _cdcmd_o_num:Nnnnn } ##2 {##3} {##4} {##5} { m } }
+ }
+ {
+ \IfNoValueTF{##4}
+ { \use:c { __cdcmd_ #1 _cdcmd_p_l_num:Nnn } ##2 {##3} {##5} }
+ { \use:c { __cdcmd_ #1 _cdcmd_o_num:Nnnnn } ##2 {##3} {##4} {##5} { +m } }
+ }
+ }
+ }
+\clist_map_function:nN { new, renew, declare } \__cdcmd_new_cdcmd_cmd_ne_aux:n
+\NewDocumentCommand \provideconditioncommand { s m O{0} o +m }
+ {
+ \cs_if_free:NT #2
+ {
+ \IfBooleanTF{#1}
+ {
+ \IfNoValueTF{#4}
+ { \newconditioncommand * #2 [#3] {#5} }
+ { \newconditioncommand * #2 [#3] [#4] {#5} }
+ }
+ {
+ \IfNoValueTF{#4}
+ { \newconditioncommand #2 [#3] {#5} }
+ { \newconditioncommand #2 [#3] [#4] {#5} }
+ }
+ }
+ }
+
+\int_step_inline:nnnn { 7 } { 1 } { 12 }
+ {
+ \__cdcmd_new_cdcmd_cmd_no:xxx
+ { \seq_item:Nn \c__cdcmd_CMD_no_seq {#1} }
+ { \seq_item:Nn \c__cdcmd_cmd_no_seq {#1} }
+ { \seq_item:Nn \c__cdcmd_Cmd_no_seq {#1} }
+ }
+
+\cs_new_protected:Npn \__cdcmd_new_cdcmd_cmd_e_no_aux:n #1
+ {
+ \exp_args:Nc \NewDocumentCommand { #1 econditioncommand } { s m O{0} +m }
+ {
+ \IfBooleanTF{##1}
+ { \use:c { __cdcmd_ #1 _cdcmd_np_nl_num:Nnn } ##2 {##3} {##4} }
+ { \use:c { __cdcmd_ #1 _cdcmd_np_l_num:Nnn } ##2 {##3} {##4} }
+ }
+ }
+\clist_map_function:nN { new, renew, declare } \__cdcmd_new_cdcmd_cmd_e_no_aux:n
+\NewDocumentCommand \provideeconditioncommand { s m O{0} +m }
+ {
+ \cs_if_free:NT #2
+ {
+ \IfBooleanTF{#1}
+ { \neweconditioncommand * #2 [#3] {#4} }
+ { \neweconditioncommand #2 [#2] {#4} }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+%</package>
+% \end{macrocode}
+%
+% \end{implementation}
+%
+% \endinput
+%
+%<*test>
+{\color{red!90!black}
+\begin{verbatim}
+ \newcondition{defined}{}
+ \newcondition{paper}{a4,a5,b5}
+ \setcondition{paper={a5,b5}}
+\end{verbatim}
+}
+
+{
+\newcondition{defined}{}
+\newcondition{paper}{a4,a5,b5}
+\setcondition{paper={a5,b5}}
+\def\cdcmdtest#1->#2 /{\textcolor{red!90!black}{\detokenize{#1}}:~ #1 \newline}
+\parindent=0pt\ttfamily
+\cdcmdtest\conditionif[*]{t}{f}->t /
+\cdcmdtest\conditionif[defined]{t}{f}->t /
+\cdcmdtest\conditionif[defined=]{t}{f}->f /
+\cdcmdtest\conditionif[defined=*]{t}{f}->t /
+\cdcmdtest\conditionif[defined=a]{t}{f}->f /
+\cdcmdtest\conditionif[paper={a5,a0},undefined]{t}{f}->t /
+
+\cdcmdtest\conditionif*[*]{t}{f}->t /
+\cdcmdtest\conditionif*[defined]{t}{f}->t /
+\cdcmdtest\conditionif*[defined={,,}]{t}{f}->f /
+\cdcmdtest\conditionif*[defined=*]{t}{f}->t /
+\cdcmdtest\conditionif*[defined=a]{t}{f}->f /
+\cdcmdtest\conditionif*[paper={a5,a0},undefined]{t}{f}->f /
+\cdcmdtest\conditionif*[*,undefined]{t}{f}->f /
+\cdcmdtest\conditionif*[paper={a5,b5}]{t}{f}->t /
+\cdcmdtest\conditionif*[paper={a5,,b5}]{t}{f}->t /
+\cdcmdtest\conditionif*[paper={a5,b6,a5}]{t}{f}->f /
+\cdcmdtest\conditionif*[paper={a5,{ },45}]{t}{f}->f /
+\cdcmdtest\conditionif*[*,defined,paper={a5,b5}]{t}{f}->t /
+}
+
+{\color{red!90!black}
+\begin{verbatim}
+ \def\truetext{true} \def\falsetext{false}
+ \edef\testa{\econditionif[*]{true}{false}}
+ \ifx\testa\truetext t\else f\fi
+ \ifx\testa\falsetext t\else f\fi
+ \strcmp {\econditionif[*]{true}{false}} {true}
+ \strcmp {\econditionif[*]{true}{false}} {false}
+ \strcmp {\testa} {\truetext}
+ \strcmp {\testa} {\falsetext}
+\end{verbatim}
+}
+\def\truetext{true} \def\falsetext{false}
+\edef\testa{\econditionif[*]{true}{false}}
+\ifx\testa\truetext t\else f\fi
+\ifx\testa\falsetext t\else f\fi
+\strcmp{\econditionif[*]{true}{false}}{true}
+\strcmp{\econditionif[*]{true}{false}}{false}
+\strcmp{\testa}{\truetext}
+\strcmp{\testa}{\falsetext}
+
+{\color{red!90!black}
+\begin{verbatim}
+ \conditioncase{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+ }
+\end{verbatim}
+}
+\conditioncase{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+}
+
+{\color{red!90!black}
+\begin{verbatim}
+ \conditioncaseTF{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+ }{true}{false}
+\end{verbatim}
+}
+\conditioncaseTF{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+}{true}{false}
+
+{\color{red!90!black}
+\begin{verbatim}
+ \conditioncase!{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+ }
+\end{verbatim}
+}
+\conditioncase!{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+}
+
+{\color{red!90!black}
+\begin{verbatim}
+ \conditioncaseTF!{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+ }{true}{false}
+\end{verbatim}
+}
+\conditioncaseTF!{
+ {paper=a3} {a3}
+ {paper=a4} {a4}
+ {paper,defined} {pd}
+}{true}{false}
+
+{\color{red!90!black}
+\begin{verbatim}
+ \newconditioncommand\longprotectedcdcmd{longprotectedcdcmd}
+ \newconditioncommand\longprotectedcdcmdi[1]{longprotectedcdcmdi<#1>}
+ \newconditioncommand\longprotectedcdcmdio[1][DFT]{longprotectedcdcmdio<#1>}
+ \newconditioncommand*\shortprotectedcdcmd{shortprotectedcdcmd}
+ \newconditioncommand*\shortprotectedcdcmdi[1]{shortprotectedcdcmdi<#1>}
+ \newconditioncommand*\shortprotectedcdcmdio[1][DFT]{shortprotectedcdcmdio<#1>}
+
+ \setcondition{paper={a4,a5}}
+ \longprotectedcdcmd{*}
+ \longprotectedcdcmdi{*}{1\par arg}
+ \longprotectedcdcmdio{*}
+ \longprotectedcdcmdio{*}[1opt]
+ \longprotectedcdcmdio{paper=a4}[1opt a4]
+ \longprotectedcdcmdio+{paper={a4,a7}}[1opt a4a7]
+ \shortprotectedcdcmd{*}
+ \shortprotectedcdcmdi{*}{1\par arg}
+ \shortprotectedcdcmdio{*}
+ \shortprotectedcdcmdio{*}[1opt]
+ \shortprotectedcdcmdio{paper=a4}[1opt a4]
+ \shortprotectedcdcmdio+{paper={a4,a7}}[1opt a4a7]
+\end{verbatim}
+}
+\newconditioncommand\longprotectedcdcmd{longprotectedcdcmd}
+\newconditioncommand\longprotectedcdcmdi[1]{longprotectedcdcmdi<#1>}
+\newconditioncommand\longprotectedcdcmdio[1][DFT]{longprotectedcdcmdio<#1>}
+\newconditioncommand*\shortprotectedcdcmd{shortprotectedcdcmd}
+\newconditioncommand*\shortprotectedcdcmdi[1]{shortprotectedcdcmdi<#1>}
+\newconditioncommand*\shortprotectedcdcmdio[1][DFT]{shortprotectedcdcmdio<#1>}
+
+{\ttfamily\setcondition{paper={a4,a5}}\obeylines
+\longprotectedcdcmd{*}
+\longprotectedcdcmdi{*}{1\par arg}
+\longprotectedcdcmdio{*}
+\longprotectedcdcmdio{*}[1opt]
+\longprotectedcdcmdio{paper=a4}[1opt a4]
+\longprotectedcdcmdio+{paper={a4,a7}}[1opt a4a7]
+\shortprotectedcdcmd{*}
+\shortprotectedcdcmdi{*}{1arg}
+\shortprotectedcdcmdio{*}
+\shortprotectedcdcmdio{*}[1opt]
+\shortprotectedcdcmdio{paper=a4}[1opt a4]
+\shortprotectedcdcmdio+{paper={a4,a7}}[1opt a4a7]
+}
+%</test> \ No newline at end of file
diff --git a/Master/texmf-dist/source/latex/cdcmd/cdcmd.ins b/Master/texmf-dist/source/latex/cdcmd/cdcmd.ins
new file mode 100644
index 00000000000..7031179eb6f
--- /dev/null
+++ b/Master/texmf-dist/source/latex/cdcmd/cdcmd.ins
@@ -0,0 +1,73 @@
+%% Copyright (C) 2021--2021
+%% Wenjian Chern (Longaster) and any individual authors listed elsewhere in this file.
+%% --------------------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.3c of this license or (at your option) any later
+%% version. This version of this license is in
+%% http://www.latex-project.org/lppl/lppl-1-3c.txt
+%% and the latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of
+%% LaTeX version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainers of this work are Wenjian Chern (Longaster).
+%% --------------------------------------------------------------------------
+\input l3docstrip.tex %
+\askforoverwritefalse
+\keepsilent
+\preamble
+
+ Copyright (C) 2021--2021
+ Wenjian Chern (Longaster) and any individual authors listed elsewhere in this file.
+ --------------------------------------------------------------------------
+
+ This work may be distributed and/or modified under the
+ conditions of the LaTeX Project Public License, either
+ version 1.3c of this license or (at your option) any later
+ version. This version of this license is in
+ http://www.latex-project.org/lppl/lppl-1-3c.txt
+ and the latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+ and version 1.3 or later is part of all distributions of
+ LaTeX version 2005/12/01 or later.
+
+ This work has the LPPL maintenance status `maintained'.
+
+ The Current Maintainers of this work are Wenjian Chern (Longaster).
+ --------------------------------------------------------------------------
+
+\endpreamble
+
+\postamble
+
+ This work consists of the file cdcmd.dtx,
+ and the derived files cdcmd.pdf,
+ cdcmd.sty,
+ cdcmd-cn.tex,
+ cdcmd-cn.pdf,
+ cdcmd-test.tex,
+ cdcmd.ins and
+ README.md
+\endpostamble
+
+\generate{
+ \usedir{tex/latex/cdcmd}
+ \file{cdcmd.sty} {\from{\jobname.dtx}{package}}
+ \nopreamble\nopostamble
+ \usedir{tex/latex/cdcmd}
+ \file{cdcmd-test.tex}{\from{\jobname.dtx}{test}}
+ \file{README.md} {\from{\jobname.dtx}{readme}}
+}
+
+\endbatchfile
+%%
+%% This work consists of the file cdcmd.dtx,
+%% and the derived files cdcmd.pdf,
+%% cdcmd.sty,
+%% cdcmd.ins and
+%% README.md
+%% End of file `cdcmd.ins'. \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/cdcmd/cdcmd.sty b/Master/texmf-dist/tex/latex/cdcmd/cdcmd.sty
new file mode 100644
index 00000000000..75373f91153
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/cdcmd/cdcmd.sty
@@ -0,0 +1,571 @@
+%%
+%% This is file `cdcmd.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% cdcmd.dtx (with options: `package')
+%%
+%% Copyright (C) 2021--2021
+%% Wenjian Chern (Longaster) and any individual authors listed elsewhere in this file.
+%% --------------------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.3c of this license or (at your option) any later
+%% version. This version of this license is in
+%% http://www.latex-project.org/lppl/lppl-1-3c.txt
+%% and the latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of
+%% LaTeX version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainers of this work are Wenjian Chern (Longaster).
+%% --------------------------------------------------------------------------
+%%
+\NeedsTeXFormat{LaTeX2e}
+\RequirePackage{expl3}[2021/05/11]
+\GetIdInfo$Id: cdcmd.dtx 1.0 2021/10/12 +0815 Longaster$
+ {Expandable Conditional Command In LaTeX2e}
+\ProvidesExplPackage{cdcmd}
+ {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
+\str_const:Nn \c_cdcmd_all_str { * }
+\clist_new:N \g__cdcmd_clist
+\bool_new:N \l__cdcmd_clear_set_bool
+\msg_new:nnn { cdcmd } { condition-exist }
+ { The~ condition~ `#1'~ you~ try~ to~ new~ already~ exists. }
+\msg_new:nnn { cdcmd } { condition-not-exist }
+ { The~ condition~ `#1'~ not~ exists. }
+\msg_new:nnn { cdcmd } { condition-id-not-exist }
+ { The~ id~ `#2' of~ condition~ `#1'~ not~ exists. }
+\prg_new_conditional:Npnn \cdcmd_if_exist:n #1 { p, T, F, TF }
+ {
+ \clist_if_exist:cTF { c__cdcmd_condition@ #1 _clist }
+ { \prg_return_true: } { \prg_return_false: }
+ }
+\prg_new_conditional:Npnn \cdcmd_cd_id_if_exist:nn #1#2 { T, F, TF }
+ {
+ \clist_if_in:cnTF { c__cdcmd_condition@ #1 _clist } {#2}
+ { \prg_return_true: } { \prg_return_false: }
+ }
+\cs_new_nopar:Npn \cdcmd_new:nn #1#2
+ {
+ \cdcmd_if_exist:nTF {#1}
+ { \msg_error:nnn { cdcmd } { condition-exist } {#1} }
+ {
+ \clist_gput_right:Nn \g__cdcmd_clist {#1}
+ \clist_const:cn { c__cdcmd_condition@ #1 _clist } {#2}
+ \clist_new:c { l__cdcmd_curr_condition@ #1 _clist }
+ }
+ }
+\cs_new_nopar:Npn \cdcmd_set:nn #1#2
+ {
+ \cdcmd_if_exist:nTF {#1}
+ {
+ \bool_if:NT \l__cdcmd_clear_set_bool
+ { \clist_clear:c { l__cdcmd_curr_condition@ #1 _clist } }
+ \clist_map_inline:nn {#2}
+ {
+ \str_if_eq:eeTF {##1} { \c_cdcmd_all_str }
+ { \clist_map_break:n { \cdcmd_set_cdcmd_all:n {#1} } }
+ { \cdcmd_set_cdcmd_single:nn {#1} {##1} }
+ }
+ }
+ { \msg_warning:nnn { cdcmd } { condition-not-exist } {#1} }
+ }
+\cs_new_nopar:Npn \cdcmd_set_cdcmd_single:nn #1#2
+ {
+ \cdcmd_if_exist:nTF {#1}
+ {
+ \cdcmd_cd_id_if_exist:nnTF {#1} {#2}
+ { \clist_put_right:cn { l__cdcmd_curr_condition@ #1 _clist } {#2} }
+ { \msg_warning:nnnn { cdcmd } { condition-id-not-exist } {#1} {#2} }
+ }
+ { \msg_warning:nnn { cdcmd } { condition-not-exist } }
+ }
+\cs_new_nopar:Npn \cdcmd_set_cdcmd_all:n #1
+ {
+ \cdcmd_if_exist:nTF {#1}
+ {
+ \clist_set_eq:cc
+ { l__cdcmd_curr_condition@ #1 _clist }
+ { c__cdcmd_condition@ #1 _clist }
+ }
+ { \msg_warning:nnn { cdcmd } { condition-not-exist } {#1} }
+ }
+\cs_new_nopar:Npn \cdcmd_set:n
+ { \keyval_parse:NNn \cdcmd_set_cdcmd_all:n \cdcmd_set:nn }
+\cs_new_nopar:Npn \cdcmd_clear_set:n #1
+ {
+ \bool_set_true:N \l__cdcmd_clear_set_bool
+ \keyval_parse:NNn \cdcmd_set_cdcmd_all:n \cdcmd_set:nn {#1}
+ \bool_set_false:N \l__cdcmd_clear_set_bool
+ }
+\cs_new:Npn \cdcmd_any_if:nTF #1
+ {
+ \bool_if:nTF
+ {
+ \keyval_parse:NNn
+ \__cdcmd_any_i:n \__cdcmd_any_ii:nn {#1}
+ \c_false_bool
+ }
+ }
+\cs_new:Npn \cdcmd_any_if_p:n #1
+ {
+ \bool_if_p:n
+ {
+ \keyval_parse:NNn
+ \__cdcmd_any_i:n \__cdcmd_any_ii:nn {#1}
+ \c_false_bool
+ }
+ }
+\cs_new:Npn \cdcmd_any_if:nT #1#2 { \cdcmd_any_if:nTF {#1} {#2} { } }
+\cs_new:Npn \cdcmd_any_if:nF #1 { \cdcmd_any_if:nTF {#1} { } }
+\cs_new:Npn \cdcmd_any_if:nFT #1#2#3 { \cdcmd_any_if:nTF {#1} {#3} {#2} }
+\prg_generate_conditional_variant:Nnn \cdcmd_any_if:n { o, V, f } { p, T, F, TF }
+\cs_new:Npn \__cdcmd_any_i:n #1
+ {
+ \str_if_eq:eeTF {#1} { \c_cdcmd_all_str }
+ { \c_true_bool || }
+ { \cdcmd_if_exist:nT {#1} { \c_true_bool || } }
+ }
+\cs_new:Npn \__cdcmd_any_ii:nn #1#2
+ {
+ \cdcmd_if_exist:nT {#1}
+ {
+ \clist_map_tokens:nn {#2}
+ { \__cdcmd_any_ii_aux:nn {#1} }
+ }
+ }
+\cs_new:Npn \__cdcmd_any_ii_aux:nn #1#2
+ {
+ \str_if_eq:eeTF {#2} { \c_cdcmd_all_str }
+ { \clist_map_break:n { \tex_the:D \c_true_bool || } }
+ {
+ \__cdcmd_clist_if_in:cnT { l__cdcmd_curr_condition@ #1 _clist } {#2}
+ { \clist_map_break:n { \tex_the:D \c_true_bool || } }
+ }
+ }
+\cs_new:Npn \cdcmd_all_if:nTF #1
+ {
+ \bool_if:nTF
+ {
+ \keyval_parse:NNn
+ \__cdcmd_all_i:n \__cdcmd_all_ii:nn {#1}
+ \c_true_bool
+ }
+ }
+\cs_new:Npn \cdcmd_all_if_p:n #1
+ {
+ \bool_if_p:n
+ {
+ \keyval_parse:NNn
+ \__cdcmd_all_i:n \__cdcmd_all_ii:nn {#1}
+ \c_true_bool
+ }
+ }
+\cs_new:Npn \cdcmd_all_if:nT #1#2 { \cdcmd_all_if:nTF {#1} {#2} { } }
+\cs_new:Npn \cdcmd_all_if:nF #1 { \cdcmd_all_if:nTF {#1} { } }
+\cs_new:Npn \cdcmd_all_if:nFT #1#2#3 { \cdcmd_all_if:nTF {#1} {#3} {#2} }
+\prg_generate_conditional_variant:Nnn \cdcmd_all_if:n { o, V, f } { p, T, F, TF }
+\cs_new:Npn \__cdcmd_all_i:n #1
+ {
+ \str_if_eq:eeF {#1} { \c_cdcmd_all_str }
+ { \cdcmd_if_exist:nF {#1} { \c_false_bool && } }
+ }
+\cs_new:Npn \__cdcmd_all_ii:nn #1#2
+ {
+ \cdcmd_if_exist:nTF {#1}
+ {
+ \bool_lazy_and_p:nn
+ { \int_compare_p:n { \clist_count:n {#2} > 0 } }
+ {
+ \int_compare_p:n
+ { \clist_map_tokens:nn {#2} { \__cdcmd_all_ii_aux:nn {#1} } 1 > 0 }
+ } &&
+ }
+ { \c_false_bool && }
+ }
+\cs_new:Npn \__cdcmd_all_ii_aux:nn #1#2
+ {
+ \str_if_eq:eeF {#2} { \c_cdcmd_all_str }
+ {
+ \__cdcmd_clist_if_in:cnF { l__cdcmd_curr_condition@ #1 _clist } {#2}
+ { \clist_map_break:n { - } }
+ }
+ }
+\prg_new_conditional:Npnn \__cdcmd_clist_if_in:Nn #1#2 { p, T, F, TF }
+ {
+ \int_compare:nTF
+ { 0 \clist_map_tokens:Nn #1 { \__cdcmd_if_eq_break:ee {#2} } > 0 }
+ { \prg_return_true: } { \prg_return_false: }
+ }
+\prg_generate_conditional_variant:Nnn \__cdcmd_clist_if_in:Nn
+ { NV, No, cn, cV, co } { p, T, F, TF }
+\prg_new_conditional:Npnn \__cdcmd_clist_if_in:nn #1#2 { p, T, F, TF }
+ {
+ \int_compare:nTF
+ { 0 \clist_map_tokens:nn {#1} { \__cdcmd_if_eq_break:ee {#2} } > 0 }
+ { \prg_return_true: } { \prg_return_false: }
+ }
+\prg_generate_conditional_variant:Nnn \__cdcmd_clist_if_in:nn { nV, no } { p, T, F, TF }
+\cs_new:Npn \__cdcmd_if_eq_break:ee #1#2
+ {
+ \str_if_eq:eeT {#1} {#2} { \clist_map_break:n { 1 } }
+ }
+\scan_new:N \s__cdcmd_mark
+\scan_new:N \s__cdcmd_stop
+\cs_new:Npn \cdcmd_any_case_true:nTF { \exp:w \__cdcmd_any_case_true:nTF }
+\cs_new:Npn \cdcmd_any_case_true:n #1 { \exp:w \__cdcmd_any_case_true:nTF {#1} { } { } }
+\cs_new:Npn \cdcmd_all_case_true:nTF { \exp:w \__cdcmd_all_case_true:nTF }
+\cs_new:Npn \cdcmd_all_case_true:n #1 { \exp:w \__cdcmd_all_case_true:nTF {#1} { } { } }
+\cs_new:Npn \cdcmd_any_case_false:nTF { \exp:w \__cdcmd_any_case_false:nTF }
+\cs_new:Npn \cdcmd_any_case_false:n #1 { \exp:w \__cdcmd_any_case_false:nTF {#1} { } { } }
+\cs_new:Npn \cdcmd_all_case_false:nTF { \exp:w \__cdcmd_all_case_false:nTF }
+\cs_new:Npn \cdcmd_all_case_false:n #1 { \exp:w \__cdcmd_all_case_false:nTF {#1} { } { } }
+\cs_new:Npn \__cdcmd_any_case_true:nTF #1#2#3
+ {
+ \__cdcmd_case:Nw \cdcmd_any_if:nTF #1 { * } { }
+ \s__cdcmd_mark {#2} \s__cdcmd_mark {#3} \s__cdcmd_stop
+ }
+\cs_new:Npn \__cdcmd_all_case_true:nTF #1#2#3
+ {
+ \__cdcmd_case:Nw \cdcmd_all_if:nTF #1 { * } { }
+ \s__cdcmd_mark {#2} \s__cdcmd_mark {#3} \s__cdcmd_stop
+ }
+\cs_new:Npn \__cdcmd_any_case_false:nTF #1#2#3
+ {
+ \__cdcmd_case:Nw \cdcmd_any_if:nFT #1 { * } { }
+ \s__cdcmd_mark {#2} \s__cdcmd_mark {#3} \s__cdcmd_stop
+ }
+\cs_new:Npn \__cdcmd_all_case_false:nTF #1#2#3
+ {
+ \__cdcmd_case:Nw \cdcmd_all_if:nFT #1 { * } { }
+ \s__cdcmd_mark {#2} \s__cdcmd_mark {#3} \s__cdcmd_stop
+ }
+\cs_new:Npn \__cdcmd_case:Nw #1#2#3
+ { #1 {#2} { \__cdcmd_case_end:nw {#3} } { \__cdcmd_case:Nw #1 } }
+\cs_new:Npn \__cdcmd_case_end:nw #1#2#3 \s__cdcmd_mark #4#5 \s__cdcmd_stop
+ { \exp_end: #1 #4 }
+\NewDocumentCommand \newcondition { >{ \TrimSpaces } m } { \cdcmd_new:nn {#1} }
+\NewDocumentCommand \setcondition { t+ }
+ { \IfBooleanTF {#1} { \cdcmd_set:n } { \cdcmd_clear_set:n } }
+\NewDocumentCommand \clearcondition { !O{*} }
+ {
+ \clist_map_inline:nn {#1}
+ {
+ \str_if_eq:eeTF {##1} { \c_cdcmd_all_str }
+ {
+ \clist_map_break:n
+ { \exp_after:wN \clearcondition \exp_after:wN [ \g__cdcmd_clist ] }
+ }
+ {
+ \cdcmd_if_exist:nTF {##1}
+ { \clist_clear:c { l__cdcmd_curr_condition@ ##1 _clist } }
+ { \msg_warning:nnn { cdcmd } { condition-not-exist } {##1} }
+ }
+ }
+ }
+\NewExpandableDocumentCommand \econditionif { s O{*} +m +m }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_if:nTF }
+ { \cdcmd_any_if:nTF }
+ {#2} {#3} {#4}
+ }
+\NewExpandableDocumentCommand \econditioncmd { s O{*} +m }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_if:nTF }
+ { \cdcmd_any_if:nTF }
+ {#2} {#3} { }
+ }
+\NewExpandableDocumentCommand \econditioncase { s +m }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_case:n {#2} }
+ { \cdcmd_any_case:n {#2} }
+ }
+\NewExpandableDocumentCommand \econditioncaseTF { s +m }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_case:nTF {#2} }
+ { \cdcmd_any_case:nTF {#2} }
+ }
+\NewDocumentCommand \conditionif { s O{*} +m +m }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_if:nTF }
+ { \cdcmd_any_if:nTF }
+ {#2} {#3} {#4}
+ }
+\NewDocumentCommand \conditioncmd { s O{*} +m }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_if:nTF }
+ { \cdcmd_any_if:nTF }
+ {#2} {#3} { }
+ }
+\NewDocumentCommand \conditioncase { s t! +m }
+ {
+ \IfBooleanTF {#2}
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_case_false:n {#3} }
+ { \cdcmd_any_case_false:n {#3} }
+ }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_case_true:n {#3} }
+ { \cdcmd_any_case_true:n {#3} }
+ }
+ }
+\NewDocumentCommand \conditioncaseTF { s t! +m }
+ {
+ \IfBooleanTF {#2}
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_case_false:nTF {#3} }
+ { \cdcmd_any_case_false:nTF {#3} }
+ }
+ {
+ \IfBooleanTF {#1}
+ { \cdcmd_all_case_true:nTF {#3} }
+ { \cdcmd_any_case_true:nTF {#3} }
+ }
+ }
+\str_const:Nn \c_cdcmd_pair_u_str { cdcmd@u@ }
+\str_const:Nn \c_cdcmd_pair_n_str { cdcmd@n@ }
+\cs_new_nopar:Npn \__cdcmd_cs_pair_u:N #1
+ { \c_cdcmd_pair_u_str \cs_to_str:N #1 }
+\cs_new_nopar:Npn \__cdcmd_cs_pair_n:N #1
+ { \c_cdcmd_pair_n_str \cs_to_str:N #1 }
+\cs_new:Npn \__cdcmd_arg_spec_from_num:nn #1#2
+ {
+ \if_case:w 0#1 \exp_stop_f:
+ \or: #2 \or: #2#2 \or: #2#2#2 \or: #2#2#2#2 \or: #2#2#2#2#2 \or: #2#2#2#2#2#2
+ \or: #2#2#2#2#2#2#2 \or: #2#2#2#2#2#2#2#2 \else: #2#2#2#2#2#2#2#2#2 \fi:
+ }
+\cs_new_nopar:Npn \__cdcmd_cs_pair_u:Nn #1#2
+ {
+ \c_cdcmd_pair_u_str
+ \cs_to_str:N #1 :
+ \__cdcmd_arg_spec_from_num:nn {#2} { n }
+ }
+\cs_new_nopar:Npn \__cdcmd_cs_pair_n:Nn #1#2
+ {
+ \c_cdcmd_pair_n_str
+ \cs_to_str:N #1 :
+ \__cdcmd_arg_spec_from_num:nn {#2} { n }
+ }
+\cs_new:Npn \__cdcmd_new_cdcmd_command:NN #1#2
+ {
+ \cs_new_protected:Npn #1 ##1##2##3
+ {
+ #2 ##1 { t+ m }
+ {
+ \IfBooleanTF {####1}
+ { \cdcmd_all_if:nTF }
+ { \cdcmd_any_if:nTF }
+ {####2}
+ { \use:c { \__cdcmd_cs_pair_u:N ##1 } }
+ { \use:c { \__cdcmd_cs_pair_n:N ##1 } }
+ }
+ \exp_args:Nc #2
+ { \__cdcmd_cs_pair_u:N ##1 } {##2} {##3}
+ \exp_args:Nc #2
+ { \__cdcmd_cs_pair_n:N ##1 } {##2} { }
+ }
+ }
+\seq_const_from_clist:Nn \c__cdcmd_Command_seq
+ {
+ \NewDocumentCommand ,
+ \RenewDocumentCommand ,
+ \ProvideDocumentCommand ,
+ \DeclareDocumentCommand ,
+ \NewExpandableDocumentCommand ,
+ \RenewExpandableDocumentCommand ,
+ \ProvideExpandableDocumentCommand ,
+ \DeclareExpandableDocumentCommand ,
+ }
+\seq_const_from_clist:Nn \c__cdcmd_COMMAND_seq
+ {
+ \NewConditionCommand ,
+ \RenewConditionCommand ,
+ \ProvideConditionCommand ,
+ \DeclareConditionCommand ,
+ \NewExpandableConditionCommand ,
+ \RenewExpandableConditionCommand ,
+ \ProvideExpandableConditionCommand ,
+ \DeclareExpandableConditionCommand ,
+ }
+\seq_mapthread_function:NNN
+ \c__cdcmd_COMMAND_seq
+ \c__cdcmd_Command_seq
+ \__cdcmd_new_cdcmd_command:NN
+\cs_new:Npn \__cdcmd_new_cdcmd_cmd_no:nnn #1#2#3
+ {
+ \cs_new_protected:Npn #1 ##1##2##3
+ {
+ #3 ##1 { t+ m }
+ {
+ \IfBooleanTF {####1}
+ { \cdcmd_all_if:nTF }
+ { \cdcmd_any_if:nTF }
+ { ####2 }
+ { \use:c { \__cdcmd_cs_pair_u:Nn ##1 {##2} } }
+ { \use:c { \__cdcmd_cs_pair_n:Nn ##1 {##2} } }
+ }
+ #2 { \__cdcmd_cs_pair_u:Nn ##1 {##2} } {##3}
+ #2 { \__cdcmd_cs_pair_n:Nn ##1 {##2} } { }
+ }
+ }
+\cs_generate_variant:Nn \__cdcmd_new_cdcmd_cmd_no:nnn { xxx }
+\seq_const_from_clist:Nn \c__cdcmd_cmd_no_seq
+ {
+ \cs_set_protected:cn , \cs_set_protected_nopar:cn ,
+ \cs_set_protected:cn , \cs_set_protected_nopar:cn ,
+ \cs_set_protected:cn , \cs_set_protected_nopar:cn ,
+ \cs_set:cn , \cs_set_nopar:cn ,
+ \cs_set:cn , \cs_set_nopar:cn ,
+ \cs_set:cn , \cs_set_nopar:cn ,
+ }
+\seq_const_from_clist:Nn \c__cdcmd_Cmd_no_seq
+ {
+ \NewDocumentCommand , \NewDocumentCommand ,
+ \RenewDocumentCommand , \RenewDocumentCommand ,
+ \DeclareDocumentCommand , \DeclareDocumentCommand ,
+ \NewExpandableDocumentCommand , \NewExpandableDocumentCommand ,
+ \RenewExpandableDocumentCommand , \RenewExpandableDocumentCommand ,
+ \DeclareExpandableDocumentCommand , \DeclareExpandableDocumentCommand ,
+ }
+\seq_const_from_clist:Nn \c__cdcmd_CMD_no_seq
+ {
+ \__cdcmd_new_cdcmd_p_l_num:Nnn , \__cdcmd_new_cdcmd_p_nl_num:Nnn ,
+ \__cdcmd_renew_cdcmd_p_l_num:Nnn , \__cdcmd_renew_cdcmd_p_nl_num:Nnn ,
+ \__cdcmd_declare_cdcmd_p_l_num:Nnn , \__cdcmd_declare_cdcmd_p_nl_num:Nnn ,
+ \__cdcmd_new_cdcmd_np_l_num:Nnn , \__cdcmd_new_cdcmd_np_nl_num:Nnn ,
+ \__cdcmd_renew_cdcmd_np_l_num:Nnn , \__cdcmd_renew_cdcmd_np_nl_num:Nnn ,
+ \__cdcmd_declare_cdcmd_np_l_num:Nnn , \__cdcmd_declare_cdcmd_np_nl_num:Nnn ,
+ }
+\int_step_inline:nn { 6 }
+ {
+ \__cdcmd_new_cdcmd_cmd_no:xxx
+ { \seq_item:Nn \c__cdcmd_CMD_no_seq {#1} }
+ { \seq_item:Nn \c__cdcmd_cmd_no_seq {#1} }
+ { \seq_item:Nn \c__cdcmd_Cmd_no_seq {#1} }
+ }
+\tl_new:N \l__cdcmd_arg_spec_tl
+\cs_new:Npn \__cdcmd_generate_arg_spec:nnn #1#2#3
+ {
+ \tl_set:Nn \l__cdcmd_arg_spec_tl { O{#2} }
+ \if_int_compare:w #1 > 1 \exp_stop_f:
+ \int_step_inline:nn {#1-1} { \tl_put_right:Nn \l__cdcmd_arg_spec_tl {#3} }
+ \fi:
+ }
+\cs_new:Npn \__cdcmd_new_cdcmd_cmd_o_aux:nn #1#2
+ {
+ \cs_new_protected:Npn #1 ##1##2##3##4##5
+ {
+ #2 ##1 { t+ m }
+ {
+ \IfBooleanTF{####1}
+ { \cdcmd_all_if:nTF }
+ { \cdcmd_any_if:nTF }
+ {####2}
+ { \use:c { \__cdcmd_cs_pair_u:N ##1 } }
+ { \use:c { \__cdcmd_cs_pair_n:N ##1 } }
+ }
+ \__cdcmd_generate_arg_spec:nnn {##2} {##3} {##5}
+ \exp_args:NcV #2 { \__cdcmd_cs_pair_u:N ##1 } \l__cdcmd_arg_spec_tl {##4}
+ \exp_args:NcV #2 { \__cdcmd_cs_pair_n:N ##1 } \l__cdcmd_arg_spec_tl { }
+ }
+ }
+\seq_const_from_clist:Nn \c__cdcmd_CMD_o_seq
+ { \NewDocumentCommand , \RenewDocumentCommand , \DeclareDocumentCommand }
+\seq_const_from_clist:Nn \c__cdcmd_cmd_o_seq
+ {
+ \__cdcmd_new_cdcmd_o_num:Nnnnn ,
+ \__cdcmd_renew_cdcmd_o_num:Nnnnn ,
+ \__cdcmd_declare_cdcmd_o_num:Nnnnn ,
+ }
+\seq_mapthread_function:NNN
+ \c__cdcmd_cmd_o_seq
+ \c__cdcmd_CMD_o_seq
+ \__cdcmd_new_cdcmd_cmd_o_aux:nn
+\cs_new_protected:Npn \__cdcmd_new_cdcmd_cmd_ne_aux:n #1
+ {
+ \exp_args:Nc \NewDocumentCommand { #1 conditioncommand } { s m O{0} o +m }
+ {
+ \IfBooleanTF{##1}
+ {
+ \IfNoValueTF{##4}
+ { \use:c { __cdcmd_ #1 _cdcmd_p_nl_num:Nnn } ##2 {##3} {##5} }
+ { \use:c { __cdcmd_ #1 _cdcmd_o_num:Nnnnn } ##2 {##3} {##4} {##5} { m } }
+ }
+ {
+ \IfNoValueTF{##4}
+ { \use:c { __cdcmd_ #1 _cdcmd_p_l_num:Nnn } ##2 {##3} {##5} }
+ { \use:c { __cdcmd_ #1 _cdcmd_o_num:Nnnnn } ##2 {##3} {##4} {##5} { +m } }
+ }
+ }
+ }
+\clist_map_function:nN { new, renew, declare } \__cdcmd_new_cdcmd_cmd_ne_aux:n
+\NewDocumentCommand \provideconditioncommand { s m O{0} o +m }
+ {
+ \cs_if_free:NT #2
+ {
+ \IfBooleanTF{#1}
+ {
+ \IfNoValueTF{#4}
+ { \newconditioncommand * #2 [#3] {#5} }
+ { \newconditioncommand * #2 [#3] [#4] {#5} }
+ }
+ {
+ \IfNoValueTF{#4}
+ { \newconditioncommand #2 [#3] {#5} }
+ { \newconditioncommand #2 [#3] [#4] {#5} }
+ }
+ }
+ }
+
+\int_step_inline:nnnn { 7 } { 1 } { 12 }
+ {
+ \__cdcmd_new_cdcmd_cmd_no:xxx
+ { \seq_item:Nn \c__cdcmd_CMD_no_seq {#1} }
+ { \seq_item:Nn \c__cdcmd_cmd_no_seq {#1} }
+ { \seq_item:Nn \c__cdcmd_Cmd_no_seq {#1} }
+ }
+
+\cs_new_protected:Npn \__cdcmd_new_cdcmd_cmd_e_no_aux:n #1
+ {
+ \exp_args:Nc \NewDocumentCommand { #1 econditioncommand } { s m O{0} +m }
+ {
+ \IfBooleanTF{##1}
+ { \use:c { __cdcmd_ #1 _cdcmd_np_nl_num:Nnn } ##2 {##3} {##4} }
+ { \use:c { __cdcmd_ #1 _cdcmd_np_l_num:Nnn } ##2 {##3} {##4} }
+ }
+ }
+\clist_map_function:nN { new, renew, declare } \__cdcmd_new_cdcmd_cmd_e_no_aux:n
+\NewDocumentCommand \provideeconditioncommand { s m O{0} +m }
+ {
+ \cs_if_free:NT #2
+ {
+ \IfBooleanTF{#1}
+ { \neweconditioncommand * #2 [#3] {#4} }
+ { \neweconditioncommand #2 [#2] {#4} }
+ }
+ }
+%%
+%% This work consists of the file cdcmd.dtx,
+%% and the derived files cdcmd.pdf,
+%% cdcmd.sty,
+%% cdcmd-cn.tex,
+%% cdcmd-cn.pdf,
+%% cdcmd-test.tex,
+%% cdcmd.ins and
+%% README.md
+%%
+%% End of file `cdcmd.sty'.
diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check
index 31a09179853..eb8224f68e0 100755
--- a/Master/tlpkg/bin/tlpkg-ctan-check
+++ b/Master/tlpkg/bin/tlpkg-ctan-check
@@ -161,7 +161,7 @@ my @TLP_working = qw(
catchfile catchfilebetweentags catcodes catechis catoptions causets
cbcoptic cbfonts cbfonts-fd
cc-pl ccaption ccfonts ccicons cclicenses ccool
- cd cd-cover cdpbundl
+ cd cd-cover cdcmd cdpbundl
cell cellprops cellspace celtic censor
centeredline centerlastline cesenaexam
cfr-initials cfr-lm
diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds
index 5ba1d88e950..2759c206985 100755
--- a/Master/tlpkg/libexec/ctan2tds
+++ b/Master/tlpkg/libexec/ctan2tds
@@ -259,6 +259,7 @@ chomp (my $ctan_root = `tlpkginfo --ctan-root`);
'cbfonts', "&MAKEflatten",
'cc-pl', "&MAKEflatten",
'cchess', "die 'skipping, noinfo license, old'",
+ 'cdcmd', "&MAKEflatten",
'cdcover', "die 'skipping, use cd-cover'",
'cellular', "die 'skipping, noinfo license, author deceased'",
'cellwise', "die 'skipping, noinfo license'",
diff --git a/Master/tlpkg/tlpsrc/cdcmd.tlpsrc b/Master/tlpkg/tlpsrc/cdcmd.tlpsrc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Master/tlpkg/tlpsrc/cdcmd.tlpsrc
diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
index 4b2c984c6d6..b72bbe641e2 100644
--- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
@@ -157,6 +157,7 @@ depend ccaption
depend cclicenses
depend cd
depend cd-cover
+depend cdcmd
depend cdpbundl
depend cellprops
depend cellspace