summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/decision-table/decision-table-doc.tex
blob: 266e88acbf507b0504f5341172060b3390157dac (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
\documentclass{article}
\usepackage{decision-table}
\usepackage{hyperref}
\usepackage{listings}
\usepackage{float}

\author{Simon Vandevelde}

\title{The \texttt{decision-table} Package}
\date{2020/08/22}

\begin{document}

\maketitle

\section{Description}

The \texttt{decision-table} package allows for an easy way to generate decision tables in the Decision Model and Notation (DMN) format. (See Fig. \ref{ex1})
This package ensures consistency in the tables (i.e. fontsize), and is thus a better alternative to inserting tables via images.

\begin{figure}[H]
    \centering
    \dmntable{Calculate BMI}{U}{Weight(kgs),Length(m)}{BMI}{
              ---,---,weight/length*length}
    \caption{Example of a DMN table}
    \label{ex1}
\end{figure}
\section{How to use}

The \texttt{decision-table} package adds the \texttt{dmntable} command, with which tables can be created.
This command expands into a \texttt{tabular}, so it can be used within a \texttt{table} or \texttt{figure} environment.
Furthermore, this allows labels and captions to be added seamlessly. 
It is also possible to place multiple DMN tables in one \texttt{table}/\texttt{figure} environment.

The \texttt{dmntable} command has the following inputs:
\begin{itemize}
    \item title
    \item hit policy
    \item input column headers
    \item output column headers
    \item the table values
\end{itemize}
The command is used as follows:
\begin{lstlisting}[language=tex, frame=single]
\dmntable{title}{hitpolicy}{input}{output}{values}
\end{lstlisting}

The input, output and cell values are split by a comma.
It is not necessary to include the row numbers for the cell values.
For example, \ref{ex1} is generated by the following code:
\begin{lstlisting}[language=tex, frame=single, basicstyle=\small]
\begin{figure}[H]
    \centering
    \dmntable{Calculate BMI}{U}             % Title and HP
             {Weight(kgs),Length(m)}{BMI}   % Input, output
             {---,---,weight/length*length} % Cell values
    \caption{Example of a DMN table}
    \label{ex1}
\end{figure}
\end{lstlisting}

If a cell value contains multiple values (e.g. multiple string values), then accolades should be written around them.
See the example \ref{ex2}.


\section{Examples}
This section contains some example code and their resulting tables.

\begin{lstlisting}[language=tex, frame=single, basicstyle=\small]
\begin{figure}[H]
    \centering
    \dmntable{Calculate BMI}{U}             % Title and HP
             {Weight(kgs),Length(m)}{BMI}   % Input, output
             {---,---,weight/length*length} % Cell values
    \caption{Example of a DMN table}
\end{figure}
\end{lstlisting}
\begin{figure}[H]
    \centering
    \dmntable{Calculate BMI}{U}             % Title and HP
             {Weight(kgs),Length(m)}{BMI}   % Input, output
             {---,---,weight/length*length} % Cell values
    \caption{Example of a DMN table}
\end{figure}


\begin{lstlisting}[language=tex, frame=single, basicstyle=\small]
\begin{ligure}[H]
    \centering
    \dmntable{Decide BMI Level}{U}              % Title and HP
             {BMI}{BMI Level, Risk Level}       % Input, output
             {$< 18.5$, Underweight, Increased,
              $[18.5..24.9]$, Normal, Low,
              $[25..29.9]$, overweight, Increased,
              $[30..34.9]$, Obese I, High,
              $[35..39.9]$, Obese II, Very High,
              $> 39.9$, Extreme Obesity, Extremely High}
    \caption{Example of a DMN table}
\end{figure}
\end{lstlisting}
\begin{figure}[H]
    \centering
    \dmntable{Decide BMI Level}{U}              % Title, HP
             {BMI}{BMI Level, Risk Level}       % Input, output
             {$< 18.5$, Underweight, Increased,
              $[18.5..24.9]$, Normal, Low,
              $[25..29.9]$, overweight, Increased,
              $[30..34.9]$, Obese I, High,
              $[35..39.9]$, Obese II, Very High,
              $> 39.9$, Extreme Obesity, Extremely High}
    \caption{Example of a larger DMN table}
\end{figure}

\begin{lstlisting}[language=tex, frame=single, basicstyle=\tiny]
\begin{figure}[H]
    \centering
    \dmntable{Decide Risk Level}{U}
             {BMI level, Waist(cm)}{Risk Level}
             {Overweight, $<=88$, Increased,
              Overweight, $ > 88$, High,
              Obese I,$ <= 88$, High,
              Obese II, ---, Very High,
              Extreme Obesity, ---, Extremely High,
              {not(Overweight, Obese I, Obese II, Extreme Obesity)}, ---, Low
             }
    \caption{Example of cell with multiple values}
    \label{ex2}
\end{figure}
\end{lstlisting}

\begin{figure}[H]
    \centering
    \dmntable{Decide Risk Level}{U}
             {BMI level, Waist(cm)}{Risk Level}
             {Overweight, $<=88$, Increased,
              Overweight, $ > 88$, High,
              Obese I,$ <= 88$, High,
              Obese II, ---, Very High,
              Extreme Obesity, ---, Extremely High,
              {not(Overweight, Obese I, Obese II, Extreme Obesity)}, ---, Low
             }
    \caption{Example of cell with multiple values}
    \label{ex2}
\end{figure}

\begin{lstlisting}[language=tex, frame=single, basicstyle=\tiny]
\begin{figure}[H]
    \centering
    \dmntable{Rule 1}{U}
             {Age, Service Years}{Eligible1}
             {$\leq18$, ---, Yes,
              $\geq60$, ---, Yes,
              {$[18, 60]$}, $\geq 30$, Yes
             }
    \dmntable{Rule 2}{U}
             {Age, Service Years}{Eligible2}
             {---,$\geq30$, Yes,
              $\geq60$,$<30$, Yes
             }
    \dmntable{Rule 3}{U}
             {Age, Service Years}{Eligible3}
             {$< 45$, {$[15, 30)$}, Yes,
              $> 45$, ---, Yes
             }
    \dmntable{Vacation days}{C+}
             {Eligible1, Eligible2, Eligble3}{Vacation Days}
             {---, ---, ---, 22,
              Yes, ---, ---, 5,
              ---, Yes, ---, 3,
              No, ---, Yes, 2
             }
    \caption{dmn table example for the Vacation Days}
\end{figure}
\end{lstlisting}
\begin{figure}[H]
    \centering
    \dmntable{Rule 1}{U}
             {Age, Service Years}{Eligible1}
             {$\leq18$, ---, Yes,
              $\geq60$, ---, Yes,
              {$[18, 60]$}, $\geq 30$, Yes
             }
    \dmntable{Rule 2}{U}
             {Age, Service Years}{Eligible2}
             {---,$\geq30$, Yes,
              $\geq60$,$<30$, Yes
             }
    \dmntable{Rule 3}{U}
             {Age, Service Years}{Eligible3}
             {$< 45$, {$[15, 30)$}, Yes,
              $> 45$, ---, Yes
             }
    \dmntable{Vacation days}{C+}
             {Eligible1, Eligible2, Eligble3}{Vacation Days}
             {---, ---, ---, 22,
              Yes, ---, ---, 5,
              ---, Yes, ---, 3,
              No, ---, Yes, 2
             }
    \caption{DMN table example for the Vacation Days}
\end{figure}


\section{Contributing}

Contributions are always welcome.
The project is hosted at \url{https://gitlab.com/Vadevesi/dmn-tex}

\end{document}