summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/argumentation/argumentation.sty
blob: 6633c25a3a90f983f5dda6928a3d671de35e8cec (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
574
575
576
577
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{argumentation}[2024/11/03 Argumentation]
% Author:   Lars Bengel
% E-Mail:   lars.bengel@fernuni-hagen.de
% Version:  1.4
% Date:     2024/11/03
% License:  LaTeX Project Public License 1.3c


%%%%%%%%%%% Package Requirements %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{amsbsy,amsmath}                 % Proper bold letters in math mode
\RequirePackage{pgfopts}                        % Managing package options
\RequirePackage{etoolbox}                       % Internal list handling
\RequirePackage{refcount}                       % Expandable ref-counter value
\RequirePackage{xspace}                         % Dynamic spaces after math commands
\RequirePackage{xcolor}                         % Defining colors
\RequirePackage{tikz}                           % Drawing the argumentation frameworks
\usetikzlibrary{positioning}                    % Relative node positioning
\usetikzlibrary{arrows.meta}                    % Directed edges / attack arrows
\usetikzlibrary{arrows}                         % Directed edges / attack arrows
\usetikzlibrary{decorations.markings}           % Creating the support edge markings


%%%%%%%%%%% Package Style Definitions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Color definitions
\definecolor{aigyellow}{RGB}{210,149,81}        % Highlight color
\definecolor{aigblue}{RGB}{0,76,151}            % Node color

%%% Argument Style Definitions
\tikzset{
    argument size/.style={},                                                                    % Size of argument nodes
    argument/.style={},                                                                         % Base style for argument nodes
    argument standard/.style={circle,draw=black,inner sep=0,outer sep=0},                       % Standard argument style
    argument large/.style={circle,draw=black,inner sep=0,outer sep=0, font=\large},             % Large argument style
    argument thick/.style={circle,draw=black,inner sep=0,outer sep=0, line width=0.1em},        % Thick outline argument style
    argument gray/.style={argument thick,fill=gray!30,draw=gray!65,text=black!80},              % Gray argument style
    argument colored/.style={argument thick,fill=aigblue!40,draw=aigblue!80},                   % Colored argument stlye
}

%%% Attack/Support Edge Definitions
\tikzset{
    attack width/.style={},                                                 % Width of attack arrows
    attack/.style={},                                                       % Base style for attack arrow
    attack standard/.style={-{stealth'}},                                   % Standard attack arrow
    attack large/.style={-{Stealth[scale=1.25]}},                           % Larger arrow tip
    attack modern/.style={-{To[sharp,length=0.65ex,line width=0.05em]}},    % Mordern rightarrow style tip
    support/.style={},                                                      % Base style for support
    support standard/.style = {attack, postaction = {decorate,decoration={markings,mark=at position 0.36 with {\draw[-] (0,-0.1) -- (0.1,0.1);}}}},                                             % Standard support arrow
    support dashed/.style={attack,densely dashed},                          % Dashed Support arrow
    support double/.style={-{Classical TikZ Rightarrow},double},            % double-line support arrow
}

%%% Additional Style Parameters
\tikzset{
    selfattack/.style={loop,min distance=0.4em,in=0,out=60,looseness=4.5},  % Self-attack
    inactive/.style={fill=none,draw=gray!50,text=gray!60},                  % Inactive argument or edge (reduct)
    incomplete/.style={densely dashed},                                     % incomplete argument or edge
    accepted/.style={fill=green!40},                                        % Accepted argument (in)
    rejected/.style={fill=red!40},                                          % Rejected argument (out)
    undecided/.style={fill=cyan!40},                                        % Undecided Argument (undec)
    highlight/.style={fill=aigyellow!60},                                   % Highlighted argument
    caption/.style={draw=none},                                             % Caption or text
    invisible/.style={draw=none,fill=none,opacity=0.0},                     % Invisible argument or edge
    annotation/.style={font=\small},                                        % Argument annotation
    argin/.style={accepted},
    argout/.style={rejected},
    argundec/.style={undecided},
}

%%% Style-Options for af environment
\pgfkeys{/tikz/.cd,
    af/.style={},                                               % Base style for af
    standard/.style={node distance=6.6ex,argument size/.style={minimum size=4.5ex},attack width/.style={line width=0.05em}},                                                                % Standard size style for af
    small/.style={node distance=3.5ex,argument size/.style={minimum size=3.4ex},attack width/.style={line width=0.045em},caption/.append style={font=\small}},        % Small size style for af
    tiny/.style={node distance=2.3ex,argument size/.style={minimum size=2.6ex,font=\small},attack width/.style={line width=0.03em},caption/.append style={font=\small}},         % Tiny size style for af
}


%%%%%%%%%% Internal Utility Functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\newif\ifmacros
\newif\ifbeamer
\newif\if@numericidx
\newif\if@alphaidx
\newif\if@insideaf

%%% Defines the font style in which argument names are displayed
\newcommand{\@arg@style}[1]{#1}

%%% Auxilliary command for splitting a given pair x,y into two macros
\def\@split@pair#1,#2\relax{%
  \def\@attacker{#1}%
  \def\@attacked{#2}%
}
\makeatother

%%%%%%%%%% Package Options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Options for style of the argument node itself
\pgfkeys{/tikz/.cd,
    argumentstyle/.is choice,
    argumentstyle/standard/.code={\tikzset{argument/.style={argument standard,argument size}}},
    argumentstyle/large/.code={\tikzset{argument/.style={argument large,argument size}}},
    argumentstyle/thick/.code={\tikzset{argument/.style={argument thick,argument size}}},
    argumentstyle/gray/.code={\tikzset{argument/.style={argument gray,argument size}}},
    argumentstyle/colored/.code={\tikzset{argument/.style={argument colored,argument size}}},
}
\pgfkeys{/argumentation/.cd,
    .unknown/.code={},
    argumentstyle/.is choice,
    argumentstyle/standard/.code={\tikzset{argument/.style={argument standard,argument size}}},
    argumentstyle/large/.code={\tikzset{argument/.style={argument large,argument size}}},
    argumentstyle/thick/.code={\tikzset{argument/.style={argument thick,argument size}}},
    argumentstyle/gray/.code={\tikzset{argument/.style={argument gray,argument size}}},
    argumentstyle/colored/.code={\tikzset{argument/.style={argument colored,argument size}}},
    argumentstyle=standard,
}

%%% Options for the style of the attack edges
\pgfkeys{/tikz/.cd,
    attackstyle/.is choice,
    attackstyle/standard/.code={\tikzset{attack/.style={attack width,attack standard}}},
    attackstyle/large/.code={\tikzset{attack/.style={attack width,attack large}}},
    attackstyle/modern/.code={\tikzset{attack/.style={attack width,attack modern}}},
    attackstyle=standard,
}
\pgfkeys{/argumentation/.cd,
    attackstyle/.is choice,
    attackstyle/standard/.code={\tikzset{attack/.style={attack width,attack standard}}},
    attackstyle/large/.code={\tikzset{attack/.style={attack width,attack large}}},
    attackstyle/modern/.code={\tikzset{attack/.style={attack width,attack modern}}},
    attackstyle=standard,
}

%%% Options for the style of the support edges
\pgfkeys{/tikz/.cd,
    supportstyle/.is choice,
    supportstyle/standard/.code={\tikzset{support/.style={support standard}}},
    supportstyle/dashed/.code={\tikzset{support/.style={support dashed}}},
    supportstyle/double/.code={\tikzset{support/.style={support double}}},
    supportstyle=standard,
}
\pgfkeys{/argumentation/.cd,
    supportstyle/.is choice,
    supportstyle/standard/.code={\tikzset{support/.style={support standard}}},
    supportstyle/dashed/.code={\tikzset{support/.style={support dashed}}},
    supportstyle/double/.code={\tikzset{support/.style={support double}}},
    supportstyle=standard,
}

%%% Options for the automatic text formatting for the argument names
\makeatletter
\pgfkeys{/tikz/.cd,
    namestyle/.is choice,
    namestyle/none/.code={\renewcommand{\@arg@style}[1]{##1}},
    namestyle/math/.code={\renewcommand{\@arg@style}[1]{\ensuremath{##1}}},
    namestyle/bold/.code={\renewcommand{\@arg@style}[1]{\ensuremath{\boldsymbol{##1}}}},
    namestyle/monospace/.code={\renewcommand{\@arg@style}[1]{{\ttfamily##1}}},
    namestyle/monoemph/.code={\renewcommand{\@arg@style}[1]{{\ttfamily\itshape##1}}},
    namestyle=none,
}
\pgfkeys{/argumentation/.cd,
    namestyle/.is choice,
    namestyle/none/.code={\renewcommand{\@arg@style}[1]{##1}},
    namestyle/math/.code={\renewcommand{\@arg@style}[1]{\ensuremath{##1}}},
    namestyle/bold/.code={\renewcommand{\@arg@style}[1]{\ensuremath{\boldsymbol{##1}}}},
    namestyle/monospace/.code={\renewcommand{\@arg@style}[1]{{\ttfamily##1}}},
    namestyle/monoemph/.code={\renewcommand{\@arg@style}[1]{{\ttfamily\itshape##1}}},
    namestyle=none,
}


%%% Option for automatic indexing of arguments
\pgfkeys{/argumentation/.cd,
    indexing/.is choice,
    indexing/numeric/.code={\@numericidxtrue},
    indexing/alphabetic/.code={\@alphaidxtrue},
    indexing/none/.code={\@numericidxfalse\@alphaidxfalse},
    indexing/.default=numeric,
    indexing=numeric,
}
\makeatother

%%% Option for enabling additional macros
\pgfkeys{/argumentation/.cd,
    macros/.is choice,
    macros/true/.code={\macrostrue},
    macros/false/.code={\macrosfalse},
    macros/.default=true,
    macros=false,
}

%%% Option for enabling beamer functionality
\pgfkeys{/argumentation/.cd,
    beamer/.is choice,
    beamer/true/.code={\beamertrue},
    beamer/false/.code={\beamerfalse},
    beamer/.default=true,
    beamer=false,
}

\ProcessPgfPackageOptions{/argumentation}


%%%%%%%%%%%%%%% Arguments %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
% Internal counter for argument IDs
\newcounter{@argument}

%%% Command for creating arguments
%   #1 TikZ parameters (optional)
%   #2 unique argument ID (optional)
%   #3 argument display name
%   #4 ignored
%   #5 absolute positioning values (optional)
\NewDocumentCommand { \argument } {O{} d() m dat d()} {%
    \stepcounter{@argument}
    \IfNoValueTF {#2}{%
        \if@alphaidx
            \edef\@argid{\alph{@argument}}
        \else\if@numericidx
            \edef\@argid{a\arabic{@argument}}
        \else
            \PackageError{argumentation}{Missing argument ID}{Must either provide argument ID inside () or activate auto-indexing}
        \fi\fi
    }{%
        \edef\@argid{#2}
    }
    \ifbeamer
        \if@insideaf
            \@make@argument{#1}{\@argid}{#3}{#4}{#5}{\arabic{af}}
            \csname @af@\arabic{af}@arg@\@argid\endcsname{}
        \else
            \@create@argument{#1}{}{\@argid}{#3}{#5}
        \fi
    \else
        \@create@argument{#1}{}{\@argid}{#3}{#5}
    \fi
}

%%% Auxilliary command for creating arguments
%   #1 TikZ parameters (optional)
%   #2 TikZ parameters (optional)
%   #3 unique argument ID (optional)
%   #4 argument display name
%   #5 absolute positioning value (optional)
\NewDocumentCommand { \@create@argument } {mmmmm} {%
    \IfNoValueTF {#5}{%
        \node[argument size,argument,#1,#2](#3) {\@arg@style{#4}};
    }{%
        \node[argument size,argument,#1,#2](#3) at (#5) {\@arg@style{#4}};
    }
}

\ifbeamer
%%% Auxilliary command for creating unique argument macros
%   #1 TikZ parameters
%   #2 unique argument ID
%   #3 argument display name
%   #4 ignored
%   #5 absolute positioning values
%   #6 unique AF ID
\NewDocumentCommand { \@make@argument } {mmmmmm} {%
    %\typeout{CREATED NEW MACRO @af@#6@arg#2}
    \expandafter\listxadd\csname @arguments@#6\endcsname{#2}
    \expandafter\global\expandafter\edef\csname @af@#6@arg@#2\endcsname##1{%
        %\typeout{RECALLING MACRO @af@#6@arg#2}
        \@create@argument{#1}{##1}{#2}{#3}{#5}
    }
}
\fi
\makeatother


%%%%%%%%%%%%%%% Attacks & Support %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
%%% Command for creating attacks
%   #1 TikZ parameters (optional)
%   #2 attacking argument ID
%   #3 attacked argument ID
%   #4 annotation text (optional)
\NewDocumentCommand { \attack } {O{} m m d()} {%
    \ifbeamer
        \if@insideaf
            \@make@attack{#1}{#2}{#3}{#4}{\arabic{af}}
            \csname @af@\arabic{af}@att@#2#3\endcsname{}
        \else
            \@create@attack{#1}{}{#2}{#3}{#4}
        \fi
    \else
        \@create@attack{#1}{}{#2}{#3}{#4}
    \fi
}

%%% Internal command for creating the attack in TikZ
%   #1 TikZ parameters (optional)
%   #2 TikZ parameters (optional)
%   #3 attacking argument ID
%   #4 attacked argument ID
%   #5 annotation text
\NewDocumentCommand { \@create@attack } {mmmmm} {%
    \IfNoValueTF{#5}{%
        \path(#3) edge [attack,#1,#2] (#4);
    }{%
        \path(#3) edge [attack,#1,#2] node[annotation](p_#3_#4){#5} (#4);
    }
}

\ifbeamer
%%% Auxilliary command for creating unique attack macros
%   #1 TikZ parameters
%   #2 attacking argument ID
%   #3 attacked argument ID
%   #4 annotation text
%   #5 unique AF ID
\NewDocumentCommand { \@make@attack } {mmmmm} {%
    \expandafter\listgadd\csname @attacks@#5\endcsname{#2,#3}
    \expandafter\global\expandafter\edef\csname @af@#5@att@#2#3\endcsname##1{
        \@create@attack{#1}{##1}{#2}{#3}{#4}
    }
}
\fi

%%% Self-attack edge
%   #1 TikZ parameters (optional)
%   #2 argument ID
\NewDocumentCommand { \selfattack } {O{} m} {%
    \attack[selfattack,#1]{#2}{#2}
}

%%% Symmetric attack edges between two arguments
%   #1 TikZ parameters (optional)
%   #2 first argument ID
%   #3 second argument ID
\NewDocumentCommand { \dualattack } {O{} m m} {%
    \attack[bend right,#1]{#2}{#3}
    \attack[bend right,#1]{#3}{#2}
}

%%% Create attack edge with value (DEPRECATED as of v1.4)
%   #1 TikZ parameters (optional)
%   #2 attacking argument ID
%   #3 attacked argument ID
%   #4 annotation text
\NewDocumentCommand{ \annotatedattack } {O{}mmm} {%
    \attack[#1]{#2}{#3}(#4)
}

%%% Support edge
%   #1 TikZ parameters (optional)
%   #2 supporting argument ID
%   #3 supported argument ID
\NewDocumentCommand { \support } {O{} m m} {%
    \path(#2) edge [support=0.35,#1] (#3);
}
\makeatother


%%%%%%%%%%%%%%%  AF Environment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{af}

%%% Uncounted version of the environment
\makeatletter
\NewDocumentEnvironment {af*} {O{}} {%
    \setcounter{@argument}{0}
    \pgfkeys{/argumentation/.cd, #1}
    \tikzpicture[standard,af,#1]
}{%
    \endtikzpicture
}

%%% Standard version of af environment
\NewDocumentEnvironment {af} {O{}} {%
    \refstepcounter{af}
    \ifbeamer
        \global\expandafter\def\csname @arguments@\arabic{af}\endcsname{}
        \global\expandafter\def\csname @attacks@\arabic{af}\endcsname{}
    \fi
    \@insideaftrue
    \begin{af*}[#1]
}{%
    \end{af*}
    \@insideaffalse
}
\makeatother


%%%%%%%%%%%%%%%% Additional Commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Definitions for referencing
\ifmacros
    \providecommand{\AF}{\ensuremath{F}\xspace}                     % AF abbreviation
    \providecommand{\arguments}{\ensuremath{A}\xspace}              % Set of arguments
    \providecommand{\attacks}{\ensuremath{R}\xspace}                % Set of attacks
    \providecommand{\AFcomplete}{\ensuremath{\AF = (\arguments, \attacks)}\xspace}  % Full AF
    \newcommand{\afref}[1]{\ensuremath{\AF_{\ref{#1}}}\xspace}      % Reference an AF
    \newcommand{\fullafref}[1]{\ensuremath{\afref{#1} = (\arguments_{\ref{#1}}, \attacks_{\ref{#1}})}\xspace}                                   % Full AF with reference
\fi

%%% Creates a node displaying the name of the AF
\NewDocumentCommand { \afname } { O{} D(){caption} m dat d()} {%
    \IfNoValueTF {#5}{%
        \node[caption,#1](#2){#3};
    }{%
        \node[caption,#1](#2) at (#5) {#3};
    }
}

%%% Create a text annotation next to another node
\NewDocumentCommand { \annotation } {O{} m m} {%
    \node[annotation,above of=#2,#1](an_#2){#3};
}

%%% Commands for setting custom tikz-style parameters
\newcommand{\setafstyle}[1]{\tikzset{af/.style={#1}}}
\newcommand{\setargumentcolorscheme}[2]{\tikzset{argument colored/.style={argument thick,fill=#2,draw=#1}}}
\newcommand{\setargumentstyle}[1]{\tikzset{argument/.style={argument size,#1}}}
\newcommand{\setattackstyle}[1]{\tikzset{attack/.style={attack width,#1}}}
\newcommand{\setsupportstyle}[1]{\tikzset{support/.style={#1}}}
\newcommand{\setannotationstyle}[1]{\tikzset{annotation/.style={#1}}}


%%%%%%%%%%%% Beamer Commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ifbeamer
\makeatletter
%%% Prints an extension of an AF for the given list of accepted arguments
%   #1 unique ID of an AF
%   #2 a comma-separated list of argument IDs
\NewDocumentCommand { \afextension } {mm} {%
    \@prepare@af{#1}
    % Collect accepted arguments in list
    \forcsvlist{\listeadd\@accepted@arguments}{#2}

    % render the af with the given information
    \@render@af{\@afid}{accepted}{}{}{}{}
}

%%% Prints a labeling of an AF for the given list of accepted arguments
%   #1 unique ID of an AF
%   #2 a comma-separated list of argument IDs
\NewDocumentCommand { \aflabeling } {mm} {%
    \@prepare@af{#1}
    % Collect accepted arguments in list
    \forcsvlist{\listeadd\@accepted@arguments}{#2}

    % Collect rejected arguments in list
    \renewcommand*{\do}[1]{
        \expandafter\@split@pair##1\relax
        \xifinlist{\@attacker}{\@accepted@arguments}{%
            \listeadd\@rejected@arguments{\@attacked}
        }{}
    }
    \dolistcsloop{@attacks@\@afid}

    % Collect undecided arguments in list
    \renewcommand*{\do}[1]{
        \xifinlist{##1}{\@accepted@arguments}{}{
            \xifinlist{##1}{\@rejected@arguments}{}{
                \listadd\@undecided@arguments{##1}
            }
        }
    }
    \dolistcsloop{@arguments@\@afid}

    % render the af with the given information
    \@render@af{\@afid}{accepted}{rejected}{undecided}{}{}
}

%%% Prints the reduct of an AF wrt. the given list of arguments
%   #1 unique ID of an AF
%   #2 a comma-separated list of argument IDs
\NewDocumentCommand { \afreduct } {mm} {%
    \@prepare@af{#1}
    \forcsvlist{\listeadd\@accepted@arguments}{#2}
    \forcsvlist{\listeadd\@inactive@arguments}{#2}
    
    \renewcommand*{\do}[1]{
        \expandafter\@split@pair##1\relax
        \xifinlist{\@attacker}{\@accepted@arguments}{%
            \listeadd\@rejected@arguments{\@attacked}
            \listeadd\@inactive@arguments{\@attacked}
        }{}
    }
    \dolistcsloop{@attacks@\@afid}
    
    \@render@af{\@afid}{inactive}{inactive}{}{inactive}{}
}

%%% Prints an AF restricted to the given list of arguments
%   #1 unique ID of an AF
%   #2 a comma-separated list of argument IDs
\NewDocumentCommand { \afrestriction } {mm} {%
    \@prepare@af{#1}
    \forcsvlist{\listeadd\@accepted@arguments}{#2}

    \renewcommand*{\do}[1]{%
        \ifinlist{##1}{\@accepted@arguments}{}{
            \listeadd\@inactive@arguments{##1}
        }
    }
    \dolistcsloop{@arguments@\@afid}

    \@render@af{\@afid}{}{}{}{invisible}{}    
}

%%% Prepares recreation of an AF. Parses AF label to letter ID and defines lists to partition arguments
%   #1 unique ID of the AF to recreate
\NewDocumentCommand { \@prepare@af } {m} {%
    \edef\@afid{\getrefnumber{#1}}
    \def\@accepted@arguments{}
    \def\@rejected@arguments{}
    \def\@undecided@arguments{}
    \def\@inactive@arguments{}
}

%%% name of innermost af environment
\def\@afenvname{af*}

%%% Prepares recreation of AF by making sure we are inside an af environment
%   #1 unique ID of the AF to recreate
%   #2-#6 style parameters (see \@render@afdo)
\NewDocumentCommand { \@render@af } {mmmmmm} {%
    \ifx\@currenvir\@afenvname
        \@render@afdo{#1}{#2}{#3}{#4}{#5}{#6}
    \else
        \begin{af*}
        \@render@afdo{#1}{#2}{#3}{#4}{#5}{#6}
        \end{af*}
    \fi
}

%%% Recreates an AF
%%  Utilises lists defined in \@prepare@af
%   #1 unique ID of the AF to recreate
%   #2 style of accepted arguments
%   #3 style of rejected arguments
%   #4 style of undecided arguments
%   #5 style of inactive arguments/attacks
%   #6 style of normal attacks
\NewDocumentCommand { \@render@afdo } {mmmmmm} {%
    % handle arguments for rendering
    \renewcommand*{\do}[1]{%
        \ifinlist{##1}{\@accepted@arguments}{
            \csname @af@#1@arg@##1\endcsname{#2}
        }{%
            \ifinlist{##1}{\@rejected@arguments}{%
                \csname @af@#1@arg@##1\endcsname{#3}
            }{%
                \ifinlist{##1}{\@undecided@arguments}{%
                    \csname @af@#1@arg@##1\endcsname{#4}
                }{%
                    \ifinlist{##1}{\@inactive@arguments}{%
                        \csname @af@#1@arg@##1\endcsname{#5}
                    }{%
                        \csname @af@#1@arg@##1\endcsname{}
                    }
                }
            }
        }
    }
    \dolistcsloop{@arguments@#1}

    % handle attack rendering
    \renewcommand*{\do}[1]{%
        \expandafter\@split@pair##1\relax
        \xifinlist{\@attacker}{\@inactive@arguments}{%
            \csname @af@#1@att@\@attacker\@attacked\endcsname{#5,fill=none}
        }{%
            \xifinlist{\@attacked}{\@inactive@arguments}{%
                \csname @af@#1@att@\@attacker\@attacked\endcsname{#5,fill=none}
            }{%
                \csname @af@#1@att@\@attacker\@attacked\endcsname{#6}
            }
        }
    }
    \dolistcsloop{@attacks@#1}
}
\makeatother
\fi