summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/mathcommand/mathcommand.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/mathcommand/mathcommand.dtx')
-rw-r--r--macros/latex/contrib/mathcommand/mathcommand.dtx170
1 files changed, 109 insertions, 61 deletions
diff --git a/macros/latex/contrib/mathcommand/mathcommand.dtx b/macros/latex/contrib/mathcommand/mathcommand.dtx
index e269646e1f..7b2bb48485 100644
--- a/macros/latex/contrib/mathcommand/mathcommand.dtx
+++ b/macros/latex/contrib/mathcommand/mathcommand.dtx
@@ -4,26 +4,34 @@
%
%
%
-% 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.
-%
+%% mathcommand.dtx
+%%
+%% Copyright (C) 2019-2021 by Thomas Colcombet
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% 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.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 Maintainer of this work is Thomas Colcombet.
+%%
+%% This work consists of the files
+%% mathcommand.dtx, mathcommand.ins, and makefile,
+%% and the derived files
+%% mathcommand.sty and readme.md.
+%%
% \fi
%
% \iffalse
%<head>\usepackage{expl3}
-%<head>\ProvidesExplPackage{mathcommand}{2019/12/06}{1.03}{}
+%<head>\ProvidesExplPackage{mathcommand}{2021/06/07}{1.04}{}
%<*driver>
\documentclass{ltxdoc}
\usepackage[utf8]{inputenc}
@@ -40,6 +48,7 @@
\changes{1.01}{2019/05/12}{Initial version} %
\changes{1.02}{2019/07/03}{Bug correction} %
\changes{1.03}{2019/12/06}{added disabling commands} %
+\changes{1.04}{2021/06/05}{correction with respect to modification of xparse package} %
\GetFileInfo{mathcommand.sty} %
\DoNotIndex{}
\edef\mathcommandversiondate{\fileversion--\filedate}
@@ -160,6 +169,7 @@
\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{amssymb}{package,url = {https://www.ctan.org/pkg/amssymb}}
\knowledge{mathcommand}{package}
\knowledge{math variant}{doc notion}
@@ -204,6 +214,7 @@
\item[2019-05-14] New macros \cs\IfEmptyTF, \cs\GetExponent, and \cs\GetIndex.
\item[2019-07-03] Corrects bug of functions declaring PIE's issuing an error when already existing. Version 1.02 on CTAN.
\item[2019-12-06] Added disabling commands, and package options. Version 1.03 on CTAN.
+\item[2021-06-07] Corrected code that was broken due to an update in "xparse". Version 1.04 on CTAN.
\end{compactdesc}
@@ -230,10 +241,9 @@
\end{center}
If the macro \cs{\macro} already exists, it is stored
- under the name \cs{\LaTeXmacro}, and then everything's happen as
+ under the name \cs{\LaTeXmacro}, and then everything happens as
if it had already been defined both in math and text mode.
-
- This is interesting for redefining known macros.
+ This is useful 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.:
@@ -414,7 +424,7 @@ defined with as main body \texttt{\cs\overline\{u\#2\}\#1\#3}
Hence, for instance:
\begin{code}[10cm]
\cs\LoopCommands\cs\lettersUppercase[bb\#1]\\
- \indent~~~~~~\{\cs\newmathcommand\{\cs\mathbb \#1\}\}\\
+ \indent~~~~~~\{\cs\newmathcommand\#2\{\cs\mathbb \#1\}\}\\
\cs\LoopCommands\cs\lettersGreekLowercase[\#1][LaTeX\#1]\\
\indent~~~~~~\{\cs\renewmathcommand\#2\{\cs\textcolor\{blue\}\{\#3\}\}
\end{code}
@@ -422,7 +432,7 @@ defined with as main body \texttt{\cs\overline\{u\#2\}\#1\#3}
the letters in blackboard bold alphabet (e.g. 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 the third parameter used for accessing the macros \cs\LaTeXalpha,\dots\
+ the use of the third parameter for accessing the macros \cs\LaTeXalpha,\dots\
that are automatically generated by the \cs\renewmathcommand\ macro.
\section{Disabling command}
@@ -439,7 +449,7 @@ The result of this command is that the control sequences appearing in the sequen
\item The original macro is stored as \cs\LaTeXmacro, and thus can still be used.
\item Using \cs\macro\ now displays an error message explaining that it has been disabled, that~\cs\LaTeXmacro\ can be used instead, and also provides a list suggestions of replacement that are defined by the command \cs\suggestcommand.
\end{itemize}
-However, be careful: disabling a command which is used in the system or in the the style will yield an error.
+However, be careful: disabling a command which is used in the system or in the the style may cause problems.
Hence, it is possible to disable all math symbols but macros like \cs\dagger\ would yield problem if used in footnotes or for the affiliation of the authors.
\AP The syntax of~\cs\suggestcommand\ is as follows:
\begin{center}
@@ -462,7 +472,7 @@ Now, executing \cs\leq\ yields:
\section{Options}
-\AP Options can either be triggered either when the package is loaded, or using:
+\AP Options can be triggered either when the package is loaded, or using:
\begin{center}
\csintro\mathcommandconfigure\{option list\}
\end{center}
@@ -495,12 +505,12 @@ The available options are:
This directory contains the package
name: mathcommand
- license: LaTeX Project Public License version 1.2 or above
- version: v1.03
- date: 2019/12/06
+ license: LaTeX Project Public License version 1.3 or above
+ version: v1.04
+ date: 2021/06/07
author: Thomas Colcombet
mail: thomas.colcombet@irif.fr
- web: -
+ web: https://www.ctan.org/pkg/mathcommand
Purpose:
The mathcommand package provides functionalities for defining macros:
@@ -517,11 +527,11 @@ Install:
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.sty: the package file (generated using mathcommand.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
+ and mathcommand.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).
@@ -676,7 +686,7 @@ Content of the file mathcommand-ctan.zip:
%
% \begin{macrocode}
\NewDocumentCommand\newcommandPIE{ m o o m }{
- \__xparse_check_definable:nNT {#1} \newcommandPIE
+ \__mathcommand_check_definable:nNT {#1} \newcommandPIE
{
\cs_if_exist:NTF #1
{
@@ -688,7 +698,7 @@ Content of the file mathcommand-ctan.zip:
}
}
\NewDocumentCommand\renewcommandPIE{ m o o m }{
- \__xparse_check_definable:nNT {#1} \renewcommandPIE
+ \__mathcommand_check_definable:nNT {#1} \renewcommandPIE
{
\cs_if_exist:NTF #1
{ \__mathcommand_declarecommandPIE:Nnnn #1{#2}{#3}{#4} }
@@ -700,7 +710,7 @@ Content of the file mathcommand-ctan.zip:
}
}
\NewDocumentCommand\declarecommandPIE{ m o o m }{
- \__xparse_check_definable:nNT {#1} \declarecommandPIE
+ \__mathcommand_check_definable:nNT {#1} \declarecommandPIE
{ \__mathcommand_declarecommandPIE:Nnnn #1{#2}{#3}{#4} }
}
% \end{macrocode}
@@ -721,7 +731,7 @@ Content of the file mathcommand-ctan.zip:
% \end{macrocode}
% \begin{macrocode}
\cs_new_protected:Npn\NewDocumentCommandPIE#1#2#3{
- \__xparse_check_definable:nNT {#1} \NewDocumentCommandPIE
+ \__mathcommand_check_definable:nNT {#1} \NewDocumentCommandPIE
{
\cs_if_exist:NTF #1
{
@@ -735,12 +745,12 @@ Content of the file mathcommand-ctan.zip:
% \end{macrocode}
% \begin{macrocode}
\cs_new_protected:Npn\RenewDocumentCommandPIE#1#2#3{
- \__xparse_check_definable:nNT {#1} \RenewDocumentCommandPIE
+ \__mathcommand_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 }
+ \__kernel_msg_error:nnxx { mathcommand } { command-not-yet-defined }
{ \use:nnn \token_to_str:N #1 { } }
{ \token_to_str:N \RenewDocumentCommandPIE }
}
@@ -749,7 +759,7 @@ Content of the file mathcommand-ctan.zip:
% \end{macrocode}
% \begin{macrocode}
\cs_new_protected:Npn\DeclareDocumentCommandPIE#1#2#3{
- \__xparse_check_definable:nNT {#1} \DeclareDocumentCommandPIE
+ \__mathcommand_check_definable:nNT {#1} \DeclareDocumentCommandPIE
{
\__mathcommand_DeclareDocumentCommandPIE:Nnn #1 {#2} {#3}
}
@@ -757,7 +767,7 @@ Content of the file mathcommand-ctan.zip:
% \end{macrocode}
% \begin{macrocode}
\cs_new_protected:Npn\ProvideDocumentCommandPIE#1#2#3{
- \__xparse_check_definable:nNT {#1} \ProvideDocumentCommandPIE
+ \__mathcommand_check_definable:nNT {#1} \ProvideDocumentCommandPIE
{
\cs_if_exist:NTF #1{}
{
@@ -970,7 +980,7 @@ Content of the file mathcommand-ctan.zip:
% \subsection{Definition of the high level commands}
% \begin{macrocode}
\NewDocumentCommand\declarecommand{m}{
- \__xparse_check_definable:nNT {#1} \declarecommand
+ \__mathcommand_check_definable:nNT {#1} \declarecommand
{
\cs_if_exist:NTF#1
{\renewcommand#1}
@@ -978,7 +988,7 @@ Content of the file mathcommand-ctan.zip:
}
}
\newrobustcmd\storecommand[2][\__mathcommand_prefix_store_tl]{
- \__xparse_check_definable:nNT {#2} \storecommand
+ \__mathcommand_check_definable:nNT {#2} \storecommand
{
\cs_if_exist:NTF#2{
\cs_set_eq:cN{#1\cs_to_str:N#2}#2
@@ -992,7 +1002,7 @@ Content of the file mathcommand-ctan.zip:
}
\NewDocumentCommand\NewDocumentMathCommand{m}{
- \__xparse_check_definable:nNT {#1} \NewDocumentMathCommand
+ \__mathcommand_check_definable:nNT {#1} \NewDocumentMathCommand
{
\__mathcommand_create_fork:N#1
\__mathcommand_error_if_exist_math:NF#1
@@ -1000,7 +1010,7 @@ Content of the file mathcommand-ctan.zip:
}
}
\NewDocumentCommand\NewDocumentTextCommand{m}{
- \__xparse_check_definable:nNT {#1} \NewDocumentTextCommand
+ \__mathcommand_check_definable:nNT {#1} \NewDocumentTextCommand
{
\__mathcommand_create_fork:N#1
\__mathcommand_error_if_exist_text:NF#1
@@ -1008,7 +1018,7 @@ Content of the file mathcommand-ctan.zip:
}
}
\NewDocumentCommand\newmathcommand{m}{
- \__xparse_check_definable:nNT {#1} \newmathcommand
+ \__mathcommand_check_definable:nNT {#1} \newmathcommand
{
\__mathcommand_create_fork:N#1
\__mathcommand_error_if_exist_math:NF#1
@@ -1016,7 +1026,7 @@ Content of the file mathcommand-ctan.zip:
}
}
\NewDocumentCommand\newtextcommand{m}{
- \__xparse_check_definable:nNT {#1} \newtextcommand
+ \__mathcommand_check_definable:nNT {#1} \newtextcommand
{
\__mathcommand_create_fork:N#1
\__mathcommand_error_if_exist_text:NF#1
@@ -1024,7 +1034,7 @@ Content of the file mathcommand-ctan.zip:
}
}
\NewDocumentCommand\RenewDocumentMathCommand{m}{
- \__xparse_check_definable:nNT {#1} \RenewDocumentMathCommand
+ \__mathcommand_check_definable:nNT {#1} \RenewDocumentMathCommand
{
\__mathcommand_create_fork:N#1
\__mathcommand_error_if_not_exist_math:NF#1
@@ -1032,7 +1042,7 @@ Content of the file mathcommand-ctan.zip:
}
}
\NewDocumentCommand\RenewDocumentTextCommand{m}{
- \__xparse_check_definable:nNT {#1} \RenewDocumentMathCommand
+ \__mathcommand_check_definable:nNT {#1} \RenewDocumentMathCommand
{
\__mathcommand_create_fork:N#1
\__mathcommand_error_if_not_exist_text:NF#1
@@ -1040,7 +1050,7 @@ Content of the file mathcommand-ctan.zip:
}
}
\NewDocumentCommand\renewmathcommand{m}{
- \__xparse_check_definable:nNT {#1} \renewmathcommand
+ \__mathcommand_check_definable:nNT {#1} \renewmathcommand
{
\__mathcommand_create_fork:N#1
\__mathcommand_error_if_not_exist_math:NF#1
@@ -1048,7 +1058,7 @@ Content of the file mathcommand-ctan.zip:
}
}
\NewDocumentCommand\renewtextcommand{m}{
- \__xparse_check_definable:nNT {#1} \renewtextcommand
+ \__mathcommand_check_definable:nNT {#1} \renewtextcommand
{
\__mathcommand_create_fork:N#1
\__mathcommand_error_if_not_exist_text:NF#1
@@ -1056,14 +1066,14 @@ Content of the file mathcommand-ctan.zip:
}
}
\NewDocumentCommand\declaremathcommand{m}{
- \__xparse_check_definable:nNT {#1} \renewmathcommand
+ \__mathcommand_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_check_definable:nNT {#1} \renewtextcommand
{
\__mathcommand_create_fork:N#1
\exp_args:Nc\declarecommand{\__mathcommand_to_texttl:N#1}
@@ -1071,28 +1081,28 @@ Content of the file mathcommand-ctan.zip:
}
\NewDocumentCommand\DeclareDocumentMathCommand{m}{
- \__xparse_check_definable:nNT {#1} \DeclareDocumentMathCommand
+ \__mathcommand_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_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_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_check_definable:nNT {#1} \ProvideDocumentTextCommand
{
\__mathcommand_create_fork:N#1
\exp_args:Nc\ProvideDocumentCommand{\__mathcommand_to_texttl:N#1}
@@ -1104,7 +1114,7 @@ Content of the file mathcommand-ctan.zip:
%
% \begin{macrocode}
\NewDocumentCommand\NewDocumentMathCommandPIE{m}{
- \__xparse_check_definable:nNT {#1} \NewDocumentMathCommandPIE
+ \__mathcommand_check_definable:nNT {#1} \NewDocumentMathCommandPIE
{
\__mathcommand_create_fork:N#1
\__mathcommand_error_if_exist_math:NF#1
@@ -1112,7 +1122,7 @@ Content of the file mathcommand-ctan.zip:
}
}
\NewDocumentCommand\newmathcommandPIE{m}{
- \__xparse_check_definable:nNT {#1} \newmathcommandPiE
+ \__mathcommand_check_definable:nNT {#1} \newmathcommandPiE
{
\__mathcommand_create_fork:N#1
\__mathcommand_error_if_exist_math:NF#1
@@ -1120,7 +1130,7 @@ Content of the file mathcommand-ctan.zip:
}
}
\NewDocumentCommand\RenewDocumentMathCommandPIE{m}{
- \__xparse_check_definable:nNT {#1} \RenewDocumentMathCommandPIE
+ \__mathcommand_check_definable:nNT {#1} \RenewDocumentMathCommandPIE
{
\__mathcommand_create_fork:N#1
\__mathcommand_error_if_not_exist_math:NF#1
@@ -1128,7 +1138,7 @@ Content of the file mathcommand-ctan.zip:
}
}
\NewDocumentCommand\renewmathcommandPIE{m}{
- \__xparse_check_definable:nNT {#1} \renewmathcommandPIE
+ \__mathcommand_check_definable:nNT {#1} \renewmathcommandPIE
{
\__mathcommand_create_fork:N#1
\__mathcommand_error_if_not_exist_math:NF#1
@@ -1136,14 +1146,14 @@ Content of the file mathcommand-ctan.zip:
}
}
\NewDocumentCommand\DeclareDocumentMathCommandPIE{m}{
- \__xparse_check_definable:nNT {#1} \DeclareDocumentMathCommand
+ \__mathcommand_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_check_definable:nNT {#1} \declaremathcommandPIE
{
\__mathcommand_create_fork:N#1
\exp_args:Nc\declarecommandPIE{\__mathcommand_to_mathtl:N#1}
@@ -1151,7 +1161,7 @@ Content of the file mathcommand-ctan.zip:
}
\NewDocumentCommand\ProvideDocumentMathCommandPIE{mmm}{
- \__xparse_check_definable:nNT {#1} \ProvideDocumentMathCommandPIE
+ \__mathcommand_check_definable:nNT {#1} \ProvideDocumentMathCommandPIE
{
\__mathcommand_create_fork:N#1
\exp_args:Nc\ProvideDocumentCommandPIE{\__mathcommand_to_mathtl:N#1}{#2}{#3}
@@ -1265,7 +1275,7 @@ Content of the file mathcommand-ctan.zip:
\cs_new:Nn\mathcommand_disablecommand:N
{ \cs_if_exist:NTF#1{
- \__xparse_check_definable:nNT#1\disablecommand
+ \__mathcommand_check_definable:nNT#1\disablecommand
{\tl_if_exist:cTF{\__mathcommand_to_disabled_help_tl:N#1}
{}
{\storecommand#1
@@ -1312,6 +1322,44 @@ Content of the file mathcommand-ctan.zip:
\NewDocumentCommand\mathcommandconfigure{ m }
{\keys_set:nn{ mathcommand}{ #1} }
% \end{macrocode}
+%
+% \subsection{Testing control sequence for definition}
+% This part of the code is an import of a previous version of xparse (Frank Mittelbach, Chris Rowley, David Carlisle, The LaTeX Project). It is done in a very ugly hack: the code is copied and past, and \texttt{mathcommand} substituted to \texttt{xparse} wherever necessary.
+% \begin{macrocode}
+\cs_new_protected:Npn \__mathcommand_check_definable:nNT #1
+ { \tl_trim_spaces_apply:nN {#1} \__mathcommand_check_definable_aux:nN }
+\group_begin:
+ \char_set_catcode_active:n { `? }
+ \cs_new_protected:Npn \__mathcommand_check_definable_aux:nN #1#2
+ {
+ \group_begin:
+ \tl_if_single_token:nTF {#1}
+ {
+ \int_set:Nn \tex_escapechar:D { 92 }
+ \exp_args:Nx \tl_if_empty:nTF
+ { \exp_args:No \str_tail:n { \token_to_str:N #1 } }
+ {
+ \exp_args:Nx \char_set_lccode:nn
+ { ` \str_head:n {#1} } { `? }
+ \tex_lowercase:D { \tl_if_eq:nnTF {#1} } { ? }
+ { \group_end: \use_iii:nnn }
+ { \group_end: \use_i:nnn }
+ }
+ { \group_end: \use_iii:nnn }
+ }
+ { \group_end: \use_ii:nnn }
+ {
+ \__kernel_msg_error:nnxx { mathcommand } { not-definable }
+ { \tl_to_str:n {#1} } { \token_to_str:N #2 }
+ }
+ {
+ \__kernel_msg_error:nnxx { mathcommand } { not-one-token }
+ { \tl_to_str:n {#1} } { \token_to_str:N #2 }
+ }
+ }
+\group_end:
+% \end{macrocode}
+% \subsection{Closure}
% \begin{macrocode}
\ExplSyntaxOff
% \end{macrocode}