texlive[51105] Master: mathcommand (12may19)

commits+karl at tug.org commits+karl at tug.org
Sun May 12 22:18:42 CEST 2019


Revision: 51105
          http://tug.org/svn/texlive?view=revision&revision=51105
Author:   karl
Date:     2019-05-12 22:18:41 +0200 (Sun, 12 May 2019)
Log Message:
-----------
mathcommand (12may19)

Modified Paths:
--------------
    trunk/Master/tlpkg/bin/tlpkg-ctan-check
    trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/mathcommand/
    trunk/Master/texmf-dist/doc/latex/mathcommand/README.md
    trunk/Master/texmf-dist/doc/latex/mathcommand/makefile
    trunk/Master/texmf-dist/doc/latex/mathcommand/mathcommand.pdf
    trunk/Master/texmf-dist/source/latex/mathcommand/
    trunk/Master/texmf-dist/source/latex/mathcommand/mathcommand.dtx
    trunk/Master/texmf-dist/source/latex/mathcommand/mathcommand.ins
    trunk/Master/texmf-dist/tex/latex/mathcommand/
    trunk/Master/texmf-dist/tex/latex/mathcommand/mathcommand.sty
    trunk/Master/tlpkg/tlpsrc/mathcommand.tlpsrc

Added: trunk/Master/texmf-dist/doc/latex/mathcommand/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/mathcommand/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/mathcommand/README.md	2019-05-12 20:18:41 UTC (rev 51105)
@@ -0,0 +1,36 @@
+%%%%%%%%
+This directory contains the package
+
+  name: mathcommand
+  license: LaTeX Project Public License version 1.2 or above
+  version: v1.01
+  date: 2019/05/12
+  author: Thomas Colcombet
+  mail: thomas.colcombet at irif.fr
+  web: -
+
+Purpose:
+ The mathcommand package provides functionalities for defining macros:
+  - that have different behaviors depending on whether in math or text mode,
+  - absorb Primes, Indices, Exponents (PIE) following LaTeX notations and
+    have them as extra parameters usable in the code.
+ The primary objective of this code is to be used together with the knowledge
+ package for a proper handling of mathematical notations.
+
+Install:
+ It is sufficient to have the file mathcommand.sty accessible by LaTeX.
+ It can be produced by `make mathcommand.sty' if necessary.
+ The documentation is in the file mathcommand.pdf.
+
+Content of the file mathcommand-ctan.zip:
+ - README.md: this file generated while compiling mathcommand.ins,
+ - mathcommand.sty: the package file (generated using knowledge.ins)
+ - mathcommand.pdf: the user documentation (generated by compiling
+   mathcommand.dtx)
+ - makefile: the makefile. Use 'make all' to generate mathcommand.sty
+   and knowledge.pdf. It can also: clean the directory, make zip
+   version of the sources, or ready for CTAN.
+ - mathcommand.ins: is the file generating mathcommand.sty and
+   README.md from mathcommand.dtx (using docstrip).
+ - mathcommand.dtx: code and documentation.
+


Property changes on: trunk/Master/texmf-dist/doc/latex/mathcommand/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/mathcommand/makefile
===================================================================
--- trunk/Master/texmf-dist/doc/latex/mathcommand/makefile	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/mathcommand/makefile	2019-05-12 20:18:41 UTC (rev 51105)
@@ -0,0 +1,49 @@
+help:
+	@echo "This is the makefile for the mathcommand package"
+	@echo "- all: produces mathcommand.pdf mathcommand.sty mathcommand-code.pdf README.md"
+	@echo "- clean"
+	@echo "- ctan: creates the mathcommand-ctan.zip file tailored for CTAN"
+
+all: mathcommand.sty mathcommand.pdf README.md
+
+mathcommand.sty: mathcommand.dtx mathcommand.ins
+	latex mathcommand.ins
+
+README.md: mathcommand.dtx mathcommand.ins
+	latex mathcommand.ins
+
+clean:
+	rm -f *.aux *.glo *.idx *.aux *.synctex.gz *.out *.toc *.kaux *.diagnose *.log
+	rm -f *.bbl *.out *.bbl *.ind *.ilg *.idx
+	rm -f mathcommand.sty
+	rm -f mathcommand.pdf
+	rm -f mathcommand-sources-complete.zip
+	rm -f mathcommand-ctan.zip
+	rm -f README.md
+
+ctan: mathcommand-ctan.zip
+
+mathcommand.pdf: mathcommand.dtx mathcommand.sty
+	pdflatex mathcommand.dtx
+	pdflatex mathcommand.dtx
+	pdflatex mathcommand.dtx
+
+mathcommand.aux: mathcommand.dtx mathcommand.sty
+	pdflatex mathcommand.dtx
+
+sources: clean mathcommand-ctan.zip mathcommand-sources-complete.zip
+
+mathcommand-sources-complete.zip: clean
+	\rm -f mathcommand-sources-complete.zip
+	cp  mathcommand-sources-complete.zip ../mathcommand-sources-complete-`date +%y-%m-%d_%H:%M`.zip
+
+mathcommand-ctan.zip: mathcommand.pdf mathcommand.sty mathcommand.ins README.md makefile
+	rm -f mathcommand-ctan.zip
+	rm -rf mathcommand
+	mkdir mathcommand
+	cp mathcommand.pdf mathcommand/
+	cp mathcommand.dtx mathcommand/
+	cp makefile mathcommand.ins README.md mathcommand/
+	zip mathcommand-ctan.zip mathcommand/*
+	rm -rf mathcommand
+


Property changes on: trunk/Master/texmf-dist/doc/latex/mathcommand/makefile
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/mathcommand/mathcommand.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/mathcommand/mathcommand.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/mathcommand/mathcommand.pdf	2019-05-12 20:17:53 UTC (rev 51104)
+++ trunk/Master/texmf-dist/doc/latex/mathcommand/mathcommand.pdf	2019-05-12 20:18:41 UTC (rev 51105)

Property changes on: trunk/Master/texmf-dist/doc/latex/mathcommand/mathcommand.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/source/latex/mathcommand/mathcommand.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/mathcommand/mathcommand.dtx	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/mathcommand/mathcommand.dtx	2019-05-12 20:18:41 UTC (rev 51105)
@@ -0,0 +1,1112 @@
+% \iffalse
+% !TEX encoding = UTF-8 Unicode
+% !TEX TS-program = pdflatex
+%
+%
+%
+%  meta-comment
+%
+% Copyright (C) 2019-2019 by Thomas Colcombet
+% -----------------------------------
+%
+% This file may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.2
+% of this license or (at your option) any later version.
+% The latest version of this license is in:
+%
+% http://www.latex-project.org/lppl.txt
+%
+% and version 1.2 or later is part of all distributions of LaTeX
+% version 1999/12/01 or later.
+%
+% \fi
+%
+% \iffalse
+%<head>\usepackage{expl3}
+%<head>\ProvidesExplPackage{mathcommand}{2019/05/12}{1.01}{}
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{paralist}
+\usepackage[svgnames]{xcolor}
+\usepackage{expl3}
+\usepackage{mathcommand}
+\usepackage[hidelinks]{hyperref}
+\usepackage[quotation,scope,electronic]{knowledge}
+
+\CheckSum{0}
+\changes{1.01}{2019/05/12}{Initial version} %
+\GetFileInfo{mathcommand.sty} %
+\DoNotIndex{}
+\edef\mathcommandversiondate{\fileversion--\filedate}
+
+
+
+ \newcommand\smallcode[1]{\colorbox{Honeydew}{\texttt{#1}}}
+
+
+\newsavebox{\fminipagebox}
+
+\NewDocumentEnvironment{cminipage}{m O{\fboxsep}}
+ {\par\kern#2\noindent\begin{lrbox}{\fminipagebox}
+  \begin{minipage}{#1}\ignorespaces}
+ {\end{minipage}\end{lrbox}%
+  \makebox[#1]{%
+    \kern\dimexpr-\fboxsep-\fboxrule\relax
+    \colorbox{Honeydew}{\usebox{\fminipagebox}}%
+    \kern\dimexpr-\fboxsep-\fboxrule\relax}\par\kern#2}
+
+\NewDocumentEnvironment{fminipage}{m O{\fboxsep}}
+ {\par\kern#2\noindent\begin{lrbox}{\fminipagebox}
+  \begin{minipage}{#1}\ignorespaces}
+ {\end{minipage}\end{lrbox}%
+  \makebox[#1]{%
+    \kern\dimexpr-\fboxsep-\fboxrule\relax
+    \fbox{\usebox{\fminipagebox}}%
+    \kern\dimexpr-\fboxsep-\fboxrule\relax}\par\kern#2\relax}
+
+ \newenvironment{code}[1][12.4cm]
+    {\par
+     \noindent
+     \cminipage{#1}%
+     \tt
+    }{%
+    \endcminipage%
+    \par
+    }
+ 
+% This is a hack. Introducing Hyphenation everywhere in a sequence of token.
+% Otherwise the macro names tend to always exceed lines.
+% It should be improved in order to always require at least--say--3 symbols before
+% and after the hyphenation.
+\ExplSyntaxOn
+\cs_new:Nn\tl_fragilize:n
+  {\__tl_fragilize:N#1\q_stop}
+\cs_new:Nn\__tl_fragilize:N
+  {\token_if_eq_meaning:NNTF#1\q_stop
+      {}{#1
+      \-\__tl_fragilize:N}}
+\cs_set_eq:NN\textfragilize\tl_fragilize:n
+\cs_new:Npn\Robustdisplay#1
+   {\exp_args:Nx\textfragilize{\robustdisplay{#1}}}
+\ExplSyntaxOff
+
+\let\cs\undefined
+\knowledgenewvariant\cs
+ {namespace=cs,
+  default style={autoref link,cs},
+  unknown style=cs unknown,
+  unknown style cont=cs unknown,
+  unknown warning=false,
+  unknown diagnose=true,
+  suggestion=cs,
+  PDF string={\detokenize{#1}}}
+\knowledgestyle{cs}{wrap=\Robustdisplay,typewriter,up,md,color=NavyBlue}
+\knowledgestyle{cs unknown}{wrap=\Robustdisplay,typewriter,up,md,color=black}
+
+\knowledgenewvariant\csintro
+ {namespace=cs,
+  auto knowledge={autoref,scope=document,also now},
+  default style={autoref target,csintro},
+  unknown style=csintro unknown,
+  unknown style cont=csintro unknown,
+  unknown warning=false,
+  unknown diagnose=false,
+  PDF string = {\detokenize{#1}}}
+\knowledgestyle{csintro}{wrap=\Robustdisplay,typewriter,up,md,color=blue}
+\knowledgestyle{csintro unknown}{wrap=\Robustdisplay,typewriter,up,md,color=black}
+
+\knowledgenewvariant\csreintro
+ {namespace=cs,
+  default style=csintro,
+  unknown style=csintro unknown,
+  unknown style cont=csintro unknown,
+  PDF string = {\Robustdisplay{#1}}}
+
+
+
+
+\knowledgedirective{doc notion}
+         {autoref,style=doc notion,intro style=intro doc notion}
+\knowledgestyle{doc notion}{color=DarkBlue}
+\knowledgestyle{intro doc notion}{color=blue,emphasize}
+ 
+
+\knowledgedirective{package}{style=package}
+\knowledgestyle{package}{typewriter,color=black}
+
+
+
+
+\knowledge{xparse}{package,url = {https://www.ctan.org/pkg/xparse}}
+\knowledge{knowledge}{package,url = {https://www.ctan.org/pkg/knowledge}}
+\knowledge{xcolor}{package,url = {https://www.ctan.org/pkg/xcolor}}
+\knowledge{amsfonts}{package,url = {https://www.ctan.org/pkg/amsfonts}}
+\knowledge{mathcommand}{package}
+
+\knowledge{math variant}{doc notion}
+\knowledge{text variant}{doc notion}
+\knowledge{PIE}[PIEs]{doc notion}
+\knowledge{PIE command}[PIE commands]{doc notion}
+
+
+\begin{document}
+\title{The \texttt{mathcommand} package for \LaTeX\\
+       {\small[version  \mathcommandversiondate]}}
+
+\author{Thomas Colcombet}
+ \maketitle
+ \begin{abstract}
+  The "mathcommand" package provides functionalities for defining macros
+  1. that have different behaviors depending on whether in math or text mode,
+  2. that absorb Primes, Indices and Exponents (PIE) as extra parameters usable in the code, and
+  3. offers some iteration facilities for defining macros with similar code.
+ The primary objective of this package is to be used together with the "knowledge"
+ package for a proper handling of mathematical notations.
+ \end{abstract}
+
+ \section{History of the package}
+ This first version of the package was written in May 2019.
+
+
+ \section{Defining text and math commands}
+
+ The principle is that the package will maintain, for a macro \cs{\macro}, two concurrent version of the code:
+ a ""math variant"" (technically it is stored in a macro \verb|\Math macro|) and a ""text variant""
+  (technically stored in a macro \verb|\Text macro|\footnote{These cannot be used accidentally by the user since these control sequences contain a space.}).
+ The macro \cs{\macro} itself will execute one or the other depending on whether it is
+ executed in math or text mode. Note that all the macros are non-expandable for avoiding problems
+ with mathematics that would be sent, for instance, to the table of contents.
+
+ For instance after executing:
+ \begin{code}
+ \cs{\newmathcommand}\cs\macro[1]\{\cs\mathit\{math\}\verb.^.\cs\mathrm\{code\}\verb._.\{(\#1)\}\}\\
+ \cs{\newtextcommand}\cs\macro[1]\{text code (\#1)\}
+ \end{code}
+ \noindent when executing \cs{\macro} in math mode,
+ the math code will be executed, and in text mode similarly:
+ \newmathcommand\toto[1]{\mathit{math}^{\mathrm{code}}_{(#1)}}
+ \newtextcommand\toto[1]{text code (#1)}
+ \begin{center}
+  \smallcode{\cs\macro\{a\}} yields~`\toto{a}' \qquad while \smallcode{\$\cs\macro\{a\}\$} yields `$\toto{a}$'.
+ \end{center}
+
+ If the macro \cs{\macro} already exists, it is stored
+ under the name \cs{\LaTeXmacro}, and then everything's happen as
+ if it had already been defined both in math and text mode.   
+
+ This is interesting for redefining known macros.
+ For instance \cs{\c} is a convenient way to producing cedillas in \LaTeX, as in \smallcode{\cs\c\ a}
+ which yields `\c a'. However, one may want \cs{\c} to reprensent a variable $c$ in math mode.
+ This is done using, e.g.:
+ \begin{code}
+ \cs{\renewmathcommand}\cs\c\{c\}
+ \end{code}
+ \renewmathcommand\c{c}
+ \noindent Then, the macro \cs{\c} still works in text mode,
+ and using~\cs{\c} in math mode does display simply~`$\c$'.
+
+ The name of the macros offered by the "mathcommand" package are mere adaptations of the standard macros of \LaTeX\ and of the package "xparse"\footnote{The package "xparse" offers a very convenient way to define macros with complicated parameter signatures.}.
+ Their syntax is the same (in particular in terms of parameter definitions):
+ \begin{asparadesc}
+ \itemAP[\csintro{\newmathcommand}] is similar to \cs{\newcommand} and creates a "math variant",
+ \itemAP[\csintro{\newtextcommand}] is similar to \cs{\newcommand} and creates a "text variant",
+ \itemAP[\csintro{\renewmathcommand}] is similar to \cs{\renewcommand} and creates a "math variant",
+ \itemAP[\csintro{\renewtextcommand}] is similar to \cs{\renewcommand} and creates a "text variant",
+ \itemAP[\csintro{\declaremathcommand}] is similar to \cs{\newcommand} but defines the macro even if it exists before; it creates a "math variant",
+ \itemAP[\csintro{\declaretextcommand}] is similar to \cs{\newcommand} but defines the macro even if it exists before; it creates a "text variant",
+ \itemAP[\csintro{\NewDocumentMathCommand}] is like \cs{\NewDocumentCommand} of the "xparse" package, but creates a "math variant",
+ \itemAP[\csintro{\NewDocumentTextCommand}] is like \cs{\NewDocumentCommand} of the "xparse" package, but creates a "text variant",
+ \itemAP[\csintro{\RenewDocumentMathCommand}] is like \cs{\RenewDocumentCommand} of the "xparse" package, but creates a "math variant",
+ \itemAP[\csintro{\RenewDocumentTextCommand}] is like \cs{\RenewDocumentCommand} of the "xparse" package, but creates a "text variant",
+ \itemAP[\csintro{\DeclareDocumentMathCommand}] is like \cs{\DeclareDocumentCommand} of the "xparse" package, but creates a "math variant",
+ \itemAP[\csintro{\DeclareDocumentTextCommand}] is like \cs{\DeclareDocumentCommand} of the "xparse" package, but creates a "text variant",
+ \itemAP[\csintro{\ProvideDocumentMathCommand}] is like \cs{\ProvideDocumentCommand} of the "xparse" package, but creates a "math variant",
+ \itemAP[\csintro{\ProvideDocumentTextCommand}] is like \cs{\ProvideDocumentCommand} of the "xparse" package, but creates a "text variant".
+ \end{asparadesc}
+
+ The package offers also the following commands:
+ \begin{asparadesc}
+ \itemAP[\csintro{\declarecommand}] which is similar to \cs{\newcommand} but defines the macro even if it exists before,
+ \itemAP[\csintro{\storecommand}\texttt{[optional-prefix]}\texttt{\cs\macro}] which copies the content of the macro \cs\macro\ to \verb|\optional-prefixmacro|. By default, the optional prefix is \verb|LaTeX|. (Hence, it does what is automatically made by commands such as \cs\declarecommand).
+ \end{asparadesc}
+ 
+ \section{Defining Prime/Indices/Exponents absorbing commands (PIE commands)}
+
+ Another feature offered by the "mathcommand" package is to permit the definitions of macros that would
+ absorb the primes, subscript and superscript that follow them.
+ \AP
+ The three pieces of information are abbreviated as ""PIE"" (for ``Primes-Indices-Exponents'').
+ This terminology serves as a help for remembering the order prime-index-exponent.
+ \AP A ""PIE command"" is similar to a normal macro/command, but for the fact
+ that the "PIEs" that follow are absorbed and can be used in the macro as
+ three extra parameters.
+
+ This is best explained through an example. After writing:
+ \begin{code}
+ \cs\newcommandPIE\cs\macro[1]\{([\#1]\#3)\#2\#4\}
+ \end{code}
+ \noindent one obtains that
+ \newcommandPIE\macrob[1]{([#1]#3)#2#4}
+ \begin{center}
+ \smallcode{\$\cs\macro\{A\}\_2'\$} yields $\macrob{A}_2'$\ .
+ \end{center}
+ Indeed, in the body of the definition of \cs{macro}, \#1 represents the normal parameter of the command, while the three following parameters (\texttt{\#2},\texttt{\#3},\texttt{\#4} in this case) contain respectively the primes (either empty or a sequence of $'$ symbols), 
+ the index (either empty if there is no subscript or of the form \verb"_{index}" if there is
+ an index), and the exponent (either empty if there is no superscript or of the form
+ \verb"^{exponent}" if there is one).
+ In the case of the above definition, the index (parameter \texttt{\#3}) is written inside the parenthesis,
+ while primes and exponents are put outside.
+
+ The commands provided for defining "PIE commands" are given in the following list. Once more, 
+ appart from the specificity of "PIE commands", the syntax is as the original corresponding commands these are based on.
+ \begin{asparadesc}
+ \itemAP[\csintro{\newcommandPIE}] is similar to \cs\newcommand\ (but defines a non-expandable macro)
+ \itemAP[\csintro{\renewcommandPIE}] is similar to \cs\renewcommand\ (but defines a non-expandable macro)
+ \itemAP[\csintro{\declarecommandPIE}] is similar to \cs\newcommand\ and works even if the macro already exists (and defines a non-expandable macro)
+ \itemAP[\csintro{\NewDocumentCommandPIE}] is similar to \cs\NewDocumentCommand\ of the "xparse" package,
+ \itemAP[\csintro{\RenewDocumentCommandPIE}] is similar to \cs\RenewDocumentCommand\ of the "xparse" package,
+ \itemAP[\csintro{\DeclareDocumentCommandPIE}] is similar to \cs\DeclareDocumentCommand\ of the "xparse" package,
+ \itemAP[\csintro{\ProvideDocumentCommandPIE}] is similar to \cs\ProvideDocumentCommand\ of the "xparse" package.
+ \end{asparadesc}
+
+ Finally, a bunch of macros are used to define "math variants" that are "PIE commands":
+ \begin{asparadesc}
+ \itemAP[\csintro{\newmathcommandPIE}] is like \cs{\newcommandPIE} and creates a "math variant",
+ \itemAP[\csintro{\renewmathcommandPIE}] is like \cs{\renewcommandPIE} and creates a "math variant",
+ \itemAP[\csintro{\declaremathcommandPIE}] is like \cs{\declarecommandPIE} and creates a "math variant",
+ \itemAP[\csintro{\NewDocumentMathCommandPIE}] is like \cs{\NewDocumentCommandPIE}, but creates a "math variant",
+ \itemAP[\csintro{\RenewDocumentMathCommandPIE}] is like \cs{\RenewDocumentCommandPIE}, but creates a "math variant",
+ \itemAP[\csintro{\DeclareDocumentMathCommandPIE}] is like \cs{\DeclareDocumentCommandPIE}, but creates a "math variant",
+ \itemAP[\csintro{\ProvideDocumentMathCommandPIE}] is like \cs{\ProvideDocumentCommandPIE}, but creates a "math variant",
+ \end{asparadesc}
+
+
+  \section{Looping for defining commands}
+ 
+ \begin{scope}\label{LoopCommands}
+ \knowledge{list on which to iterate}{doc notion}
+ \knowledge{name 1}{doc notion}
+ \knowledge{name 2}{doc notion}
+ \knowledge{name 7}{doc notion}
+ \knowledge{code}{doc notion}
+ The "mathcommand" package offer also some capabilities for automatically defining multiple
+ similar macros. This is done using only one command:
+ \begin{center}
+    \AP\csintro{\LoopCommands}\{"list on which to iterate"\}["name 1"]["name 2"]\dots["name 7"]\{"code@@LoopCommands"\}
+ \end{center}
+ \AP The ""list on which to iterate"" is a list of letters or braced sequences of letters.
+ \AP the ""name 1"", ""name 2"" up to ""name 7"" optional parameters are expandable
+ pieces of code that are to be evaluated
+ and then converted to control sequences; they may use the extra parameter~\texttt{\#1}.
+ \AP ""code"" is the code to be executed that can
+ use the parameters~\texttt{\#1}, \texttt{\#2}, up to~\texttt{\#8}.
+
+ The result of executing this macro is that each of the letters or sequences of letters
+ in the "list on which to iterate" will be taken one after the other. For each of them, the "code" is executed,
+ taking as value of the parameter~\#1 the element in the list, and as parameters~\#2  to~\#8
+ control sequences constructed from the evaluation of "name 1" up to "name 7" (using as parameters~\#1 the element of the sequence).
+
+ For instance, imagine one easily wants to denote vectors simply as `\cs\vx' instead of `\cs\vec~x' or `\cs\vec\{x\}',
+ it is sufficient to write:
+ \begin{code}
+ \cs\LoopCommands\{abcdefghijklmnopqrstuvwxyz\}[v\#1]\\
+ \indent~~~~\{\cs\newcommand\#2\{\cs\vec~\#1\}\}
+ \end{code}
+ \noindent It will result in the successive execution of
+ \smallcode{\cs\newcommand\cs\va\{\cs\vec~a\}} and so on up to
+ \smallcode{\cs\newcommand\cs\vz\{\cs\vec~z\}}.
+
+ Note also that if by default that the "list on which to iterate" is automatically expanded,
+ and if a non-expandable control sequence is met, then it is replaced by its main text.
+ Hence using \texttt{\{\cs\alpha\cs\beta\}} is equivalent to \texttt{\{\{alpha\}\{beta\}\}}.
+
+
+ Some extra remarks may be helpful:
+ \begin{itemize}
+ \item As usual in \TeX/\LaTeX, the "code" may have to use its own internal parameters,
+ for instance for defining macros: such parameters should use double \texttt{\#}'s, i.e., \texttt{\#\#1}, \texttt{\#\#2} up to \texttt{\#\#9}.
+
+ \LoopCommands{abcdefghijklmnopqrstuvwxyz}[o#1]
+      {\declarecommandPIE#2{\overline{#1##2}##1##3}}
+ For instance:
+ \begin{code}[10cm]
+ \cs\LoopCommands\{abcdefghijklmnopqrstuvwxyz\}[o\#1]\\
+ \indent~~~~\{\cs\declarecommandPIE\#2\{\cs\overline\{\#1\#\#2\}\#\#1\#\#3\}
+ \end{code}
+ \noindent will result in \cs\ou\ to be declared as the "PIE command"
+defined with as main body \texttt{\cs\overline\{u\#2\}\#1\#3\}}
+ (note the translation of parameters, which is the standard way to proceed for \TeX).
+ In our case {\tt \cs\ou\_1\verb.^.2} yields `$\ou_1^2$' (the subscript gets to be inside the bar, 
+ and the superscript and primes outside), and so on...
+ \item When defining multiple commands, some may already exists. To avoid conflict, one sould use
+    the `declare' version of the defining commands. These will work independently of the 
+    context. Is it also good to define only the "math variants" using the appropriate commands
+ of the package.
+ \itemAP The following strings are predefined for the user to loop on:
+    \begin{asparaitem}
+    \itemAP \csintro\lettersUppercase\ stands for \texttt{\lettersUppercase}
+    \itemAP \csintro\lettersLowercase\ stands for \texttt{\lettersLowercase}
+    \itemAP \csintro\lettersAll\ stands for \texttt{\lettersAll}.
+    \itemAP \csintro\lettersGreekLowercase\ stands for $\lettersGreekLowercase$.
+    \itemAP \csintro\lettersGreekUppercase\ stands for $\lettersGreekUppercase$.
+    \itemAP \csintro\lettersGreekAll\ stands for $\lettersGreekAll$.
+    \end{asparaitem}
+ \end{itemize}
+ \end{scope}
+
+ Hence, for instance:
+ \begin{code}
+ \cs\LoopCommands\cs\lettersUppercase[bb\#1]\\
+ \indent~~~~~~\{\cs\newmathcommand\{\cs\mathbb \#1\}\}\\
+ \cs\LoopCommands\cs\lettersGreekLowercase[\#1][LaTeX\#1]\\
+ \indent~~~~~~\{\cs\renewmathcommand\#2\{\cs\textcolor\{blue\}\{\#3\}\}
+ \end{code}
+ \noindent configures the macros \cs\bbA, \dots, \cs\bbZ\ to display
+ the letters in blackboard bold alphabet (with the "amsfonts" package),
+ and the lowercase greek letters \cs\alpha,\dots\ to
+ be displayed in blue (with the "xcolor" package loaded). Note in the last case
+ the use of an extra parameter that is used for accessing the macros \cs\LaTeXalpha,\dots\
+ that are automatically generated by the \cs\renewmathcommand\ macro.
+ \newpage
+
+ \DocInput{mathcommand.dtx}
+ \end{document}
+%</driver>
+% \fi
+%
+%
+%
+%%%%%%%%%%
+%
+% \section{Implementation}
+% \label{section:code}
+%
+% \subsection{README.md}
+%
+%<*readme>
+%    \begin{macrocode}
+This directory contains the package
+
+  name: mathcommand
+  license: LaTeX Project Public License version 1.2 or above
+  version: v1.01
+  date: 2019/05/12
+  author: Thomas Colcombet
+  mail: thomas.colcombet at irif.fr
+  web: -
+  
+Purpose:
+ The mathcommand package provides functionalities for defining macros:
+  - that have different behaviors depending on whether in math or text mode,
+  - absorb Primes, Indices, Exponents (PIE) following LaTeX notations and
+    have them as extra parameters usable in the code. 
+ The primary objective of this code is to be used together with the knowledge
+ package for a proper handling of mathematical notations.
+
+Install:
+ It is sufficient to have the file mathcommand.sty accessible by LaTeX.
+ It can be produced by `make mathcommand.sty' if necessary.
+ The documentation is in the file mathcommand.pdf.
+
+Content of the file mathcommand-ctan.zip:
+ - README.md: this file generated while compiling mathcommand.ins,
+ - mathcommand.sty: the package file (generated using knowledge.ins)
+ - mathcommand.pdf: the user documentation (generated by compiling
+   mathcommand.dtx)
+ - makefile: the makefile. Use 'make all' to generate mathcommand.sty
+   and knowledge.pdf. It can also: clean the directory, make zip
+   version of the sources, or ready for CTAN.
+ - mathcommand.ins: is the file generating mathcommand.sty and
+   README.md from mathcommand.dtx (using docstrip).
+ - mathcommand.dtx: code and documentation.
+
+%    \end{macrocode}
+%</readme>
+% \subsection{Code preparation}
+%<*package>
+%    \begin{macrocode}
+\RequirePackage{expl3}
+\RequirePackage{etoolbox}
+\RequirePackage{xparse}
+\ExplSyntaxOn
+\bool_if_exist:NTF\mathcommand_package_loaded_bool
+ \endinput
+ {\bool_new:N\mathcommand_package_loaded_bool
+  \bool_set_true:N\mathcommand_package_loaded_bool}
+%    \end{macrocode}
+
+
+% \subsection{Absorbing primes, indices and exponents (PIE)}
+% \subsubsection{Parsing pies}
+% We start by defining the code used to absorb "PIEs" from the input stream.
+% The main function defined in this context is 
+% \begin{quote}\AP
+%   \csintro{\__mathcommand_absorb_PIE:nw}
+% \end{quote}
+% which takes some code as first parameter, then absorbs primes, indices and exponents,
+% and finally reinserts the code in the input stream, followed with three braces containing
+% respectively the primes, the index, and the exponent.
+%
+% \AP
+% It works by storing the code to be executed in \csintro{\__mathcommand_absorb_finished_tl},
+% preparing \csintro{\__mathcommand_primes_tl}, \csintro{\__mathcommand_index_t},
+% and \csintro{\__mathcommand_exponent_tl} to contain the "PIEs".
+% Then the core of the parsing is performed by \csintro{\__mathcommand_absorb:w}.
+%    \begin{macrocode}
+\cs_new:Npn\__mathcommand_absorb_PIE:nw#1{
+  \tl_set:Nn\__mathcommand_absorb_finished_tl{#1}
+  \tl_set:Nn\__mathcommand_primes_tl{}
+  \tl_set:Nn\__mathcommand_index_tl{}
+  \tl_set:Nn\__mathcommand_exponent_tl{}  
+  \__mathcommand_absorb:w
+}
+%    \end{macrocode}
+% \AP
+% When the parsing is finished, \csintro{\__mathcommand_absorb_finished:} is
+% executed, which inserts the original code stored in \cs{\__mathcommand_absorb_finished_tl}
+% followed by the "PIEs" in the input stream.
+%    \begin{macrocode}
+\cs_new:Nn\__mathcommand_absorb_finished:{
+  \exp_args:NV\__mathcommand_absorb_finished_:\__mathcommand_exponent_tl
+}
+\cs_new:Nn\__mathcommand_absorb_finished_:{
+  \exp_args:NV\__mathcommand_absorb_finished__:\__mathcommand_index_tl
+}
+\cs_new:Nn\__mathcommand_absorb_finished__:{
+  \exp_args:NV\__mathcommand_absorb_finished_tl\__mathcommand_primes_tl
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Npn\peek_subscript_remove:TFw
+    {\peek_charcode_remove:NTF _}
+\cs_new:Npn\peek_superscript_remove:TFw
+    {\peek_charcode_remove:NTF ^}
+\cs_new:Npn\peek_prime_remove:TFw
+    {\peek_charcode_remove:NTF '}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Nn\__mathcommand_absorb_add_prime:{
+  \tl_put_right:Nn\__mathcommand_primes_tl{'}
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\ExplSyntaxOff
+\expandafter\def\csname g_tmpa_tl\endcsname{_}
+\ExplSyntaxOn
+\cs_new:Nx\__mathcommand_absorb_add_index_after:Nn{
+  \exp_not:N\tl_set:Nn\exp_not:N\__mathcommand_index_tl
+     {\g_tmpa_tl{#2}}
+  #1
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Nn\__mathcommand_absorb_add_exponent_after:Nn{
+  \tl_set:Nn\__mathcommand_exponent_tl{^{#2}}
+  #1
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Npn\__mathcommand_absorb:w{
+   \peek_prime_remove:TFw
+      {\__mathcommand_absorb_add_prime:
+       \__mathcommand_absorb_p:w}
+      \__mathcommand_absorb_:w}
+\cs_new:Npn\__mathcommand_absorb_:w{
+   \peek_subscript_remove:TFw
+      {\__mathcommand_absorb_add_index_after:Nn
+       \__mathcommand_absorb_i:w}
+      \__mathcommand_absorb__:w}
+\cs_new:Npn\__mathcommand_absorb__:w{
+   \peek_superscript_remove:TFw
+      {\__mathcommand_absorb_add_exponent_after:Nn
+       \__mathcommand_absorb_e:w}
+      \__mathcommand_absorb_finished:}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Npn\__mathcommand_absorb_p:w{
+   \peek_prime_remove:TFw
+      {\__mathcommand_absorb_add_prime:
+       \__mathcommand_absorb_p:w}
+      \__mathcommand_absorb_p_:w}
+\cs_new:Npn\__mathcommand_absorb_p_:w{
+   \peek_subscript_remove:TFw
+      {\__mathcommand_absorb_add_index_after:Nn
+       \__mathcommand_absorb_pi:w}
+      \__mathcommand_absorb_finished:}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Npn\__mathcommand_absorb_pi:w{
+   \peek_prime_remove:TFw
+      {\__mathcommand_absorb_add_prime:
+       \__mathcommand_absorb_pi:w}
+      \__mathcommand_absorb_finished:}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Npn\__mathcommand_absorb_e:w{
+   \peek_subscript_remove:TFw
+      {\__mathcommand_absorb_add_index_after:Nn
+       \__mathcommand_absorb_finished:}
+      \__mathcommand_absorb_finished:}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Npn\__mathcommand_absorb_i:w{
+   \peek_prime_remove:TFw
+      {\__mathcommand_absorb_add_prime:
+       \__mathcommand_absorb_pi:w}
+      \__mathcommand_absorb_i_:w}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Npn\__mathcommand_absorb_i_:w{
+   \peek_superscript_remove:TFw
+      {\__mathcommand_absorb_add_exponent_after:Nn
+       \__mathcommand_absorb_finished:}
+      \__mathcommand_absorb_finished:}
+%    \end{macrocode}
+%
+%\subsubsection{Definition of high level commands}
+%
+%    \begin{macrocode}
+\NewDocumentCommand\newcommandPIE{ m o  o m }{
+   \__xparse_check_definable:nNT {#1} \newcommandPIE
+      {
+        \cs_if_exist:NTF #1
+          {
+            \__kernel_msg_error:nnxx { mathcommand } { command-already-defined }
+              { \use:nnn \token_to_str:N #1 { } }
+              { \token_to_str:N \newcommandPIE }
+          }
+          { \__mathcommand_declarecommandPIE:Nnnn #1{#2}{#3}{#4} }
+      }
+}
+\NewDocumentCommand\renewcommandPIE{ m o  o m }{
+   \__xparse_check_definable:nNT {#1} \renewcommandPIE
+      {
+        \cs_if_exist:NTF #1
+          { \__mathcommand_declarecommandPIE:Nnnn #1{#2}{#3}{#4} }
+          {
+            \__kernel_msg_error:nnxx { mathcommand } { command-not-yet-defined }
+              { \use:nnn \token_to_str:N #1 { } }
+              { \token_to_str:N \renewcommandPIE }
+          }
+      }
+}
+\NewDocumentCommand\declarecommandPIE{ m o  o m }{
+   \__xparse_check_definable:nNT {#1} \declarecommandPIE
+        { \__mathcommand_declarecommandPIE:Nnnn #1{#2}{#3}{#4} }
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Nn\__mathcommand_declarecommandPIE:Nnnn{
+   \use:x{
+   \exp_not:N\__mathcommand_new_generic:Nnnn
+      \exp_not:N#1
+      {\IfNoValueTF{#2}{0}{#2}}
+      {\cs_if_exist:NTF#1
+            {\exp_not:N\renewrobustcmd}
+            {\exp_not:N\newrobustcmd}
+         \exp_not:N#1
+         \IfNoValueTF{#2}{}{[#2]}
+         \IfNoValueTF{#3}{}{[{\exp_not:n{#3}}]}}
+      {\exp_not:n{#4}}
+}}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new_protected:Npn\NewDocumentCommandPIE#1#2#3{
+   \__xparse_check_definable:nNT {#1} \NewDocumentCommandPIE
+      {
+        \cs_if_exist:NTF #1
+          {
+            \__kernel_msg_error:nnxx { mathcommand } { command-already-defined }
+              { \use:nnn \token_to_str:N #1 { } }
+              { \token_to_str:N \NewDocumentCommandPIE }
+          }
+          { \__mathcommand_DeclareDocumentCommandPIE:Nnn #1 {#2} {#3} }
+      }
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new_protected:Npn\RenewDocumentCommandPIE#1#2#3{
+   \__xparse_check_definable:nNT {#1} \RenewDocumentCommandPIE
+      {
+        \cs_if_exist:NTF #1
+          { \__mathcommand_DeclareDocumentCommandPIE:Nnn #1 {#2} {#3} }
+          {
+             \__kernel_msg_error:nnxx { xparse } { command-not-yet-defined }
+              { \use:nnn \token_to_str:N #1 { } }
+              { \token_to_str:N \RenewDocumentCommandPIE }
+          }
+      }
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new_protected:Npn\DeclareDocumentCommandPIE#1#2#3{
+   \__xparse_check_definable:nNT {#1} \DeclareDocumentCommandPIE
+      {
+          \__mathcommand_DeclareDocumentCommandPIE:Nnn #1 {#2} {#3}
+      }
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new_protected:Npn\ProvideDocumentCommandPIE#1#2#3{
+   \__xparse_check_definable:nNT {#1} \ProvideDocumentCommandPIE
+      {
+        \cs_if_exist:NTF #1{}
+          {
+            \__mathcommand_DeclareDocumentCommandPIE:Nnn #1 {#2} {#3}
+          }
+      }
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_set:Nn\__mathcommand_DeclareDocumentCommandPIE:Nnn{
+   \group_begin:
+      \DeclareDocumentCommand#1{#2}{}
+      \int_gset_eq:NN\g_tmpa_int\l__xparse_current_arg_int
+   \group_end:
+   \__mathcommand_new_generic:Nnnn
+      #1
+      {\g_tmpa_int}
+      {\DeclareDocumentCommand#1{#2}}
+      {#3}
+}
+%    \end{macrocode}
+% Control token, number parameters, defining command, code
+%    \begin{macrocode}
+\cs_new:Nn\__mathcommand_new_generic:Nnnn{
+   \int_compare:nNnTF{#2}>{6}
+    {\PackageError{mathcommand} 
+          {At~most~6~parameters~in~PIE~commands~when~defining~`\token_to_str:N#1'}
+          {PIE~commands~(mathcommand~package)~do~not~accept~more~than~six~parameters.}}
+    {\int_case:nn{#2}
+     {{0} {\cs_new:cpn{\cs_to_str:N#1~PIE~code}##1##2##3}
+      {1} {\cs_new:cpn{\cs_to_str:N#1~PIE~code}##1##2##3##4}
+      {2} {\cs_new:cpn{\cs_to_str:N#1~PIE~code}##1##2##3##4##5}
+      {3} {\cs_new:cpn{\cs_to_str:N#1~PIE~code}##1##2##3##4##5##6}
+      {4} {\cs_new:cpn{\cs_to_str:N#1~PIE~code}##1##2##3##4##5##6##7}
+      {5} {\cs_new:cpn{\cs_to_str:N#1~PIE~code}##1##2##3##4##5##6##7##8}
+      {6} {\cs_new:cpn{\cs_to_str:N#1~PIE~code}##1##2##3##4##5##6##7##8##9}}
+    {#4}
+   \use:x{
+      \exp_not:n{#3}
+      {\exp_not:N\__mathcommand_absorb_PIE:nw
+          {\exp_not:c{\cs_to_str:N#1~PIE~code}
+          \int_case:nn{#2}
+          {{0}{}
+           {1}{\exp_not:n{{##1}}}
+           {2}{\exp_not:n{{##1}{##2}}}
+           {3}{\exp_not:n{{##1}{##2}{##3}}}
+           {4}{\exp_not:n{{##1}{##2}{##3}{##4}}}
+           {5}{\exp_not:n{{##1}{##2}{##3}{##4}{##5}}}
+           {6}{\exp_not:n{{##1}{##2}{##3}{##4}{##5}{##6}}}}}}}
+   }
+}
+%    \end{macrocode}
+%
+%
+%  \subsubsection{Auxiliary functions}
+%
+%
+%    \begin{macrocode}
+\def\lettersUppercase{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
+\def\lettersLowercase{abcdefghijklmnopqrstuvwxyz}
+\xdef\lettersAll{\lettersLowercase\lettersUppercase}
+\def\lettersGreekLowercase{\alpha\beta\gamma\delta\epsilon\varepsilon\zeta\eta\theta\vartheta\iota\kappa\lambda\mu\nu\xi\pi\varpi\rho\varrho\sigma\varsigma\tau\upsilon\phi\varphi\chi\psi\omega}
+\def\lettersGreekUppercase{\Gamma\Delta\Theta\Lambda\Xi\Pi\Sigma\Upsilon\Phi\Psi\Omega}
+\xdef\lettersGreekAll{\lettersGreekLowercase\lettersGreekUppercase}
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\cs_set_eq:NN\IfEmptyTF\tl_if_empty:nTF
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Npn\EmptyContent#1{
+    \tl_if_empty:nTF{#1}{{}}{
+        \__mathcommand_EmptyContent:w #1*\end_marker:
+    }
+}
+\cs_new:Npn\__mathcommand_EmptyContent:w #1#2\end_marker:{
+    #1*
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Npn\GetContent#1{
+    \tl_if_empty:nTF{#1}{}{
+        \__mathcommand_GetContent:w #1*\end_marker:
+    }
+}
+\cs_new:Npn\__mathcommand_GetContent:w #1#2\end_marker:{
+    #1*
+}
+%    \end{macrocode}
+%
+%
+% \subsection{Separating math and text macros}
+%
+%
+%    \begin{macrocode}
+\tl_const:Nn\__mathcommand_prefix_math_tl{Math~}
+\tl_const:Nn\__mathcommand_prefix_text_tl{Text~}
+\tl_const:Nn\__mathcommand_prefix_store_tl{LaTeX}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Nn\__mathcommand_to_mathtl:N{\__mathcommand_prefix_math_tl\cs_to_str:N#1}
+\cs_new:Nn\__mathcommand_to_texttl:N{\__mathcommand_prefix_text_tl\cs_to_str:N#1}
+\cs_new:Nn\__mathcommand_to_storetl:N{\__mathcommand_prefix_store_tl\cs_to_str:N#1}
+\cs_new:Nn\__mathcommand_coretl:N
+    {\expandafter\__command_coretl:w\string#1\end_mark}
+\cs_new:Npn\__command_coretl:w#1~#2\end_mark{#2}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Npn\__mathcommand_if_exist:NTF
+  {\cs_if_exist:NTF}
+\cs_new:Npn\__mathcommand_if_exist_math:NTF#1
+  {\cs_if_exist:cTF{\__mathcommand_to_mathtl:N#1}}
+\cs_new:Npn\__mathcommand_if_exist_text:NTF#1
+  {\cs_if_exist:cTF{\__mathcommand_to_texttl:N#1}}
+\cs_new:Npn\__mathcommand_if_exist_text_or_math:NTF#1
+  {\__mathcommand_if_exist_math:NTF#1
+      \use_i:nn{\__mathcommand_if_exist_text:NTF#1}}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Nn\__mathcommand_error_if_exist_math:NF{
+   \cs_if_exist:cTF{\__mathcommand_to_mathtl:N#1}
+   {\exp_args:Nnx\PackageError{}
+       {Command~`\token_to_str:N#1'~already~exists~in~math~mode}
+       {}
+   }{#2}
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Nn\__mathcommand_error_if_exist_text:NF{
+   \cs_if_exist:cTF{\__mathcommand_to_texttl:N#1}
+   {\exp_args:Nnx\PackageError{}
+       {Command~`\token_to_str:N#1'~already~exists~in~text~mode}
+       {}
+   }{#2}
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Nn\__mathcommand_error_if_not_exist_math:NF{
+   \cs_if_exist:cTF{\__mathcommand_to_mathtl:N#1}
+     {#2}
+     {\exp_args:Nnx\PackageError{}
+       {Command~`\token_to_str:N#1'~does~not~exist~in~math~mode}
+       {}
+   }
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Nn\__mathcommand_error_if_not_exist_text:NF{
+   \cs_if_exist:cTF{\__mathcommand_to_texttl:N#1}
+     {#2}
+     {\exp_args:Nnx\PackageError{}
+       {Command~`\token_to_str:N#1'~does~not~exist~in~text~mode}
+       {}
+   }
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Nn\__mathcommand_error_unknownmath:N{
+   \exp_args:Nnx\PackageError{}
+       {Command~`\token_to_str:c{\__mathcommand_coretl:N #1}'~does~not~exist~in~math~mode}
+       {}
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Nn\__mathcommand_error_unknowntext:N{
+   \exp_args:Nnx\PackageError{}
+       {Command~`\token_to_str:c{\__mathcommand_coretl:N #1}'~does~not~exist~in~text~mode}
+       {}
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\cs_new:Nn\__mathcommand_try_math:N{
+   \cs_if_exist:NTF#1#1{\__mathcommand_error_unknownmath:N#1}
+}
+\cs_new:Nn\__mathcommand_try_text:N{
+   \cs_if_exist:NTF#1#1{\__mathcommand_error_unknowntext:N#1}
+}
+%    \end{macrocode}
+% \AP
+% The macro \csintro{\__mathcommand_create_fork:N} takes a control sequence,
+% and creates the forking code that executes either the math branch of the text branch.
+% If this forking code is already present, the command does nothing.
+% However, if some macro was already associated with this control sequence, then
+% it is copied to the "math variant", the "text variant" as well as the stored.
+%    \begin{macrocode}
+\cs_set:Nn\__mathcommand_create_fork:N{
+   \let\__mathcommand_tmp_cs\undefined
+   \exp_args:NNx
+      \cs_new_protected:Npn\__mathcommand_tmp_cs{
+         \exp_not:N\mode_if_math:TF
+          {\exp_not:N\__mathcommand_try_math:N\exp_not:c{\__mathcommand_to_mathtl:N#1}}
+          {\exp_not:N\__mathcommand_try_text:N\exp_not:c{\__mathcommand_to_texttl:N#1}}
+      }
+   \cs_if_exist:NTF#1{
+     \cs_if_eq:NNTF#1\__mathcommand_tmp_cs
+       { }
+       { \cs_set_eq:cN{\__mathcommand_to_storetl:N#1}#1
+         \cs_set_eq:cN{\__mathcommand_to_mathtl:N#1}#1
+         \cs_set_eq:cN{\__mathcommand_to_texttl:N#1}#1
+         \cs_set_eq:NN#1\__mathcommand_tmp_cs
+       }
+     }{ \cs_set_eq:NN#1\__mathcommand_tmp_cs }
+}
+%    \end{macrocode}
+% \subsection{Definition of the high level commands}
+%    \begin{macrocode}
+\NewDocumentCommand\declarecommand{m}{
+   \__xparse_check_definable:nNT {#1} \declarecommand
+   {
+     \cs_if_exist:NTF#1
+        {\renewcommand#1}
+        {\newcommand#1}
+   }
+}
+\newrobustcmd\storecommand[2][\__mathcommand_prefix_store_tl]{
+   \__xparse_check_definable:nNT {#2} \storecommand
+   {
+       \cs_if_exist:NTF#2{
+           \cs_set_eq:cN{\__mathcommand_prefix_store_tl\cs_to_str:N#2}#2
+       }
+       {
+           \PackageError{mathcommand} 
+          {The~command~`\token_to_str:N#2'~does~not~exist~(in~\token_to_str:N\storecommand)}
+          {}
+       }
+   }
+}
+
+\NewDocumentCommand\NewDocumentMathCommand{m}{
+   \__xparse_check_definable:nNT {#1} \NewDocumentMathCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_exist_math:NF#1
+      {\exp_args:Nc\DeclareDocumentCommand{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\NewDocumentTextCommand{m}{
+   \__xparse_check_definable:nNT {#1} \NewDocumentTextCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_exist_text:NF#1
+      {\exp_args:Nc\DeclareDocumentCommand{\__mathcommand_to_texttl:N#1}}
+   }
+}
+\NewDocumentCommand\newmathcommand{m}{
+   \__xparse_check_definable:nNT {#1} \newmathcommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_exist_math:NF#1
+      {\exp_args:Nc\newcommand{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\newtextcommand{m}{
+   \__xparse_check_definable:nNT {#1} \newtextcommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_exist_text:NF#1
+      {\exp_args:Nc\newcommand{\__mathcommand_to_texttl:N#1}}
+   }
+}
+\NewDocumentCommand\RenewDocumentMathCommand{m}{
+   \__xparse_check_definable:nNT {#1} \RenewDocumentMathCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_not_exist_math:NF#1
+      {\exp_args:Nc\DeclareDocumentCommand{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\RenewDocumentTextCommand{m}{
+   \__xparse_check_definable:nNT {#1} \RenewDocumentMathCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_not_exist_text:NF#1
+      {\exp_args:Nc\DeclareDocumentCommand{\__mathcommand_to_texttl:N#1}}
+   }
+}
+\NewDocumentCommand\renewmathcommand{m}{
+   \__xparse_check_definable:nNT {#1} \renewmathcommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_not_exist_math:NF#1
+      {\exp_args:Nc\renewcommand{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\renewtextcommand{m}{
+   \__xparse_check_definable:nNT {#1} \renewtextcommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_not_exist_text:NF#1
+      {\exp_args:Nc\renewcommand{\__mathcommand_to_texttl:N#1}}
+   }
+}
+\NewDocumentCommand\declaremathcommand{m}{
+   \__xparse_check_definable:nNT {#1} \renewmathcommand
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\declarecommand{\__mathcommand_to_mathtl:N#1}
+   }
+}
+\NewDocumentCommand\declaretextcommand{m}{
+   \__xparse_check_definable:nNT {#1} \renewtextcommand
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\declarecommand{\__mathcommand_to_texttl:N#1}
+   }
+}
+
+\NewDocumentCommand\DeclareDocumentMathCommand{m}{
+   \__xparse_check_definable:nNT {#1} \DeclareDocumentMathCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\DeclareDocumentCommand{\__mathcommand_to_mathtl:N#1}
+   }
+}
+\NewDocumentCommand\DeclareDocumentTextCommand{m}{
+   \__xparse_check_definable:nNT {#1} \DeclareDocumentTextCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\DeclareDocumentCommand{\__mathcommand_to_texttl:N#1}
+   }
+}
+\NewDocumentCommand\ProvideDocumentMathCommand{mmm}{
+   \__xparse_check_definable:nNT {#1} \ProvideDocumentMathCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\ProvideDocumentCommand{\__mathcommand_to_mathtl:N#1}{#2}{#3}
+   }
+}
+\NewDocumentCommand\ProvideDocumentTextCommand{m}{
+   \__xparse_check_definable:nNT {#1} \ProvideDocumentTextCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\ProvideDocumentCommand{\__mathcommand_to_texttl:N#1}
+   }
+}
+%    \end{macrocode}
+%
+% \subsection{Definition of the high level combined commands}
+%
+%    \begin{macrocode}
+\NewDocumentCommand\NewDocumentMathCommandPIE{m}{
+   \__xparse_check_definable:nNT {#1} \NewDocumentMathCommandPIE
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_exist_math:NF#1
+      {\exp_args:Nc\DeclareDocumentCommandPIE{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\newmathcommandPIE{m}{
+   \__xparse_check_definable:nNT {#1} \newmathcommandPiE
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_exist_math:NF#1
+      {\exp_args:Nc\newcommandPIE{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\RenewDocumentMathCommandPIE{m}{
+   \__xparse_check_definable:nNT {#1} \RenewDocumentMathCommandPIE
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_not_exist_math:NF#1
+      {\exp_args:Nc\DeclareDocumentCommandPIE{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\renewmathcommandPIE{m}{
+   \__xparse_check_definable:nNT {#1} \renewmathcommandPIE
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_not_exist_math:NF#1
+      {\exp_args:Nc\renewcommandPIE{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\DeclareDocumentMathCommandPIE{m}{
+   \__xparse_check_definable:nNT {#1} \DeclareDocumentMathCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\DeclareDocumentCommand{\__mathcommand_to_mathtl:N#1}
+   }
+}
+\NewDocumentCommand\declaremathcommandPIE{m}{
+   \__xparse_check_definable:nNT {#1} \declaremathcommandPIE
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\declarecommandPIE{\__mathcommand_to_mathtl:N#1}
+   }
+}
+
+\NewDocumentCommand\ProvideDocumentMathCommandPIE{mmm}{
+   \__xparse_check_definable:nNT {#1} \ProvideDocumentMathCommandPIE
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\ProvideDocumentCommandPIE{\__mathcommand_to_mathtl:N#1}{#2}{#3}
+   }
+}
+%    \end{macrocode}
+%
+% \subsection{Looping for command definitions}
+%
+%   
+%    \begin{macrocode}
+\NewDocumentCommand\LoopCommands{ m ooooooo m }{
+   \IfNoValueTF{#2}
+     {\cs_set:Nn\__tmp_two:n{\exp_not:c{##1}}}
+     {\cs_set:Nn\__tmp_two:n{\exp_not:c{#2}}}
+   \IfNoValueTF{#3}
+     {\cs_set:Nn\__tmp_three:n{\exp_not:c{##1}}}
+     {\cs_set:Nn\__tmp_three:n{\exp_not:c{#3}}}
+   \IfNoValueTF{#4}
+     {\cs_set:Nn\__tmp_four:n{\exp_not:c{##1}}}
+     {\cs_set:Nn\__tmp_four:n{\exp_not:c{#4}}}
+   \IfNoValueTF{#5}
+     {\cs_set:Nn\__tmp_five:n{\exp_not:c{##1}}}
+     {\cs_set:Nn\__tmp_five:n{\exp_not:c{#5}}}
+   \IfNoValueTF{#6}
+     {\cs_set:Nn\__tmp_six:n{\exp_not:c{##1}}}
+     {\cs_set:Nn\__tmp_six:n{\exp_not:c{#6}}}
+   \IfNoValueTF{#7}
+     {\cs_set:Nn\__tmp_seven:n{\exp_not:c{##1}}}
+     {\cs_set:Nn\__tmp_seven:n{\exp_not:c{#7}}}
+   \IfNoValueTF{#8}
+     {\cs_set:Nn\__tmp_eight:n{\exp_not:c{##1}}}
+     {\cs_set:Nn\__tmp_eight:n{\exp_not:c{#8}}}
+   %
+   \cs_gset:Nn\g_tmpb_cs:nnnnnnnn{#9}
+   %
+   \cs_gset:Nn\g_tmpa_cs:n{
+     \tl_set:Nn\l_tmpa_tl{##1}
+     \use:x{
+        \exp_not:N\g_tmpb_cs:nnnnnnnn
+           {\l_tmpa_tl}
+           \__tmp_two:n{\l_tmpa_tl}
+           \__tmp_three:n{\l_tmpa_tl}
+           \__tmp_four:n{\l_tmpa_tl}
+           \__tmp_five:n{\l_tmpa_tl}
+           \__tmp_six:n{\l_tmpa_tl}
+           \__tmp_seven:n{\l_tmpa_tl}
+           \__tmp_eight:n{\l_tmpa_tl}}
+     }
+  \exp_args:Nx\tl_map_inline:nn{#1}
+     {\tl_if_blank:nTF{##1}
+       {}
+       {\g_tmpa_cs:n{\__mathcommand_getbasename:n{##1}}}
+     }
+}
+\cs_new:Nn\__mathcommand_getbasename:n{
+      \tl_if_single:nTF{#1}{
+         \token_if_cs:NTF#1
+            {\cs_to_str:N#1}
+            {#1}
+      }{#1}
+}
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\ExplSyntaxOff
+%    \end{macrocode}
+%
+% \end{document}
+


Property changes on: trunk/Master/texmf-dist/source/latex/mathcommand/mathcommand.dtx
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/source/latex/mathcommand/mathcommand.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/mathcommand/mathcommand.ins	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/mathcommand/mathcommand.ins	2019-05-12 20:18:41 UTC (rev 51105)
@@ -0,0 +1,68 @@
+%%
+%% Copyright (C) 2017 by Thomas Colcombet
+%%
+%% This file may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.2 of this license or (at your option) any later 
+%% version. The latest version of this license is in:
+%%
+
+%% http://www.latex-project.org/lppl.txt
+%%
+%% and version 1.2 or later is part of all distributions of
+%% LaTeX version 1999/12/01 or later.
+%%
+\input docstrip.tex
+\keepsilent
+\askforoverwritefalse
+\preamble
+
+This is a generated file. Copyright (C) 2019 by Thomas Colcombet
+
+This file may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either
+version 1.2 of this license or (at your option) any later
+version.  The latest version of this license is in:
+
+       http://www.latex-project.org/lppl.txt
+
+and version 1.2 or later is part of all distributions of
+LaTeX version 1999/12/01 or later.
+
+\endpreamble
+
+\generate{%
+  \file{mathcommand.sty}{%
+    \from{mathcommand.dtx}{head,package}%
+  }%
+}
+
+
+
+\nopreamble\nopostamble
+\def\MetaPrefix{}
+\generate{%
+  \file{README.md}{
+    \usepreamble\empty
+    \usepostamble\empty%
+    \from{mathcommand.dtx}{readme}%
+  }}%
+
+
+
+
+\obeyspaces
+\Msg{****************************************************}
+\Msg{*}
+\Msg{* To finish the installation you have to move the }
+\Msg{* following file into a directory searched by TeX:}
+\Msg{*}
+\Msg{*     knowledge.sty}
+\Msg{*}
+\Msg{* To produce the documentation run the file *}
+\Msg{* knowledge.dtx through LaTeX.}
+\Msg{*}
+\Msg{****************************************************}
+
+\endbatchfile
+

Added: trunk/Master/texmf-dist/tex/latex/mathcommand/mathcommand.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/mathcommand/mathcommand.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/mathcommand/mathcommand.sty	2019-05-12 20:18:41 UTC (rev 51105)
@@ -0,0 +1,577 @@
+%%
+%% This is file `mathcommand.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% mathcommand.dtx  (with options: `head,package')
+%% 
+%% This is a generated file. Copyright (C) 2019 by Thomas Colcombet
+%% 
+%% This file may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.2 of this license or (at your option) any later
+%% version.  The latest version of this license is in:
+%% 
+%%        http://www.latex-project.org/lppl.txt
+%% 
+%% and version 1.2 or later is part of all distributions of
+%% LaTeX version 1999/12/01 or later.
+%% 
+\usepackage{expl3}
+\ProvidesExplPackage{mathcommand}{2019/05/12}{1.01}{}
+%%%%%%%%%%
+\RequirePackage{expl3}
+\RequirePackage{etoolbox}
+\RequirePackage{xparse}
+\ExplSyntaxOn
+\bool_if_exist:NTF\mathcommand_package_loaded_bool
+ \endinput
+ {\bool_new:N\mathcommand_package_loaded_bool
+  \bool_set_true:N\mathcommand_package_loaded_bool}
+
+\cs_new:Npn\__mathcommand_absorb_PIE:nw#1{
+  \tl_set:Nn\__mathcommand_absorb_finished_tl{#1}
+  \tl_set:Nn\__mathcommand_primes_tl{}
+  \tl_set:Nn\__mathcommand_index_tl{}
+  \tl_set:Nn\__mathcommand_exponent_tl{}
+  \__mathcommand_absorb:w
+}
+\cs_new:Nn\__mathcommand_absorb_finished:{
+  \exp_args:NV\__mathcommand_absorb_finished_:\__mathcommand_exponent_tl
+}
+\cs_new:Nn\__mathcommand_absorb_finished_:{
+  \exp_args:NV\__mathcommand_absorb_finished__:\__mathcommand_index_tl
+}
+\cs_new:Nn\__mathcommand_absorb_finished__:{
+  \exp_args:NV\__mathcommand_absorb_finished_tl\__mathcommand_primes_tl
+}
+\cs_new:Npn\peek_subscript_remove:TFw
+    {\peek_charcode_remove:NTF _}
+\cs_new:Npn\peek_superscript_remove:TFw
+    {\peek_charcode_remove:NTF ^}
+\cs_new:Npn\peek_prime_remove:TFw
+    {\peek_charcode_remove:NTF '}
+\cs_new:Nn\__mathcommand_absorb_add_prime:{
+  \tl_put_right:Nn\__mathcommand_primes_tl{'}
+}
+\ExplSyntaxOff
+\expandafter\def\csname g_tmpa_tl\endcsname{_}
+\ExplSyntaxOn
+\cs_new:Nx\__mathcommand_absorb_add_index_after:Nn{
+  \exp_not:N\tl_set:Nn\exp_not:N\__mathcommand_index_tl
+     {\g_tmpa_tl{#2}}
+  #1
+}
+\cs_new:Nn\__mathcommand_absorb_add_exponent_after:Nn{
+  \tl_set:Nn\__mathcommand_exponent_tl{^{#2}}
+  #1
+}
+\cs_new:Npn\__mathcommand_absorb:w{
+   \peek_prime_remove:TFw
+      {\__mathcommand_absorb_add_prime:
+       \__mathcommand_absorb_p:w}
+      \__mathcommand_absorb_:w}
+\cs_new:Npn\__mathcommand_absorb_:w{
+   \peek_subscript_remove:TFw
+      {\__mathcommand_absorb_add_index_after:Nn
+       \__mathcommand_absorb_i:w}
+      \__mathcommand_absorb__:w}
+\cs_new:Npn\__mathcommand_absorb__:w{
+   \peek_superscript_remove:TFw
+      {\__mathcommand_absorb_add_exponent_after:Nn
+       \__mathcommand_absorb_e:w}
+      \__mathcommand_absorb_finished:}
+\cs_new:Npn\__mathcommand_absorb_p:w{
+   \peek_prime_remove:TFw
+      {\__mathcommand_absorb_add_prime:
+       \__mathcommand_absorb_p:w}
+      \__mathcommand_absorb_p_:w}
+\cs_new:Npn\__mathcommand_absorb_p_:w{
+   \peek_subscript_remove:TFw
+      {\__mathcommand_absorb_add_index_after:Nn
+       \__mathcommand_absorb_pi:w}
+      \__mathcommand_absorb_finished:}
+\cs_new:Npn\__mathcommand_absorb_pi:w{
+   \peek_prime_remove:TFw
+      {\__mathcommand_absorb_add_prime:
+       \__mathcommand_absorb_pi:w}
+      \__mathcommand_absorb_finished:}
+\cs_new:Npn\__mathcommand_absorb_e:w{
+   \peek_subscript_remove:TFw
+      {\__mathcommand_absorb_add_index_after:Nn
+       \__mathcommand_absorb_finished:}
+      \__mathcommand_absorb_finished:}
+\cs_new:Npn\__mathcommand_absorb_i:w{
+   \peek_prime_remove:TFw
+      {\__mathcommand_absorb_add_prime:
+       \__mathcommand_absorb_pi:w}
+      \__mathcommand_absorb_i_:w}
+\cs_new:Npn\__mathcommand_absorb_i_:w{
+   \peek_superscript_remove:TFw
+      {\__mathcommand_absorb_add_exponent_after:Nn
+       \__mathcommand_absorb_finished:}
+      \__mathcommand_absorb_finished:}
+\NewDocumentCommand\newcommandPIE{ m o  o m }{
+   \__xparse_check_definable:nNT {#1} \newcommandPIE
+      {
+        \cs_if_exist:NTF #1
+          {
+            \__kernel_msg_error:nnxx { mathcommand } { command-already-defined }
+              { \use:nnn \token_to_str:N #1 { } }
+              { \token_to_str:N \newcommandPIE }
+          }
+          { \__mathcommand_declarecommandPIE:Nnnn #1{#2}{#3}{#4} }
+      }
+}
+\NewDocumentCommand\renewcommandPIE{ m o  o m }{
+   \__xparse_check_definable:nNT {#1} \renewcommandPIE
+      {
+        \cs_if_exist:NTF #1
+          { \__mathcommand_declarecommandPIE:Nnnn #1{#2}{#3}{#4} }
+          {
+            \__kernel_msg_error:nnxx { mathcommand } { command-not-yet-defined }
+              { \use:nnn \token_to_str:N #1 { } }
+              { \token_to_str:N \renewcommandPIE }
+          }
+      }
+}
+\NewDocumentCommand\declarecommandPIE{ m o  o m }{
+   \__xparse_check_definable:nNT {#1} \declarecommandPIE
+        { \__mathcommand_declarecommandPIE:Nnnn #1{#2}{#3}{#4} }
+}
+\cs_new:Nn\__mathcommand_declarecommandPIE:Nnnn{
+   \use:x{
+   \exp_not:N\__mathcommand_new_generic:Nnnn
+      \exp_not:N#1
+      {\IfNoValueTF{#2}{0}{#2}}
+      {\cs_if_exist:NTF#1
+            {\exp_not:N\renewrobustcmd}
+            {\exp_not:N\newrobustcmd}
+         \exp_not:N#1
+         \IfNoValueTF{#2}{}{[#2]}
+         \IfNoValueTF{#3}{}{[{\exp_not:n{#3}}]}}
+      {\exp_not:n{#4}}
+}}
+\cs_new_protected:Npn\NewDocumentCommandPIE#1#2#3{
+   \__xparse_check_definable:nNT {#1} \NewDocumentCommandPIE
+      {
+        \cs_if_exist:NTF #1
+          {
+            \__kernel_msg_error:nnxx { mathcommand } { command-already-defined }
+              { \use:nnn \token_to_str:N #1 { } }
+              { \token_to_str:N \NewDocumentCommandPIE }
+          }
+          { \__mathcommand_DeclareDocumentCommandPIE:Nnn #1 {#2} {#3} }
+      }
+}
+\cs_new_protected:Npn\RenewDocumentCommandPIE#1#2#3{
+   \__xparse_check_definable:nNT {#1} \RenewDocumentCommandPIE
+      {
+        \cs_if_exist:NTF #1
+          { \__mathcommand_DeclareDocumentCommandPIE:Nnn #1 {#2} {#3} }
+          {
+             \__kernel_msg_error:nnxx { xparse } { command-not-yet-defined }
+              { \use:nnn \token_to_str:N #1 { } }
+              { \token_to_str:N \RenewDocumentCommandPIE }
+          }
+      }
+}
+\cs_new_protected:Npn\DeclareDocumentCommandPIE#1#2#3{
+   \__xparse_check_definable:nNT {#1} \DeclareDocumentCommandPIE
+      {
+          \__mathcommand_DeclareDocumentCommandPIE:Nnn #1 {#2} {#3}
+      }
+}
+\cs_new_protected:Npn\ProvideDocumentCommandPIE#1#2#3{
+   \__xparse_check_definable:nNT {#1} \ProvideDocumentCommandPIE
+      {
+        \cs_if_exist:NTF #1{}
+          {
+            \__mathcommand_DeclareDocumentCommandPIE:Nnn #1 {#2} {#3}
+          }
+      }
+}
+\cs_set:Nn\__mathcommand_DeclareDocumentCommandPIE:Nnn{
+   \group_begin:
+      \DeclareDocumentCommand#1{#2}{}
+      \int_gset_eq:NN\g_tmpa_int\l__xparse_current_arg_int
+   \group_end:
+   \__mathcommand_new_generic:Nnnn
+      #1
+      {\g_tmpa_int}
+      {\DeclareDocumentCommand#1{#2}}
+      {#3}
+}
+\cs_new:Nn\__mathcommand_new_generic:Nnnn{
+   \int_compare:nNnTF{#2}>{6}
+    {\PackageError{mathcommand}
+          {At~most~6~parameters~in~PIE~commands~when~defining~`\token_to_str:N#1'}
+          {PIE~commands~(mathcommand~package)~do~not~accept~more~than~six~parameters.}}
+    {\int_case:nn{#2}
+     {{0} {\cs_new:cpn{\cs_to_str:N#1~PIE~code}##1##2##3}
+      {1} {\cs_new:cpn{\cs_to_str:N#1~PIE~code}##1##2##3##4}
+      {2} {\cs_new:cpn{\cs_to_str:N#1~PIE~code}##1##2##3##4##5}
+      {3} {\cs_new:cpn{\cs_to_str:N#1~PIE~code}##1##2##3##4##5##6}
+      {4} {\cs_new:cpn{\cs_to_str:N#1~PIE~code}##1##2##3##4##5##6##7}
+      {5} {\cs_new:cpn{\cs_to_str:N#1~PIE~code}##1##2##3##4##5##6##7##8}
+      {6} {\cs_new:cpn{\cs_to_str:N#1~PIE~code}##1##2##3##4##5##6##7##8##9}}
+    {#4}
+   \use:x{
+      \exp_not:n{#3}
+      {\exp_not:N\__mathcommand_absorb_PIE:nw
+          {\exp_not:c{\cs_to_str:N#1~PIE~code}
+          \int_case:nn{#2}
+          {{0}{}
+           {1}{\exp_not:n{{##1}}}
+           {2}{\exp_not:n{{##1}{##2}}}
+           {3}{\exp_not:n{{##1}{##2}{##3}}}
+           {4}{\exp_not:n{{##1}{##2}{##3}{##4}}}
+           {5}{\exp_not:n{{##1}{##2}{##3}{##4}{##5}}}
+           {6}{\exp_not:n{{##1}{##2}{##3}{##4}{##5}{##6}}}}}}}
+   }
+}
+\def\lettersUppercase{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
+\def\lettersLowercase{abcdefghijklmnopqrstuvwxyz}
+\xdef\lettersAll{\lettersLowercase\lettersUppercase}
+\def\lettersGreekLowercase{\alpha\beta\gamma\delta\epsilon\varepsilon\zeta\eta\theta\vartheta\iota\kappa\lambda\mu\nu\xi\pi\varpi\rho\varrho\sigma\varsigma\tau\upsilon\phi\varphi\chi\psi\omega}
+\def\lettersGreekUppercase{\Gamma\Delta\Theta\Lambda\Xi\Pi\Sigma\Upsilon\Phi\Psi\Omega}
+\xdef\lettersGreekAll{\lettersGreekLowercase\lettersGreekUppercase}
+\cs_set_eq:NN\IfEmptyTF\tl_if_empty:nTF
+\cs_new:Npn\EmptyContent#1{
+    \tl_if_empty:nTF{#1}{{}}{
+        \__mathcommand_EmptyContent:w #1*\end_marker:
+    }
+}
+\cs_new:Npn\__mathcommand_EmptyContent:w #1#2\end_marker:{
+    #1*
+}
+\cs_new:Npn\GetContent#1{
+    \tl_if_empty:nTF{#1}{}{
+        \__mathcommand_GetContent:w #1*\end_marker:
+    }
+}
+\cs_new:Npn\__mathcommand_GetContent:w #1#2\end_marker:{
+    #1*
+}
+\tl_const:Nn\__mathcommand_prefix_math_tl{Math~}
+\tl_const:Nn\__mathcommand_prefix_text_tl{Text~}
+\tl_const:Nn\__mathcommand_prefix_store_tl{LaTeX}
+\cs_new:Nn\__mathcommand_to_mathtl:N{\__mathcommand_prefix_math_tl\cs_to_str:N#1}
+\cs_new:Nn\__mathcommand_to_texttl:N{\__mathcommand_prefix_text_tl\cs_to_str:N#1}
+\cs_new:Nn\__mathcommand_to_storetl:N{\__mathcommand_prefix_store_tl\cs_to_str:N#1}
+\cs_new:Nn\__mathcommand_coretl:N
+    {\expandafter\__command_coretl:w\string#1\end_mark}
+\cs_new:Npn\__command_coretl:w#1~#2\end_mark{#2}
+\cs_new:Npn\__mathcommand_if_exist:NTF
+  {\cs_if_exist:NTF}
+\cs_new:Npn\__mathcommand_if_exist_math:NTF#1
+  {\cs_if_exist:cTF{\__mathcommand_to_mathtl:N#1}}
+\cs_new:Npn\__mathcommand_if_exist_text:NTF#1
+  {\cs_if_exist:cTF{\__mathcommand_to_texttl:N#1}}
+\cs_new:Npn\__mathcommand_if_exist_text_or_math:NTF#1
+  {\__mathcommand_if_exist_math:NTF#1
+      \use_i:nn{\__mathcommand_if_exist_text:NTF#1}}
+\cs_new:Nn\__mathcommand_error_if_exist_math:NF{
+   \cs_if_exist:cTF{\__mathcommand_to_mathtl:N#1}
+   {\exp_args:Nnx\PackageError{}
+       {Command~`\token_to_str:N#1'~already~exists~in~math~mode}
+       {}
+   }{#2}
+}
+\cs_new:Nn\__mathcommand_error_if_exist_text:NF{
+   \cs_if_exist:cTF{\__mathcommand_to_texttl:N#1}
+   {\exp_args:Nnx\PackageError{}
+       {Command~`\token_to_str:N#1'~already~exists~in~text~mode}
+       {}
+   }{#2}
+}
+\cs_new:Nn\__mathcommand_error_if_not_exist_math:NF{
+   \cs_if_exist:cTF{\__mathcommand_to_mathtl:N#1}
+     {#2}
+     {\exp_args:Nnx\PackageError{}
+       {Command~`\token_to_str:N#1'~does~not~exist~in~math~mode}
+       {}
+   }
+}
+\cs_new:Nn\__mathcommand_error_if_not_exist_text:NF{
+   \cs_if_exist:cTF{\__mathcommand_to_texttl:N#1}
+     {#2}
+     {\exp_args:Nnx\PackageError{}
+       {Command~`\token_to_str:N#1'~does~not~exist~in~text~mode}
+       {}
+   }
+}
+\cs_new:Nn\__mathcommand_error_unknownmath:N{
+   \exp_args:Nnx\PackageError{}
+       {Command~`\token_to_str:c{\__mathcommand_coretl:N #1}'~does~not~exist~in~math~mode}
+       {}
+}
+\cs_new:Nn\__mathcommand_error_unknowntext:N{
+   \exp_args:Nnx\PackageError{}
+       {Command~`\token_to_str:c{\__mathcommand_coretl:N #1}'~does~not~exist~in~text~mode}
+       {}
+}
+\cs_new:Nn\__mathcommand_try_math:N{
+   \cs_if_exist:NTF#1#1{\__mathcommand_error_unknownmath:N#1}
+}
+\cs_new:Nn\__mathcommand_try_text:N{
+   \cs_if_exist:NTF#1#1{\__mathcommand_error_unknowntext:N#1}
+}
+\cs_set:Nn\__mathcommand_create_fork:N{
+   \let\__mathcommand_tmp_cs\undefined
+   \exp_args:NNx
+      \cs_new_protected:Npn\__mathcommand_tmp_cs{
+         \exp_not:N\mode_if_math:TF
+          {\exp_not:N\__mathcommand_try_math:N\exp_not:c{\__mathcommand_to_mathtl:N#1}}
+          {\exp_not:N\__mathcommand_try_text:N\exp_not:c{\__mathcommand_to_texttl:N#1}}
+      }
+   \cs_if_exist:NTF#1{
+     \cs_if_eq:NNTF#1\__mathcommand_tmp_cs
+       { }
+       { \cs_set_eq:cN{\__mathcommand_to_storetl:N#1}#1
+         \cs_set_eq:cN{\__mathcommand_to_mathtl:N#1}#1
+         \cs_set_eq:cN{\__mathcommand_to_texttl:N#1}#1
+         \cs_set_eq:NN#1\__mathcommand_tmp_cs
+       }
+     }{ \cs_set_eq:NN#1\__mathcommand_tmp_cs }
+}
+\NewDocumentCommand\declarecommand{m}{
+   \__xparse_check_definable:nNT {#1} \declarecommand
+   {
+     \cs_if_exist:NTF#1
+        {\renewcommand#1}
+        {\newcommand#1}
+   }
+}
+\newrobustcmd\storecommand[2][\__mathcommand_prefix_store_tl]{
+   \__xparse_check_definable:nNT {#2} \storecommand
+   {
+       \cs_if_exist:NTF#2{
+           \cs_set_eq:cN{\__mathcommand_prefix_store_tl\cs_to_str:N#2}#2
+       }
+       {
+           \PackageError{mathcommand}
+          {The~command~`\token_to_str:N#2'~does~not~exist~(in~\token_to_str:N\storecommand)}
+          {}
+       }
+   }
+}
+
+\NewDocumentCommand\NewDocumentMathCommand{m}{
+   \__xparse_check_definable:nNT {#1} \NewDocumentMathCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_exist_math:NF#1
+      {\exp_args:Nc\DeclareDocumentCommand{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\NewDocumentTextCommand{m}{
+   \__xparse_check_definable:nNT {#1} \NewDocumentTextCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_exist_text:NF#1
+      {\exp_args:Nc\DeclareDocumentCommand{\__mathcommand_to_texttl:N#1}}
+   }
+}
+\NewDocumentCommand\newmathcommand{m}{
+   \__xparse_check_definable:nNT {#1} \newmathcommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_exist_math:NF#1
+      {\exp_args:Nc\newcommand{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\newtextcommand{m}{
+   \__xparse_check_definable:nNT {#1} \newtextcommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_exist_text:NF#1
+      {\exp_args:Nc\newcommand{\__mathcommand_to_texttl:N#1}}
+   }
+}
+\NewDocumentCommand\RenewDocumentMathCommand{m}{
+   \__xparse_check_definable:nNT {#1} \RenewDocumentMathCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_not_exist_math:NF#1
+      {\exp_args:Nc\DeclareDocumentCommand{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\RenewDocumentTextCommand{m}{
+   \__xparse_check_definable:nNT {#1} \RenewDocumentMathCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_not_exist_text:NF#1
+      {\exp_args:Nc\DeclareDocumentCommand{\__mathcommand_to_texttl:N#1}}
+   }
+}
+\NewDocumentCommand\renewmathcommand{m}{
+   \__xparse_check_definable:nNT {#1} \renewmathcommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_not_exist_math:NF#1
+      {\exp_args:Nc\renewcommand{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\renewtextcommand{m}{
+   \__xparse_check_definable:nNT {#1} \renewtextcommand
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_not_exist_text:NF#1
+      {\exp_args:Nc\renewcommand{\__mathcommand_to_texttl:N#1}}
+   }
+}
+\NewDocumentCommand\declaremathcommand{m}{
+   \__xparse_check_definable:nNT {#1} \renewmathcommand
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\declarecommand{\__mathcommand_to_mathtl:N#1}
+   }
+}
+\NewDocumentCommand\declaretextcommand{m}{
+   \__xparse_check_definable:nNT {#1} \renewtextcommand
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\declarecommand{\__mathcommand_to_texttl:N#1}
+   }
+}
+
+\NewDocumentCommand\DeclareDocumentMathCommand{m}{
+   \__xparse_check_definable:nNT {#1} \DeclareDocumentMathCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\DeclareDocumentCommand{\__mathcommand_to_mathtl:N#1}
+   }
+}
+\NewDocumentCommand\DeclareDocumentTextCommand{m}{
+   \__xparse_check_definable:nNT {#1} \DeclareDocumentTextCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\DeclareDocumentCommand{\__mathcommand_to_texttl:N#1}
+   }
+}
+\NewDocumentCommand\ProvideDocumentMathCommand{mmm}{
+   \__xparse_check_definable:nNT {#1} \ProvideDocumentMathCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\ProvideDocumentCommand{\__mathcommand_to_mathtl:N#1}{#2}{#3}
+   }
+}
+\NewDocumentCommand\ProvideDocumentTextCommand{m}{
+   \__xparse_check_definable:nNT {#1} \ProvideDocumentTextCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\ProvideDocumentCommand{\__mathcommand_to_texttl:N#1}
+   }
+}
+\NewDocumentCommand\NewDocumentMathCommandPIE{m}{
+   \__xparse_check_definable:nNT {#1} \NewDocumentMathCommandPIE
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_exist_math:NF#1
+      {\exp_args:Nc\DeclareDocumentCommandPIE{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\newmathcommandPIE{m}{
+   \__xparse_check_definable:nNT {#1} \newmathcommandPiE
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_exist_math:NF#1
+      {\exp_args:Nc\newcommandPIE{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\RenewDocumentMathCommandPIE{m}{
+   \__xparse_check_definable:nNT {#1} \RenewDocumentMathCommandPIE
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_not_exist_math:NF#1
+      {\exp_args:Nc\DeclareDocumentCommandPIE{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\renewmathcommandPIE{m}{
+   \__xparse_check_definable:nNT {#1} \renewmathcommandPIE
+   {
+      \__mathcommand_create_fork:N#1
+      \__mathcommand_error_if_not_exist_math:NF#1
+      {\exp_args:Nc\renewcommandPIE{\__mathcommand_to_mathtl:N#1}}
+   }
+}
+\NewDocumentCommand\DeclareDocumentMathCommandPIE{m}{
+   \__xparse_check_definable:nNT {#1} \DeclareDocumentMathCommand
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\DeclareDocumentCommand{\__mathcommand_to_mathtl:N#1}
+   }
+}
+\NewDocumentCommand\declaremathcommandPIE{m}{
+   \__xparse_check_definable:nNT {#1} \declaremathcommandPIE
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\declarecommandPIE{\__mathcommand_to_mathtl:N#1}
+   }
+}
+
+\NewDocumentCommand\ProvideDocumentMathCommandPIE{mmm}{
+   \__xparse_check_definable:nNT {#1} \ProvideDocumentMathCommandPIE
+   {
+      \__mathcommand_create_fork:N#1
+      \exp_args:Nc\ProvideDocumentCommandPIE{\__mathcommand_to_mathtl:N#1}{#2}{#3}
+   }
+}
+\NewDocumentCommand\LoopCommands{ m ooooooo m }{
+   \IfNoValueTF{#2}
+     {\cs_set:Nn\__tmp_two:n{\exp_not:c{##1}}}
+     {\cs_set:Nn\__tmp_two:n{\exp_not:c{#2}}}
+   \IfNoValueTF{#3}
+     {\cs_set:Nn\__tmp_three:n{\exp_not:c{##1}}}
+     {\cs_set:Nn\__tmp_three:n{\exp_not:c{#3}}}
+   \IfNoValueTF{#4}
+     {\cs_set:Nn\__tmp_four:n{\exp_not:c{##1}}}
+     {\cs_set:Nn\__tmp_four:n{\exp_not:c{#4}}}
+   \IfNoValueTF{#5}
+     {\cs_set:Nn\__tmp_five:n{\exp_not:c{##1}}}
+     {\cs_set:Nn\__tmp_five:n{\exp_not:c{#5}}}
+   \IfNoValueTF{#6}
+     {\cs_set:Nn\__tmp_six:n{\exp_not:c{##1}}}
+     {\cs_set:Nn\__tmp_six:n{\exp_not:c{#6}}}
+   \IfNoValueTF{#7}
+     {\cs_set:Nn\__tmp_seven:n{\exp_not:c{##1}}}
+     {\cs_set:Nn\__tmp_seven:n{\exp_not:c{#7}}}
+   \IfNoValueTF{#8}
+     {\cs_set:Nn\__tmp_eight:n{\exp_not:c{##1}}}
+     {\cs_set:Nn\__tmp_eight:n{\exp_not:c{#8}}}
+   %
+   \cs_gset:Nn\g_tmpb_cs:nnnnnnnn{#9}
+   %
+   \cs_gset:Nn\g_tmpa_cs:n{
+     \tl_set:Nn\l_tmpa_tl{##1}
+     \use:x{
+        \exp_not:N\g_tmpb_cs:nnnnnnnn
+           {\l_tmpa_tl}
+           \__tmp_two:n{\l_tmpa_tl}
+           \__tmp_three:n{\l_tmpa_tl}
+           \__tmp_four:n{\l_tmpa_tl}
+           \__tmp_five:n{\l_tmpa_tl}
+           \__tmp_six:n{\l_tmpa_tl}
+           \__tmp_seven:n{\l_tmpa_tl}
+           \__tmp_eight:n{\l_tmpa_tl}}
+     }
+  \exp_args:Nx\tl_map_inline:nn{#1}
+     {\tl_if_blank:nTF{##1}
+       {}
+       {\g_tmpa_cs:n{\__mathcommand_getbasename:n{##1}}}
+     }
+}
+\cs_new:Nn\__mathcommand_getbasename:n{
+      \tl_if_single:nTF{#1}{
+         \token_if_cs:NTF#1
+            {\cs_to_str:N#1}
+            {#1}
+      }{#1}
+}
+\ExplSyntaxOff
+
+\endinput
+%%
+%% End of file `mathcommand.sty'.


Property changes on: trunk/Master/texmf-dist/tex/latex/mathcommand/mathcommand.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2019-05-12 20:17:53 UTC (rev 51104)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2019-05-12 20:18:41 UTC (rev 51105)
@@ -441,7 +441,7 @@
     marginfit marginfix marginnote markdown marvosym
     matc3 matc3mem match_parens
     math-e math-into-latex-4 mathabx mathabx-type1 mathalfa mathastext
-    mathcomp mathdesign mathdots mathexam
+    mathcommand mathcomp mathdesign mathdots mathexam
     mathfam256 mathfixs mathfont mathpartir mathpazo mathpunctspace
     mathspec mathtools matlab-prettifier mathspic maths-symbols
     mattens maybemath

Modified: trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc	2019-05-12 20:17:53 UTC (rev 51104)
+++ trunk/Master/tlpkg/tlpsrc/collection-mathscience.tlpsrc	2019-05-12 20:18:41 UTC (rev 51105)
@@ -105,6 +105,7 @@
 depend lpform
 depend lplfitch
 depend lstbayes
+depend mathcommand
 depend mathcomp
 depend mathfixs
 depend mathpartir

Added: trunk/Master/tlpkg/tlpsrc/mathcommand.tlpsrc
===================================================================


More information about the tex-live-commits mailing list