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

%%%%%%%%%%% Package Requirements %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{amsbsy,amsmath}                 % For proper bold letters in math mode
\RequirePackage{pgfopts}                        % For managing package options
\RequirePackage{tikz}                           % For drawing the argumentation frameworks
\usetikzlibrary{positioning}                    % For relative node positioning
\usetikzlibrary{arrows.meta}                    % For directed edges / attack arrows
\usetikzlibrary{arrows}                         % For directed edges / attack arrows
\usetikzlibrary{decorations.markings}           % For creating the support edge markings
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%% Package Tikz Style Definitions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{argument}
%\newcommand{\argument}{\relax}
\newcommand{\argstyle}[1]{#1}                               % Defines the font style in which argument names are displayed

%%% Argument Style Definitions
\tikzset{ % global base styles
    argument size/.style={minimum size=0.7cm},              % Standard size of argument nodes
    argument/.style={},                                     % Base style for argument nodes
    argument standard/.style={circle,draw=black,inner sep=0,outer sep=0, argument size},
    argument large/.style={circle,draw=black,inner sep=0,outer sep=0, argument size, font=\large},
    argument thick/.style={circle,draw=black,inner sep=0,outer sep=0, argument size, thick},
}

%%% Attack/Support Edge Definitions
\tikzset{ % global base styles
    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.9mm,line width=0.7pt]}},      % Mordern rightarrow style tip
    support/.style={},
    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},
    support double/.style={-{Classical TikZ Rightarrow},double},
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

%%% Options for the style of the attack edges
\pgfkeys{/tikz/.cd,
    attackstyle/.is choice,
    attackstyle/standard/.code={\tikzset{attack/.style={attack standard}}},
    attackstyle/large/.code={\tikzset{attack/.style={attack large}}},
    attackstyle/modern/.code={\tikzset{attack/.style={attack modern}}},
    attackstyle=standard,
}
\pgfkeys{/argumentation/.cd,
    attackstyle/.is choice,
    attackstyle/standard/.code={\tikzset{attack/.style={attack standard}}},
    attackstyle/large/.code={\tikzset{attack/.style={attack large}}},
    attackstyle/modern/.code={\tikzset{attack/.style={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
\pgfkeys{/tikz/.cd,
    namestyle/.is choice,
    namestyle/none/.code={\renewcommand{\argstyle}[1]{##1}},
    namestyle/math/.code={\renewcommand{\argstyle}[1]{\ensuremath{##1}}},
    namestyle/italics/.code={\renewcommand{\argstyle}[1]{\ensuremath{\mathit{\text{##1}}}}},
    namestyle/bold/.code={\renewcommand{\argstyle}[1]{\ensuremath{\boldsymbol{\text{##1}}}}},
    namestyle/monospace/.code={\renewcommand{\argstyle}[1]{\ensuremath{\mathtt{\text{##1}}}}},
    namestyle=none,
}
\pgfkeys{/argumentation/.cd,
    namestyle/.is choice,
    namestyle/none/.code={\renewcommand{\argstyle}[1]{##1}},
    namestyle/math/.code={\renewcommand{\argstyle}[1]{\ensuremath{##1}}},
    namestyle/italics/.code={\renewcommand{\argstyle}[1]{\ensuremath{\mathit{##1}}}},
    namestyle/bold/.code={\renewcommand{\argstyle}[1]{\ensuremath{\boldsymbol{\text{##1}}}}},
    namestyle/monospace/.code={\renewcommand{\argstyle}[1]{\ensuremath{\mathtt{##1}}}},
    namestyle=none,
}

%%% Options for automatic indexing (and naming) of argument nodes
\NewDocumentCommand { \argument } {} {\relax}
\pgfkeys{/argumentation/.cd,
    indexing/.is choice,
    indexing/none/.code={
        \RenewDocumentCommand { \argument } {O{} r() m dat d()} {
            \IfNoValueTF {##5}{%
                \node[argument size,argument,##1](##2) {\argstyle{##3}};
            }{%
                \node[argument size,argument,##1](##2) at (##5) {\argstyle{##3}};
            }
        }
    },
    indexing/numeric/.code={
        \RenewDocumentCommand { \argument } {O{} d() m dat d()} {
            \stepcounter{argument}
            \IfNoValueTF {##2}{%
                \IfNoValueTF {##5}{%
                    \node[argument size,argument,##1](a\arabic{argument}) {\argstyle{##3}};
                }{%
                    \node[argument size,argument,##1](a\arabic{argument}) at (##5) {\argstyle{##3}};
                }
            }{%
                \IfNoValueTF {##5}{%
                    \node[argument size,argument,##1](##2) {\argstyle{##3}};
                }{%
                    \node[argument size,argument,##1](##2) at (##5) {\argstyle{##3}};
                }
            }
        }
    },
    indexing/alphabetic/.code={
        \RenewDocumentCommand { \argument } {O{} d() m dat d()} {
            \stepcounter{argument}
            \IfNoValueTF {##2}{%
                \IfNoValueTF {##5}{%
                    \node[argument size,argument,##1](\alph{argument}) {\argstyle{##3}};
                }{%
                    \node[argument size,argument,##1](\alph{argument}) at (##5) {\argstyle{##3}};
                }
            }{%
                \IfNoValueTF {##5}{%
                    \node[argument size,argument,##1](##2) {\argstyle{##3}};
                }{%
                    \node[argument size,argument,##1](##2) at (##5) {\argstyle{##3}};
                }
            }
        }
    },
    indexing/.default=numeric,
    indexing=numeric,
}

\ProcessPgfPackageOptions{/argumentation}

%%%%%%%%%%%%%%%  AF Environment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Additional AF Style Parameters
\tikzset{ % global predefined tikz-styles
    selfattack/.style={loop,min distance=2mm,in=0,out=60,looseness=5},      % Standard style for self-attacks
    inactive/.style={draw=black!30,text=black!40},                          % Make a node or edge inactive, i.e., greyed out
    incomplete/.style={densely dashed},                                     % Style for displaying incomplete nodes or attacks
    accepted/.style={fill=green},                                              % Color an argument that is labelled in
    rejected/.style={fill=red},                                               % Color an argument that is labelled out
    undecided/.style={fill=cyan},                                            % Color an argument that is labelled undecided
    caption/.style={draw=none},                                             % Style for displaying AF name in Figure
    invisible/.style={draw=none,text=black!0},                              % Make a node or edge invisible
    annotation/.style={font=\small},                                  % text annotation style
    argin/.style={accepted},
    argout/.style={rejected},
    argundec/.style={undecided},
}

%%% Options for af environment
\pgfkeys{/tikz/.cd,
    small/.style = {node distance=0.55cm,argument size/.style={minimum size=0.55cm},caption/.append style={font=\small}},
    tiny/.style = {node distance=0.35cm,argument size/.style={minimum size=0.4cm,font=\small},caption/.append style={font=\small}},
}

%%% Initializing the af environment
\newcounter{af}
\newenvironment{af}[1][]{
    \refstepcounter{af}
    \setcounter{argument}{0}
    \pgfkeys{/argumentation/.cd, #1}
    \tikzpicture[#1]
}{%
    \endtikzpicture
}

%%%%%%%%%%%%%%%% Commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 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};
    }
    
}

\newcommand{\annotation}[3][]{\node[annotation,above of=#2,#1](an_#2){#3};}

% Creates an attack edge
\newcommand{\attack}[3][]{\path(#2) edge [attack,#1] (#3);}

% Creates a self-attack
\newcommand{\selfattack}[2][]{\path(#2) edge [attack,selfattack,#1] (#2);}

% Creates two symmetric attack edges between two arguments
\newcommand{\dualattack}[3][]{\path(#2) edge [attack, bend right,#1] (#3);\path(#3) edge [attack, bend right,#1] (#2);}

% Creates a weighted attack
\newcommand{\annotatedattack}[4][]{\path(#2) edge [attack,#1] node[annotation](p_#2_#3){#4} (#3);}

% Creates a support edge between two arguments
\newcommand{\support}[3][]{\path(#2) edge [support=0.35,#1] (#3);}

%%% Commands for setting custom tikz-style parameters
\newcommand{\setargumentstyle}[1]{\tikzset{argument/.style={#1}}}
\newcommand{\setattackstyle}[1]{\tikzset{attack/.style={#1}}}
\newcommand{\setsupportstyle}[1]{\tikzset{support/.style={#1}}}
\newcommand{\setannotationstyle}[1]{\tikzset{annotation/.style={#1}}}

%\newcommand{\setloopstyle}[1]{\tikzset{selfattack/.style={#1}}}
%\newcommand{\adjustargumentstyle}[1]{\tikzset{argument/.append style={#1}}}
%\newcommand{\adjustattackstyle}[1]{\tikzset{attack/.append style={#1}}}