diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/multidef/multidef.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/multidef/multidef.sty | 94 |
1 files changed, 74 insertions, 20 deletions
diff --git a/Master/texmf-dist/tex/latex/multidef/multidef.sty b/Master/texmf-dist/tex/latex/multidef/multidef.sty index 6d33e63c9eb..13b554c5703 100644 --- a/Master/texmf-dist/tex/latex/multidef/multidef.sty +++ b/Master/texmf-dist/tex/latex/multidef/multidef.sty @@ -6,7 +6,7 @@ %% %% multidef.dtx (with options: `package') %% -%% (c) 2016/03/14 Nicolas Markey <multidef at markey dot fr> +%% (c) 2016/04/20 Nicolas Markey <multidef at markey dot fr> %% %% This work may be distributed and/or modified under the conditions of %% the LaTeX Project Public License, either version 1.3 of this license @@ -37,6 +37,24 @@ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} %% +\NeedsTeXFormat{LaTeX2e}[1994/12/01] +\ProvidesPackage{multidef}[2016/04/20 v1.10 definition of multiple commands] +\IfFileExists{trimspaces.sty} + {\RequirePackage{trimspaces}} + {} +%% borrowing code from trimspaces, if package was not found. +\catcode`\Q=3 +\@ifundefined{trim@spaces} + {\PackageWarning{multidef} + {Package trimspaces.sty not found.^^JDefining \noexpand\trim@spaces myself} + \newcommand\trim@spaces[1]{% + \romannumeral-`\q\trim@trim@\noexpand#1Q Q% + } + \long\def\trim@trim@#1 Q{\trim@trim@@#1Q} + \long\def\trim@trim@@#1Q#2{#1}} + {} +\catcode`\Q=11 +%% \RequirePackage{xkeyval} \define@boolkeys{mdef}{noerr,nowarn}[true] \DeclareOptionX{noerr}[true]{\setkeys{mdef}{noerr=#1}} @@ -59,9 +77,10 @@ \define@key{mdef}{s}{\def\@mdsuffix{#1}} \define@key{mdef}{arg}{\def\@mdargs{#1}} \define@key{mdef}{args}{\def\@mdargs{#1}} -\define@boolkeys{mdef}{long,global}[true] +\define@boolkeys{mdef}{long,global,robust}[true] \presetkeys{mdef} - {p=,s=,prefix=,suffix=,long=false,global=false,arg=0,args=0}{} + {p=,s=,prefix=,suffix=,long=false,global=false,robust=false, + arg=0,args=0}{} \def\@mdef@az{a-z} \def\@mdef@AZ{A-Z} \def\@mdef@alphabet{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z} @@ -70,28 +89,30 @@ \setkeys{mdef}{#1}% \def\@mdef@com##1{#2}% \@mdef#3,\@end} -\def\@mdef #1,#2\@end{\expandafter\def\expandafter\@arg - \expandafter{\romannumeral-\expandafter`\expandafter\.#1}% - \ifx\@arg\@mdef@az +\def\@mdef #1,#2\@end{% + \edef\@mdef@arg{\trim@spaces{#1}}% + \ifx\@mdef@arg\@mdef@az \expandafter\@mdef \@mdef@alphabet,\@end \else - \ifx\@arg\@mdef@AZ + \ifx\@mdef@arg\@mdef@AZ \expandafter\@mdef \@mdef@Alphabet,\@end \else - \expandafter\@@mdef\@arg->->->\@end + \expandafter\@@mdef\@mdef@arg->->->\@end \fi \fi - \def\@arg{#2}% - \ifx\@arg\@empty\else\@mdef #2\@end\fi} + \def\@mdef@arg{#2}% + \ifx\@mdef@arg\@empty\else\@mdef #2\@end\fi} \newtoks\@mdef@redeftok \def\@mdef@comma{} \def\@@mdef#1->#2->#3\@end{% \@ifundefined{\@mdprefix#1\@mdsuffix} {\@@@mdef{#1}{#2}} - {\edef\@mdef@redef{\the\@mdef@redeftok\@mdef@comma - \@backslashchar\@mdprefix#1\@mdsuffix} - \def\@mdef@comma{, } - \@mdef@redeftok=\expandafter{\@mdef@redef} + {\ifKV@mdef@nowarn\else + \edef\@mdef@redef{\the\@mdef@redeftok\@mdef@comma + \@backslashchar\@mdprefix#1\@mdsuffix} + \def\@mdef@comma{, } + \global\@mdef@redeftok=\expandafter{\@mdef@redef} + \fi \ifKV@mdef@noerr \@@@mdef{#1}{#2}% \ifKV@mdef@nowarn\else @@ -116,18 +137,51 @@ redefined commands (\the\@mdef@redeftok)}}} \def\@@@mdef#1#2{\def\@arg@{#2}% \ifx\@arg@\@empty - \@mdef@def{#1}{#1}% + \ifKV@mdef@robust + \expandafter\def\expandafter\@mdef@cmdname + \expandafter{\csname\@mdprefix#1\@mdsuffix\endcsname}% + \expandafter\@mdef@robdef\@mdef@cmdname{#1}% + \else + \@mdef@def{#1}{#1}% + \fi \else - \@mdef@def{#1}{#2}% + \ifKV@mdef@robust + \expandafter\def\expandafter\@mdef@cmdname + \expandafter{\csname\@mdprefix#1\@mdsuffix\endcsname} + \expandafter\@mdef@robdef\@mdef@cmdname{#2}% + \else + \@mdef@def{#1}{#2}% + \fi \fi} \def\@mdef@def#1#2{% - \let\reserved@b\@gobble - \ifKV@mdef@global\let\@mdglobal\global\else\let\@mdglobal\relax\fi - \ifKV@mdef@long\let\@mdlong\long\else\let\@mdlong\relax\fi - \def\l@ngrel@x{\@mdlong\@mdglobal} + \let\reserved@b\@gobble + \ifKV@mdef@global\let\@mdglobal\global\else\let\@mdglobal\relax\fi + \ifKV@mdef@long\let\@mdlong\long\else\let\@mdlong\relax\fi + \def\l@ngrel@x{\@mdlong\@mdglobal} \expandafter\expandafter\expandafter\@yargd@f\expandafter\@mdargs\csname \@mdprefix#1\@mdsuffix\expandafter\endcsname\expandafter{\@mdef@com{#2}} } +\def\@mdef@robdef#1#2{% + \edef\reserved@a{\string#1}% + \def\reserved@b{#1}% + \edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}% + \global\edef#1{% + \ifx\reserved@a\reserved@b + \noexpand\x@protect + \noexpand#1% + \fi + \noexpand\protect + \expandafter\noexpand\csname + \expandafter\@gobble\string#1 \endcsname + }% + \let\reserved@b\@gobble + \ifKV@mdef@global\let\@mdglobal\global\else\let\@mdglobal\relax\fi + \ifKV@mdef@long\let\@mdlong\long\else\let\@mdlong\relax\fi + \def\l@ngrel@x{\@mdlong\@mdglobal} + \expandafter\expandafter\expandafter\@yargd@f\expandafter\@mdargs\csname + \expandafter\@gobble\string#1 \expandafter\endcsname + \expandafter{\@mdef@com{#2}} +} %% %% %% End of file `multidef.sty'. |