summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/styledcmd/styledcmd.dtx
blob: 79da85718adbfebfac04aabb08852ea7111c7713 (plain)
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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
% \iffalse meta-comment
%
%  styledcmd Handle multiple versions for user-defined macros in LaTeX
%  Copyright (C) 2021  Paolo De Donato <dedonato95@hotmail.it>
%
%  This file is part of Styledcmd.
%
%  Styledcmd is free software: you can redistribute it and/or modify
%  it under the terms of the GNU General Public License as published by
%  the Free Software Foundation, either version 3 of the License, or
%  (at your option) any later version.
%
%  Styledcmd is distributed in the hope that it will be useful,
%  but WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%  GNU General Public License for more details.
%
%  You should have received a copy of the GNU General Public License
%  along with Styledcmd.  If not, see <https://www.gnu.org/licenses/>.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{styledcmd.dtx}[2021/08/20 1.1 Command with different styles]
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\RequirePackage{expl3}[2018-04-12]
%<package>\ProvidesExplPackage{styledcmd}{2021/08/20}{1.1}{Command with different styles}
%<package>\RequirePackage{xparse}
%<*driver>
\documentclass[full]{l3doc}
\usepackage{styledcmd}
\begin{document}
\DocInput{styledcmd.dtx}
\end{document}
%</driver>
% \fi
%
%\newstyledcmd{\saluto}{informal}[1]{Hi #1}
%\newstyledcmd{\saluto}{formal}[1]{Good morning #1}
%
%\newcommand{\thpkg}{\pkg{styledcmd}}
%
%\title{styledcmd}
%\author{Paolo De Donato}
%\date{23 August 2021}
%
%\maketitle
%
%\begin{documentation}
%
%\thpkg{} is a \LaTeX{} package that allows you to create and manage different versions of your macro in order to be able to choose the better style for every occasion and avoid rewriting code each time.

%\section{How can you include it in your project?}
%You need only to have the file \verb+styledcmd.sty+ in your current working directory. Otherwise you can manually install it inside your preferred \LaTeX{} compiler (for example \verb+TeXLive+ or \verb+MiKTeX+) in order to make it available for all your projects. Instructions for manually install a package can be found on Internet.
%
%Then once you've added it you can include in your project with this command:
%\begin{verbatim}
% \usepackage{styledcmd}
%\end{verbatim}
%
%\section{How do you use it?}
%You can create a formatted macro via the following command
%\begin{function}{\newstyledcmd, \renewstyledcmd, \providestyledcmd}
%\begin{syntax}
%|\newstyledcmd| \marg{macro name} \marg{format name} \oarg{number of arguments} \marg{code}
%\end{syntax}
%\end{function}
%
%You can repeat that command for the same macro in order to create different styles, for example these commands
%\begin{verbatim}
%    \newstyledcmd{\saluto}{informal}[1]{Hi #1}
%    \newstyledcmd{\saluto}{formal}[1]{Good morning #1}
%\end{verbatim}
%define the two formats \verb+informal+ and \verb+formal+ for macro \tn{saluto}. You can directly use the command \tn{saluto} and use the default format (the first declared one) or using a specific style by passing it as an optional argument. So commands
%\begin{verbatim}
%    \saluto{uncle}
%    \saluto[informal]{uncle}
%    \saluto[formal]{uncle}
%\end{verbatim}
%will be expanded respectively as \saluto{uncle}, \saluto[informal]{uncle}, \saluto[formal]{uncle}. With the same syntax you can use \tn{renewstyledcmd} and \tn{providestyledcmd} with the same meaning of \tn{renewcommand} and \tn{providecommand} respectively.
%
%\section{How do you change the default style?}
%In order to change the default style (the one used when you don't choose explicitily a format) you need to execute the following command
%\begin{function}{\setGlobalStyle}
%\begin{syntax}
%|\setGlobalStyle| \marg{command name} \marg{new default format name}
%\end{syntax}
%\end{function}
%\setGlobalStyle{\saluto}{formal}
%
%For example in order to change the default style of command \tn{saluto} from \verb+informal+ to \verb+formal+ you need to execute command \verb+\setGlobalStyle{\saluto}{formal}+. With this command the output of preceding commands will instead be \saluto{uncle}, \saluto[informal]{uncle}, \saluto[formal]{uncle}.
%
%\section{Customize parameters with \pkg{xparse}}
%\thpkg{} loads automatically the \pkg{xparse} package for internal reasons. You can also define new styled commands with the same syntax used by  \tn{NewDocumentCommand} with the following command
%
%\begin{function}{\NewDocStyledCMD, \RenewDocStyledCMD, \ProvideDocStyledCMD}
%\begin{syntax}
%|\NewDocStyledCMD| \marg{command name} \marg{format name} \marg{arguments format} \marg{code}
%\end{syntax}
%\end{function}
%
%\NewDocStyledCMD{\prova}{stylea}{r<>}{Stile 1 #1}
%\NewDocStyledCMD{\prova}{styleb}{r<>}{Stile 2 #1}
%For example we can create the following two styles
%\begin{verbatim}
%     \NewDocStyledCMD{\prova}{stylea}{r<>}{Stile 1 #1}
%     \NewDocStyledCMD{\prova}{styleb}{r<>}{Stile 2 #1}
%\end{verbatim}
%in order to execute
%\begin{verbatim}
%    \prova<Hello>
%    \prova[stylea]<Hello>
%    \prova[styleb]<Hello>
%\end{verbatim}
%which are expanded respectively as \prova<Hello>; \prova[stylea]<Hello>; \prova[styleb]<Hello>. Notice that the first optional argument passed to a command defined via \tn{NewDocStyleCMD} will always be interpreted as a style argument, so you should use another syntax for optional arguments or use a mandatory argument for the first place.
%
%For example this declaration \verb+\NewDocStyledCMD{\bad}{style}{o m}{Bad declaration}+ should be avoided since for example \verb+\bad[arg1]{arg2}+ will interpret \verb+arg1+ as a style name and not as the first optional argument for \tn{bad}.
%
%
%\section{Commands group}
%You can define also a commands group in which defined commands will share the same styles, that allow you to change the style for all commands in that group.
%
%To start a group you have to use the following macro
%\begin{function}{\styBeginGroup}
%\begin{syntax}
%|\styBeginGroup| \marg{group name}
%\end{syntax}
%\end{function}
%any group should be terminated via the following macro
%\begin{function}{\styEndGroup}
%\begin{syntax}
%|\styEndGroup|
%\end{syntax}
%\end{function}
%
%In each group commands are grouped toghether according to the used style. So inside a group you can define a style with the command
%\begin{function}{\styBeginStyle}
%\begin{syntax}
%|\styBeginStyle| \marg{format name}
%\end{syntax}
%\end{function}
%and once you've finished to define command with that style you have to close it with the command
%\begin{function}{\styEndStyle}
%\begin{syntax}
%|\styEndStyle|
%\end{syntax}
%\end{function}
%
%In order to define a command inside a \tn{styBeginStyle} ... \tn{styEndStyle} you can use
%
%\begin{function}{\newGstyledcmd}
%\begin{syntax}
%|\newGstyledcmd| \marg{command name} \oarg{arguments number} \marg{code}
%\end{syntax}
%\end{function}
%or
%\begin{function}{\NewGDocStyledCMD}
%\begin{syntax}
%|\NewGDocStyledCMD| \marg{command name} \marg{arguments format} \marg{code}
%\end{syntax}
%\end{function}
%if you want to use the \tn{NewDocumentCommand} syntax.
%
%Notice that in this case you mustn't define the style name in \tn{newGstyledcmd} or in \tn{NewGDocStyledCMD} since they use the format defined in the enclosing \tn{styBeginStyle} ... \tn{styEndStyle}. The defined style for a group is the first defined one, in order to change the default format you should use the following macro
%
%\begin{function}{\setGroupStyle}
%\begin{syntax}
%|\setGroupStyle| \marg{group name} \marg{new default style}
%\end{syntax}
%\end{function}
%
%Consider now the following example
%
%    \styBeginGroup{saluti}
%    \styBeginStyle{formal}
%    \newGstyledcmd{\ciao}[1]{Good morning #1}
%    \newGstyledcmd{\via}{Goodbye}
%    \styEndStyle
%    \styBeginStyle{informal}
%    \newGstyledcmd{\ciao}[1]{Hi #1}
%    \newGstyledcmd{\via}{Catch you later}
%    \styEndStyle
%    \styEndGroup
%
%\begin{verbatim}
%    \styBeginGroup{saluti}
%      \styBeginStyle{formal}
%        \newGstyledcmd{\ciao}[1]{Good morning #1}
%        \newGstyledcmd{\via}{Goodbye}
%      \styEndStyle
%
%      \styBeginStyle{informal}
%        \newGstyledcmd{\ciao}[1]{Hi #1}
%        \newGstyledcmd{\via}{Catch you later}
%      \styEndStyle
%    \styEndGroup
%\end{verbatim}
%We've defined the group \verb+saluti+ with two styles: \verb+formal+ and \verb+informal+. In that group are also defined the two commands \tn{ciao} and \tn{via} for both the styles. Since in \verb+saluti+ group the first defined style is \verb+formal+ it'll be also the default style for this group, so commands \verb+\ciao{Enrico}+ and \verb+\via+ will be expanded as \ciao{Enrico} and \via{}.
%
%If now we execute the command \setGroupStyle{saluti}{informal} \verb+\setGroupStyle{saluti}{informal}+ we change the default style to \verb+informal+ so the preceding commands this time will be expanded as \ciao{Enrico} and \via{}.
%
%You can also pass an optional argument for the style name you want to use, in particular \verb+\ciao[formal]{Enrico}+ will be always expanded as \ciao[formal]{Enrico}.
%
%\section{Generate more styled commands}
%Suppose now that you've created your own version of \tn{newcommand} or \tn{NewDocumentCommand} in order to generate some classes of commands. Suppose that your function name is \tn{mynewcommand} and it accepts, like \tn{newcommand}, the new macro as its first argument. Then you can create styled commands with your own macro by using this function
%\begin{function}{\stycmd_generate:NN, \stycmd_generate_renew:NN}
%\begin{syntax}
%|\stycmd_generate:NN| \meta{new generator name} \meta{generator name}
%\end{syntax}
%\end{function}
%So for example executing
%\begin{verbatim}
% \stycmd_generate:NN\mynewstyledcommand\mynewcommand
%\end{verbatim}
%you'll create the new macro \tn{mynewstyledcommand} that accepts the command you want to define as first argument, the style you want to use as second argument and the remaining arguments are the same needed by \tn{mynewcommand}.
%
%Notice that \tn{newstyledcmd} is defined internally as
%\begin{verbatim}
% \stycmd_generate:NN \newstyledcmd \newcommand
%\end{verbatim}
%
%Notice that \tn{mynewcommand} first argument has to be the macro you want to define, otherwise \cs{stycmd_generate:NN} will have undefined behaviour. The \cs{stycmd_generate_renew:NN} function should be used only for ''renew`` type commands that requires a preceding declaration, like \tn{renewcommand} and \tn{RenewDocumentCommand}.
%
%Actually there isn't any analogue proceeding for defining customized versions for \tn{newGstyledcmd} and \tn{NewGDocStyledCMD}.
%
%\end{documentation}
%
%\begin{implementation}
%
%\section{Implementation}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
%    \begin{macrocode}
%<@@=stycmd>
%    \end{macrocode}
%
%\begin{variable}{\c__stycmd_defname_str}
%the default style
%    \begin{macrocode}
\str_const:Nn \c_@@_defname_str{ default }
%    \end{macrocode}
%\end{variable}
%
%\begin{variable}{\l__stycmd_cexp_str, \l__stycmd_fexp_str}
%Temporary variables to store expanded names.
%    \begin{macrocode}
\str_new:N \l_@@_cexp_str
\str_new:N \l_@@_fexp_str
%    \end{macrocode}
%\end{variable}
%
%\begin{macro}{\__stycmd_cmd:nn, \__stycmd_cmd:nV, \__stycmd_cmd:VV, \__stycmd_cmd:, \__stycmd_cmddefname:n}
%Name of a command bounded to some style.
%    \begin{macrocode}
\cs_new:Npn \__stycmd_cmd:nn #1#2{ @@_command_#1_#2 }

\cs_generate_variant:Nn \@@_cmd:nn { nV }
\cs_generate_variant:Nn \@@_cmd:nn { VV }

\cs_new:Nn \@@_cmd:
  {
    \@@_cmd:VV\l_@@_cexp_str\l_@@_fexp_str
  }

\cs_new:Npn \@@_cmddefname:n #1
  {
    \@@_cmd:nV { #1 } \c_@@_defname_str
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\__stycmd_erroring:nn, \__stycmd_erroring:nV, \__stycmd_erroring:VV}
%Error messages for undefined styles.
%    \begin{macrocode}
\msg_new:nnn { stycmd } { noformat }
  {
    Style~#2~not~defined~for~command~#1
  }

\cs_new_protected:Npn\@@_erroring:nn #1#2
  {
    \cs_if_free:cT { \@@_cmd:nn {#1} {#2} }
      { \msg_error:nnnn { stycmd } { noformat } {#1} {#2} }
  }

\cs_generate_variant:Nn \@@_erroring:nn { nV, VV }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\__stycmd_deferr:}
%Error message when try to create the \verb+default+ style
%    \begin{macrocode}
\msg_new:nnn { stycmd } { deferror }
  {
    Cannot~define~a~style~with~name~default
  }

\cs_new_protected:Nn\@@_deferr:
  {
    \str_if_eq:NNT \l_@@_fexp_str \c_@@_defname_str
      { \msg_error:nn { stycmd } { deferror }  }
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\__stycmd_macro_default:nn, \__stycmd_macro_default:VV}
%Sets the default style to use.
%    \begin{macrocode}
\cs_new_protected:Npn \@@_macro_default:nn #1#2
  {
    \exp_args:Nc \ProvideDocumentCommand { \@@_cmddefname:n { #1 } }
      {}
      {
        \use:c { \@@_cmd:nn { #1 } { #2 } }
      }
  }

\cs_generate_variant:Nn \@@_macro_default:nn { VV }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\__stycmd_macro_overwrite:nn, \__stycmd_macro_overwrite:VV}
%Overwrite the default style, not the command associated to that style.
%    \begin{macrocode}
\cs_new_protected:Npn \@@_macro_overwrite:nn #1#2
  {
    \@@_erroring:nn { #1 } { #2 }

    \exp_args:Nc \RenewDocumentCommand { \@@_cmddefname:n { #1 } }
      {}
      {
        \use:c { \@@_cmd:nn { #1 } { #2 } }
      }
  }

\cs_generate_variant:Nn \@@_macro_overwrite:nn { VV }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\__stycmd_macro_declaration:n, \__stycmd_macro_declaration:V}
%Declare the effective macro. It'll overwrite existing \tn{l__stycmd_fexp_str}.
%    \begin{macrocode}
\cs_new_protected:Npn \@@_macro_declaration:n #1
  {
    \exp_args:Nc \ProvideDocumentCommand { #1 } {o}
      {
        \IfNoValueTF {##1}
          {
            \use:c { \@@_cmddefname:n { #1 } }
          }
          {
            \str_set:Nx \l_@@_fexp_str {##1}
            \@@_erroring:nV { #1 } \l_@@_fexp_str
            \use:c{ \@@_cmd:nV { #1 } \l_@@_fexp_str }
          }
      }
  }

\cs_generate_variant:Nn \__stycmd_macro_declaration:n { V }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\__stycmd_init_vars:Nn}
%Initializes system variables. First argument is the command name, second argument should be \verb+x+ expandable.
%    \begin{macrocode}
\cs_new_protected:Npn \@@_init_vars:Nn #1#2
  {
    \str_set:Nx \l_@@_cexp_str { \cs_to_str:N #1 }
    \str_set:Nx \l_@@_fexp_str {#2}
    \@@_deferr:
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\stycmd_generate:NN, \stycmd_generate_renew:NN}
%Declare the styled version \verb+#1+ of the macro generator command \verb+#2+. the \verb+_renew+ variant requires a preceding declaration
%    \begin{macrocode}
\cs_new_protected:Npn \stycmd_generate:NN #1#2
  {
    \NewDocumentCommand #1 {m m}
      {
        \@@_init_vars:Nn { ##1 } { ##2 }
        \@@_macro_default:VV \l_@@_cexp_str \l_@@_fexp_str
        \@@_macro_declaration:V \l_@@_cexp_str
        \exp_args:Nc #2 { \@@_cmd: }
      }
  }

\cs_new_protected:Npn \stycmd_generate_renew:NN #1#2
  {
    \NewDocumentCommand #1 {m m}
      {
        \@@_init_vars:Nn { ##1 } { ##2 }
        \@@_erroring:VV \l_@@_cexp_str \l_@@_fexp_str
        \exp_args:Nc #2 { \@@_cmd: }
      }
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\newstyledcmd, \renewstyledcmd, \providestyledcmd}
%Declare a new macro with the specified style name.
%    \begin{macrocode}
\stycmd_generate:NN \newstyledcmd \newcommand
\stycmd_generate_renew:NN \renewstyledcmd \renewcommand
\stycmd_generate:NN \providestyledcmd \providecommand
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\NewDocStyledCMD, \RenewDocStyledCMD, \ProvideDocStyledCMD}
%Declare a new styled macro with the \tn{NewDocumentCommand} syntax.
%    \begin{macrocode}
\stycmd_generate:NN \NewDocStyledCMD \NewDocumentCommand
\stycmd_generate_renew:NN \RenewDocStyledCMD \RenewDocumentCommand
\stycmd_generate:NN \ProvideDocStyledCMD \ProvideDocumentCommand
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\setGlobalStyle}
%Change the default style.
%    \begin{macrocode}
\NewDocumentCommand \setGlobalStyle{m m}{
    \@@_init_vars:Nn { #1 } { #2 }

    \@@_macro_overwrite:VV \l_@@_cexp_str \l_@@_fexp_str
}
%    \end{macrocode}
%\end{macro}
%
%\begin{variable}{\l__stycmd_group_str, \l__stycmd_format_str}
%Variables that stores group and format names.
%    \begin{macrocode}
\str_new:N \l_@@_group_str
\str_new:N \l_@@_format_str
%    \end{macrocode}
%\end{variable}
%
%\begin{macro}{\__stycmd_gvar:n, \__stycmd_gvar:V, \__stycmd_gvar:}
%Group command list.
%    \begin{macrocode}
\cs_new:Npn \@@_gvar:n #1 { g_@@_glist_#1_seq }

\cs_generate_variant:Nn \@@_gvar:n { V }

\cs_new:Nn \@@_gvar: { \@@_gvar:V \l_@@_group_str }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\__stycmd_push_g:Nn, \__stycmd_push_g:NV}
%Pushes command name inside group command sequence. First argument is command, second is group name
%    \begin{macrocode}
\cs_new_protected:Npn \@@_push_g:Nn #1#2
  {
    \seq_gput_left:cn { \@@_gvar:n { #2 } } { #1 }
  }

\cs_generate_variant:Nn \@@_push_g:Nn { NV }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\styBeginGroup}
%Starts a group.
%    \begin{macrocode}
\msg_new:nnn { stycmd } { gnotclosed } { Group~not~closed }

\NewDocumentCommand \styBeginGroup { m }
  {
    \str_if_empty:NF \l_@@_group_str
      {
        \msg_error:nn { stycmd } { gnotclosed }
      }

    \str_set:Nx \l_@@_group_str {#1}

    \seq_if_exist:cF { \@@_gvar: }
      { \seq_new:c { \@@_gvar: } }
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\styEndGroup}
%Closes a group.
%    \begin{macrocode}
\NewDocumentCommand \styEndGroup {}
  {
    \str_clear:N \l_@@_group_str
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\styBeginStyle}
%Starts a style subgroup.
%    \begin{macrocode}
\msg_new:nnn { stycmd } { fnotclosed } { Format~not~closed }

\NewDocumentCommand \styBeginStyle { m }
  {
    \str_if_empty:NF \l_@@_format_str
      {
        \msg_error:nn { stycmd } { fnotclosed }
      }
    \str_set:Nx \l_@@_format_str {#1}
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\styEndStyle}
%Closes a style subgroup.
%    \begin{macrocode}
\NewDocumentCommand \styEndStyle {}
  {
    \str_clear:N \l_@@_format_str
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\newGstyledcmd}
%Declare a command inside a styled group.
%    \begin{macrocode}
\NewDocumentCommand \newGstyledcmd { m o +m }
  {
    \IfNoValueTF {#2}
      {
        \newstyledcmd {#1} { \l_@@_format_str } {#3}
      }
      {
        \newstyledcmd {#1} { \l_@@_format_str } [#2] {#3}
      }
    \@@_push_g:NV {#1} \l_@@_group_str
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\NewGDocStyledCMD}
%Equivalent of \tn{NewDocStyledCMD} for command defined in a group.
%    \begin{macrocode}
\NewDocumentCommand \NewGDocStyledCMD { m m +m }
  {
    \NewDocStyledCMD {#1} { \l_@@_format_str } {#2} {#3}

    \@@_push_g:NV {#1} \l_@@_group_str
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\setGroupStyle}
%Change the default style for a group.
%    \begin{macrocode}
\NewDocumentCommand \setGroupStyle { m m }
  {
    \str_set:Nx \l_@@_group_str {#1}
    \str_set:Nx \l_@@_format_str {#2}
    \seq_map_inline:cn { \@@_gvar: }
      {
        \setGlobalStyle {##1} { \l_@@_format_str }
      }
    \str_clear:N \l_@@_format_str
    \str_clear:N \l_@@_group_str
  }
%    \end{macrocode}
%\end{macro}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
%\end{implementation}
%
%\PrintIndex