-
Notifications
You must be signed in to change notification settings - Fork 0
/
xargs.sty
361 lines (361 loc) · 12.1 KB
/
xargs.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
%%
%% This is file `xargs.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% xargs.dtx (with options: `package')
%%
%% xargs package by Manuel P\'egouri\'e-Gonnard <[email protected]>
%% This is a generated file. See xargs.dtx for license information.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{xargs}
[2008/03/22 v1.1 \space extended macro definitions \space (mpg)]
\RequirePackage{xkeyval}
\@ifdefinable\xargs@max{\newcount\xargs@max}
\@ifdefinable\xargs@temp\relax
\@ifdefinable\xargs@toksa{\newtoks\xargs@toksa}
\@ifdefinable\xargs@toksb{\newtoks\xargs@toksb}
\newcommand*\@protected@testopt@xargs[1]{%
\ifx\protect\@typeset@protect
\expandafter\xargs@read
\else
\@x@protect#1%
\fi}
\newcommand*\xargs@read[2]{%
\begingroup
\xargs@toksa{#1}%
\xargs@toksb{#2}%
\xargs@continue}
\newcommand\xargs@continue{%
\expandafter\xargs@pick@next\the\xargs@toksb,\@nil
\xargs@temp}
\@ifdefinable\xargs@pick@next{%
\def\xargs@pick@next#1,#2\@nil{%
\def\xargs@temp{#1}%
\xargs@toksb{#2}%
\ifx\xargs@temp\empty
\def\xargs@temp{\expandafter\endgroup\the\xargs@toksa}%
\fi}}
\newcommand*\xargs@set@defflag[1]{%
\def\xargs@default@flag{#1}}
\newcommand\xargs@put@arg[1]{%
\xargs@toksa\expandafter{\the\xargs@toksa{#1}}%
\xargs@continue}
\newcommand*\xargs@test@opt[1]{%
\xargs@ifnextchar[%]
{\xargs@grab@opt{#1}}%
{\xargs@put@opt{#1}}}
\newcommand\xargs@put@opt[1]{%
\xargs@toksa\expandafter{\the\xargs@toksa[{#1}]}%
\xargs@continue}
\@ifdefinable\xargs@grab@opt{%
\long\def\xargs@grab@opt#1[#2]{%
\toks@{#2}\edef\xargs@temp{\the\toks@}%
\ifx\xargs@temp\xargs@default@flag
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi{%
\xargs@put@opt{#1}%
}{%
\xargs@put@opt{#2}}}}
\newcommand\xargs@ifnextchar[3]{%
\let\xargs@temp\empty
\let\reserved@d=#1%
\def\reserved@a{#2}%
\def\reserved@b{#3}%
\futurelet\@let@token\xargs@ifnch}
\newcommand\xargs@ifnch{%
\ifx\@let@token\@sptoken
\edef\xargs@temp{\xargs@temp\space}%
\let\reserved@c\xargs@xifnch
\else
\ifx\@let@token\reserved@d
\let\reserved@c\reserved@a
\else
\def\reserved@c{\expandafter\reserved@b\xargs@temp}%
\fi
\fi
\reserved@c}
\@ifdefinable\xargs@xifnch{%
\expandafter\def\expandafter\xargs@xifnch\space{%
\futurelet\@let@token\xargs@ifnch}}
\@ifdefinable\xargs@key@addprefix{%
\define@key[xargs]{key}{addprefix}[]{%
\global\expandafter\def\expandafter\xargs@prefix\expandafter{%
\xargs@prefix#1}%
\xargs@makeshort#1\long\@nil}}
\@ifdefinable\xargs@makeshort{%
\def\xargs@makeshort#1\long#2{%
\expandafter\gdef\expandafter\xargs@shortpref\expandafter{%
\xargs@shortpref#1}%
\ifx#2\@nil \else
\expandafter\xargs@makeshort\expandafter#2%
\fi}}
\newcommand\xargs@star@or@long[1]{%
\global\let\xargs@shortpref\@empty
\@ifstar{\gdef\xargs@prefix{}#1}{\gdef\xargs@prefix{\long}#1}}
\define@key[xargs]{key}{usedefault}[]{%
\xargs@toksa{#1}\edef\xargs@default@flag{\the\xargs@toksa}}
\providecommand\@namenewc[1]{%
\expandafter\newcommand\csname #1\endcsname}
\@namenewc{xargs@action@1}{\xargs@put@arg}
\@namenewc{xargs@action@2}{\xargs@put@arg}
\@namenewc{xargs@action@3}{\xargs@put@arg}
\@namenewc{xargs@action@4}{\xargs@put@arg}
\@namenewc{xargs@action@5}{\xargs@put@arg}
\@namenewc{xargs@action@6}{\xargs@put@arg}
\@namenewc{xargs@action@7}{\xargs@put@arg}
\@namenewc{xargs@action@8}{\xargs@put@arg}
\@namenewc{xargs@action@9}{\xargs@put@arg}
\newcommand*\xargs@def@key[2]{%
\expandafter\@ifdefinable\csname xargs@key@#1\endcsname{%
\define@key[xargs]{key}{#1}[]{%
\ifnum\xargs@max<#1
\PackageError{xargs}{%
Illegal argument label in\MessageBreak
optional arguments description%
}{%
You are trying to make optional an argument whose label (#1)
\MessageBreak is higher than the total number (\the\xargs@max)
of parameters. \MessageBreak This can't be done and your
demand will be ignored.}%
\else
\expandafter\expandafter\expandafter
\ifx\csname xargs@action@#1\endcsname\xargs@put@arg \else
\PackageWarning{xargs}{%
Argument #1 was allready given a default value.\MessageBreak
Previous value will be overriden.\MessageBreak}%
\fi
\@namedef{xargs@action@#1}{\xargs@test@opt{##1}}%
#2%
\fi}}}
\newif\ifxargs@firstopt@
\newif\ifxargs@otheropt@
\xargs@def@key1\xargs@firstopt@true
\xargs@def@key2\xargs@otheropt@true \xargs@def@key3\xargs@otheropt@true
\xargs@def@key4\xargs@otheropt@true \xargs@def@key5\xargs@otheropt@true
\xargs@def@key6\xargs@otheropt@true \xargs@def@key7\xargs@otheropt@true
\xargs@def@key8\xargs@otheropt@true \xargs@def@key9\xargs@otheropt@true
\newcommand\xargs@setkeys[1]{%
\setkeys*[xargs]{key}{#1}%
\xargs@check@keys}
\newcommand\xargs@check@keys{%
\ifx\XKV@rm\empty \else
\xargs@toksa\expandafter{\XKV@rm}%
\PackageError{xargs}{%
Illegal key or argument label in\MessageBreak
optional arguments description%
}{%
You can only use non-zero digits as argument labels.\MessageBreak
Other allowed keys are usedefault and addprefix.\MessageBreak
You wrote: "\the\xargs@toksa".\MessageBreak
I can't understand this and I'm going to ignore it.}%
\fi}
\newcommand\xargs@add@args[1]{%
\xargs@toksa\expandafter{\the\xargs@toksa #1,}%
\expandafter
\ifx\@car#1\@nil\xargs@put@arg
\xargs@toksb\expandafter\expandafter\expandafter{%
\the\expandafter\xargs@toksb\expandafter##\the\count@}%
\else
\xargs@toksb\expandafter\expandafter\expandafter{%
\the\expandafter\xargs@toksb\expandafter
[\expandafter##\the\count@]}%
\fi}
\@ifdefinable\xargs@process@keys{%
\long\def\xargs@process@keys#1[#2]{%
\begingroup
\xargs@setkeys{#2}%
\xargs@toksa{}\xargs@toksb{}%
\@ifundefined{xargs@default@flag}{}{%
\xargs@toksa\expandafter{%
\expandafter\xargs@set@defflag\expandafter{%
\xargs@default@flag}}}
\count@\z@
\@whilenum\xargs@max>\count@ \do{%
\advance\count@\@ne
\expandafter\expandafter\expandafter\xargs@add@args
\expandafter\expandafter\expandafter{%
\csname xargs@action@\the\count@\endcsname}}%
\ifxargs@otheropt@ \else
\ifxargs@firstopt@
\let\xargs@test@opt\@firstofone
\xargs@toksa\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\expandafter{%
\csname xargs@action@1\endcsname}%
\fi
\fi
\edef\xargs@temp{%
\ifxargs@otheropt@ \noexpand\xargs@xargsdef \else
\ifxargs@firstopt@ \noexpand\xargs@xargdef \else
\noexpand\xargs@argdef
\fi\fi
\noexpand#1%
\expandafter\noexpand\csname\string#1\endcsname
{\the\xargs@toksa}{\the\xargs@toksb}}%
\expandafter\endgroup
\expandafter\xargs@drc@hook
\xargs@temp}}
\newcommand\xargs@argdef[5]{%
\@ifdefinable#1{%
\xargs@prefix\def#1#4{#5}}}
\newcommand\xargs@xargdef[5]{%
\@ifdefinable#1{%
\xargs@shortpref\def#1{\@protected@testopt#1#2{#3}}%
\xargs@prefix\def#2#4{#5}}}
\newcommand\xargs@xargsdef[5]{%
\@ifdefinable#1{%
\xargs@shortpref\def#1{\@protected@testopt@xargs#1#2{#3}}%
\xargs@prefix\def#2#4{#5}}}
\newcommand\newcommandx{%
\xargs@star@or@long\xargs@newc}
\newcommand*\xargs@newc[1]{%
\@testopt{\xargs@set@max{#1}}{0}}
\@ifdefinable\xargs@set@max{%
\def\xargs@set@max#1[#2]{%
\kernel@ifnextchar[%]
{\xargs@max=#2 \xargs@check@max{#1}}%
{\@argdef#1[#2]}}}
\newcommand\xargs@check@max{%
\ifcase\xargs@max \or\or\or\or\or\or\or\or\or\else
\PackageError{xargs}{Illegal number, treated as zero}{The total
number of arguments must be in the 0..9 range.\MessageBreak
Since your value is illegal, i'm going to use 0 instead.}
\xargs@max0
\fi
\xargs@process@keys}
\newcommand\CheckCommandx{%
\xargs@star@or@long\xargs@CheckC}
\@onlypreamble\CheckCommandx
\newcommand\xargs@CheckC[1]{%
\@testopt{\xargs@check@a#1}0}
\@onlypreamble\xargs@CheckC
\@ifdefinable\xargs@check@a{%
\def\xargs@check@a#1[#2]{%
\kernel@ifnextchar[%]
{\xargs@check@b#1[#2]}%
{\xargs@check@c#1{[#2]}}}}
\@onlypreamble\xargs@check@a
\@ifdefinable\xargs@check@b{%
\def\xargs@check@b#1[#2][#3]{%
\xargs@check@c{#1}{[#2][{#3}]}}}
\@onlypreamble\xargs@check@b
\newcommand\xargs@check@c[3]{%
\xargs@toksa{#1}%
\expandafter\let\csname\string\reserved@a\endcsname\relax
\xargs@renewc\reserved@a#2{#3}%
\@ifundefined{\string\reserved@a}{%
\ifx#1\reserved@a \else
\xargs@check@complain
\fi
}{%
\expandafter
\ifx\csname\string#1\expandafter\endcsname
\csname\string\reserved@a\endcsname
\xargs@check@d
\else
\xargs@check@complain
\fi}}
\@onlypreamble\xargs@check@c
\def\xargs@temp{\@protected@testopt}
\expandafter\xargs@toksa\expandafter{\meaning\xargs@temp}
\def\xargs@temp#1 {\def\xargs@temp{#1}}
\expandafter\xargs@temp\the\xargs@toksa
\expandafter\newcommand\expandafter\xargs@check@d\expandafter{%
\expandafter\expandafter\expandafter\xargs@check@e
\expandafter\meaning\expandafter\reserved@a\xargs@temp\@nil}
\@onlypreamble\xargs@check@d
\@ifdefinable\xargs@check@e{%
\expandafter\def\expandafter\xargs@check@e
\expandafter#\expandafter1\xargs@temp#2\@nil{%
\ifx\empty#1\empty \else
\xargs@check@complain
\fi}}
\@onlypreamble\xargs@check@e
\newcommand\xargs@check@complain{%
\PackageWarningNoLine{xargs}{Command \the\xargs@toksa has changed.
\MessageBreak Check if current package is valid}}
\@onlypreamble\xargs@check@complain
\newcommand\DeclareRobustCommandx{%
\xargs@star@or@long\xargs@DRC}
\newcommand*\xargs@DRC[1]{%
\ifx#1\@undefined\else\ifx#1\relax\else
\PackageInfo{xargs}{Redefining \string#1}%
\fi\fi
\edef\reserved@a{\string#1}%
\def\reserved@b{#1}%
\edef\reserved@b{\expandafter\strip@prefix\meaning\reserved@b}%
\edef\xargs@drc@hook{%
\noexpand\xargs@shortpref\def\noexpand#1{%
\ifx\reserved@a\reserved@b
\noexpand\x@protect
\noexpand#1%
\fi
\noexpand\protect
\expandafter\noexpand\csname
\expandafter\@gobble\string#1 \endcsname}%
\expandafter\let\noexpand\xargs@drc@hook\relax}%
\let\@ifdefinable\@rc@ifdefinable
\expandafter\xargs@newc\csname
\expandafter\@gobble\string#1 \endcsname}
\let\xargs@drc@hook\relax
\newcommand\renewcommandx{%
\xargs@star@or@long\xargs@renewc}
\newcommand*\xargs@renewc[1]{%
\begingroup\escapechar\m@ne
\xdef\@gtempa{{\string#1}}%
\endgroup
\expandafter\@ifundefined\@gtempa{%
\PackageError{xargs}{\noexpand#1undefined}{%
Try typing \space <return> \space to proceed.\MessageBreak
If that doesn't work, type \space X <return> \space to quit.}}%
\relax
\let\@ifdefinable\@rc@ifdefinable
\xargs@newc#1}
\newcommand\providecommandx{%
\xargs@star@or@long\xargs@providec}
\newcommand*\xargs@providec[1]{%
\begingroup\escapechar\m@ne
\xdef\@gtempa{{\string#1}}%
\endgroup
\expandafter\@ifundefined\@gtempa
{\def\reserved@a{\xargs@newc#1}}%
{\def\reserved@a{\renew@command\reserved@a}}%
\reserved@a}
\newcommand\newenvironmentx{%
\xargs@star@or@long\xargs@newenv}
\newcommand*\xargs@newenv[1]{%
\@testopt{\xargs@newenva#1}0}
\@ifdefinable\xargs@newenva{%
\def\xargs@newenva#1[#2]{%
\kernel@ifnextchar[%]
{\xargs@newenvb#1[#2]}%
{\xargs@new@env{#1}{[#2]}}}}
\@ifdefinable\xargs@newenvb{%
\def\xargs@newenvb#1[#2][#3]{%
\xargs@new@env{#1}{[#2][{#3}]}}}
\newcommand\xargs@new@env[4]{%
\@ifundefined{#1}{%
\expandafter\let\csname#1\expandafter\endcsname
\csname end#1\endcsname}%
\relax
\expandafter\xargs@newc
\csname #1\endcsname#2{#3}%
\xargs@shortpref\expandafter\def\csname end#1\endcsname{#4}}
\newcommand\renewenvironmentx{%
\xargs@star@or@long\xargs@renewenv}
\newcommand*\xargs@renewenv[1]{%
\@ifundefined{#1}{%
\PackageError{xargs}{\noexpand#1undefined}{%
Try typing \space <return> \space to proceed.\MessageBreak
If that doesn't work, type \space X <return> \space to quit.}}%
\relax
\expandafter\let\csname#1\endcsname\relax
\expandafter\let\csname end#1\endcsname\relax
\xargs@newenv{#1}}
\endinput
%%
%% End of file `xargs.sty'.