Debian Codegraph @

texmf-dist/source/latex/decision-table/decision-table.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2020-2021 by S. Vandevelde, F. Pantigny
4 % ------------------------------------------------
5 %
6 % This file may be distributed and/or modified under the
7 % conditions of the LaTeX Project Public License, either version 1.3
8 % of this license or (at your option) any later version.
9 % The latest version of this license is in:
10 %
11 % http://www.latex-project.org/lppl.txt
12 %
13 % and version 1.3c or later is part of all distributions of LaTeX
14 % version 2005/12/01 or later.
15 %
16 % \fi
17 % \iffalse
18 %
19 \def\dmnfileversion{0.0.4}
20 \def\dmnfiledate{2021/10/01}
21 %
22 %<*batchfile>
23 \begingroup
24 \input l3docstrip.tex
25 \keepsilent
26 \usedir{tex/latex/cascade}
27 \preamble
28
29 Copyright (C) 2020-2021 by S.Vandevelde, F. Pantigny
30 -----------------------------------
31
32 This file may be distributed and/or modified under the
33 conditions of the LaTeX Project Public License, either version 1.3
34 of this license or (at your option) any later version.
35 The latest version of this license is in:
36
37 http://www.latex-project.org/lppl.txt
38
39 and version 1.3c or later is part of all distributions of LaTeX
40 version 2005/12/01 or later.
41
42 \endpreamble
43 \askforoverwritefalse
44 \endgroup
45 %</batchfile>
46 %
47 %<@@=cascade>
48 %<*driver>
49 \documentclass[dvipsnames]{l3doc}% option dvipsnames is for xcolor (loaded by tikz)
50 \usepackage{xltxtra}
51 \usepackage{geometry}
52 \geometry{left=2.8cm,right=2.8cm,top=2.5cm,bottom=2.5cm,papersize={21cm,29.7cm}}
53 \setlength{\fboxsep}{0pt}
54 \usepackage{tikz}
55 \usepackage{hyperref}
56 \usepackage{listings}
57 \usepackage{float}
58 \usetikzlibrary{calc}
59 \usepackage{decision-table}
60 \hfuzz=5cm
61 \def\interitem{\vskip 7mm plus 2 mm minus 3mm}
62 \def\emphase{\bgroup\color{RoyalPurple}\let\next=}
63 \fvset{commandchars=\~\#\@,formatcom={\color{gray}}}
64 \parindent 0pt
65 \skip\footins = 2\bigskipamount
66
67
68
69 \begin{document}
70 \DocInput{decision-table.dtx}
71 \end{document}
72 %</driver>
73 % \fi
74 % \title{The package \pkg{decision-table}\thanks{This document corresponds to the
75 % version~\dmnfileversion\space of \pkg{decision-table}, at the date of~\dmnfiledate.}}
76 % \author{S. Vandevelde, F. Pantigny \\ \texttt{[email protected]} \\ \texttt{[email protected]}}
77 %
78 % \maketitle
79 %
80 % \begin{abstract}
81 % The LaTeX package \pkg{decision-table} provides a command |\dmntable|, which allows for an easy way to generate decision tables in the Decision Model and Notation (DMN) format. (See Fig.~\ref{ex1})
82 % This package ensures consistency in the tables (i.e. fontsize), and is thus a better alternative to inserting tables via images.
83 % Besides pure DMN tables, it also supports the tables used in the cDMN and pDMN extensions, namely glossary and probability tables.
84 % \end{abstract}
85 %
86 %
87 %
88 % \vspace{1cm}
89 % \section{Description}
90 %
91 % The \texttt{decision-table} package allows for easy and straightforward generation of decision tables (with or without input columns) in the Decision Model and Notation (DMN) format, as demonstrated in Fig.~\ref{ex1}.
92 % Additionally, it also supports glossary and goal tables as defined by cDMN\footnote{https://cdmn.be}, and probability tables as defined by pDMN\footnote{Vandevelde S., et al., ``A Table-Based Representation for Probabilistic Logic: Preliminary Result''.}.
93 % Usage of this package ensures consistency in tables (i.e. font type, font size, color, $\ldots$), and is thus a better alternative to inserting tables via images.
94 %
95 % \begin{figure}[H]
96 % \centering
97 % \dmntable{BMI Level}{U}{BMI}{BMILevel}
98 % {$< 18.5$, Underweight,
99 % $[18.5..25]$, Normal,
100 % $(25..30]$, Overweight,
101 % $> 30$, Obese}
102 % \caption{Example of a DMN table}
103 % \label{ex1}
104 % \end{figure}
105 % \section{Usage}
106 %
107 % In total, the \texttt{decision-table} package adds 5 new commands.
108 % \begin{itemize}
109 % \item \texttt{dmntable}: basic DMN table.
110 % \item \texttt{dmnoutputtable}: basic DMN table, but without input columns.
111 % \item \texttt{dmnglossarytable}: glossary table, as defined by cDMN.
112 % \item \texttt{goaltable}: goal table, as defined by cDMN.
113 % \item \texttt{pdmntable}: probability table, as defined by pDMN.
114 % \item \texttt{pdmnoutputtable}: probability table, but without input columns.
115 % \end{itemize}
116
117 % \subsection{dmntable}
118 % The \texttt{dmntable} command generates standard DMN decision tables.
119 % This command expands into a \texttt{tabular}, so it can be used within a \texttt{table} or \texttt{figure} environment.
120 % Furthermore, this allows labels and captions to be added seamlessly, and allows placing multiple DMN tables in the same environment.
121 % These tables will automatically arrange themselves based on size.
122 %
123 % The \texttt{dmntable} command has the following inputs:
124 % \begin{itemize}
125 % \item title
126 % \item hit policy
127 % \item input column headers
128 % \item output column headers
129 % \item the table values
130 % \end{itemize}
131 % The command is used as follows:
132 % \iffalse
133 %<*example>
134 % \fi
135 \begin{lstlisting}[language=tex, frame=single]
136 \dmntable{title}{hitpolicy}{input}{output}{values}
137 \end{lstlisting}
138 % \iffalse
139 %</example>
140 % \fi
141 %
142 % The input, output and cell values are split by a comma.
143 % It is not necessary to include the row numbers for the cell values.
144 % For example, Fig.~\ref{ex1} is generated by the following code:
145
146 % \iffalse
147 %<*example>
148 % \fi
149 \begin{lstlisting}[language=tex, frame=single, basicstyle=\small]
150 \begin{figure}[H]
151 \centering
152 \dmntable{BMI Level}{U}{BMI}{BMILevel}
153 {$< 18.5$, Underweight,
154 $[18.5..25]$, Normal,
155 $(25..30]$, Overweight,
156 $> 30$, Obese}
157 \caption{Example of a DMN table}
158 \label{ex1}
159 \end{figure}
160 \end{lstlisting}
161 % \iffalse
162 %</example>
163 % \fi
164 %
165 % If a cell value contains multiple values (e.g. multiple string values), then accolades should be written around them.
166 % See the example shown in Fig.~\ref{ex2}.
167
168 % It is also possible to have cells be multiline using the \texttt{makecell} package. This is useful in cases where large text causes page overflow.
169 % \iffalse
170 %<*example>
171 % \fi
172 \begin{lstlisting}[language=tex, frame=single, basicstyle=\small]
173 \include{makecell} % This should be somewhere at the top of document
174 \begin{figure}[H]
175 \centering
176 \dmntable{BMI Level}{U}{BMI}{\makecell{BMI \\ Level}}
177 {$< 18.5$, Underweight,
178 $[18.5..25]$, Normal,
179 $(25..30]$, Overweight,
180 $> 30$, Obese}
181 \caption{Example of a DMN table with multiline cell}
182 \label{ex1}
183 \end{figure}
184 \end{lstlisting}
185 % \iffalse
186 %</example>
187 % \fi
188 %
189 % \subsection{dmnoutputtable}
190 % Decision tables that have no input columns can be created using the \texttt{dmnoutputtable} command.
191 % Its usage is the same as the standard decision table, except that no input columns should be given.
192 % For example, the following code generates the table shown in Fig.~\ref{outputtable}.
193 % \iffalse
194 %<*example>
195 % \fi
196 \begin{lstlisting}[language=tex, frame=single, basicstyle=\small]
197 \begin{figure}[H]
198 \centering
199 \dmnoutputtable{BMI Level}{U}{BMI}{5}
200 \caption{Example of a DMN output table}
201 \label{ex1}
202 \end{figure}
203 \end{lstlisting}
204 % \iffalse
205 %</example>
206 % \fi
207 % \begin{figure}[H]
208 % \centering
209 % \dmnoutputtable{BMI Level}{U}{BMI}{5}
210 % \caption{Example of a DMN output table}
211 % \label{outputtable}
212 % \end{figure}
213 %
214 % \subsection{dmnglossarytable}
215 % Glossary tables are added by using the \texttt{glossarytable} command.
216 % This command accepts three inputs: the title, the sub-titles of the columns, and the actual elements.
217 % See Fig. \ref{glos1} for an example.
218 % \iffalse
219 %<*example>
220 % \fi
221 \begin{lstlisting}[language=tex, frame=single, basicstyle=\small]
222 \begin{figure}[H]
223 \centering
224 \glossarytable{Type}{Name, DataType, Possible Values}
225 {Country, String, {Belgium, France, Germany}}
226 \glossarytable{Function}{Name, DataType}{color of Country, Color}
227 \glossarytable{Relation}{Name}{Country borders Country}
228 \caption{Example glossary}
229 \label{glos1}
230 \end{figure}
231 \end{lstlisting}
232 % \iffalse
233 %</example>
234 % \fi
235 %
236 %
237 % \begin{figure}[H]
238 % \centering
239 % \glossarytable{Type}{Name, DataType, Possible Values}
240 % {Country, String, {Belgium, France, Germany}}
241 % \glossarytable{Function}{Name, DataType}{color of Country, Color}
242 % \glossarytable{Relation}{Name}{Country borders Country}
243 % \caption{Example glossary}
244 % \label{glos1}
245 % \end{figure}
246
247 % \subsection{goaltable}
248
249 % Generating a \texttt{Goal} table is straightforward:
250
251 % \iffalse
252 %<*example>
253 % \fi
254 \begin{lstlisting}[language=tex, frame=single]
255 \goaltable{tablename}{values}
256 \end{lstlisting}
257 % \iffalse
258 %</example>
259 % \fi
260
261 % \begin{figure}[H]
262 % \centering
263 % \goaltable{tablename}{value1, value2}
264 % \end{figure}
265
266 % \subsection{pdmntable}
267
268 % pDMN probability tables are similar to standard DMN tables, but with a few changes.
269 % The biggest change is the addition of probabilities. The syntax of \texttt{pdmntable} is as follows:
270
271 % \iffalse
272 %<*example>
273 % \fi
274 \begin{lstlisting}[language=tex, frame=single]
275 \pdmntable{title}{hitpolicy}{inputs}{outputs}{output values}{cell values}
276 \end{lstlisting}
277 % \iffalse
278 %</example>
279 % \fi
280
281 %For example, a table expressing the probabilities of an unbiased and biased dice throw can be expressed as follows:
282
283 % \iffalse
284 %<*example>
285 % \fi
286 \begin{lstlisting}[language=tex, frame=single]
287 \pdmntable{Throwing Dice}{Ch}{biased}{die value}
288 {one, two, three, four, five, six}
289 {No, $1/6$, $1/6$, $1/6$, $1/6$, $1/6$, $1/6$,
290 Yes, $0.1$, $0.1$, $0.1$, $0.1$, $0.1$, $0.5$}
291 \end{lstlisting}
292 % \iffalse
293 %</example>
294 % \fi
295
296 % \begin{figure}[H]
297 % \centering
298 % \pdmntable{Throwing Dice}{Ch}{biased}{die value}
299 % {one, two, three, four, five, six}
300 % {No, $1/6$, $1/6$, $1/6$, $1/6$, $1/6$, $1/6$,
301 % Yes, $0.1$, $0.1$, $0.1$, $0.1$, $0.1$, $0.5$}
302 % \end{figure}
303
304
305 % \subsection{pdmnoutputtable}
306 % The final type of table, \texttt{pdmnoutputtable}, is the same as the one shown in the previous subsection but without any input columns.
307
308 % \iffalse
309 %<*example>
310 % \fi
311 \begin{lstlisting}[language=tex, frame=single]
312 \pdmnoutputtable{tablename}{hitpolicy}{output}{outputvalue}{probabilities}
313 \end{lstlisting}
314 % \iffalse
315 %</example>
316 % \fi
317
318 % \begin{figure}[H]
319 % \centering
320 % \pdmnoutputtable{h1}{U}{heads1}{Yes}{0.5}
321 % \end{figure}
322
323 % \section{Contributing}
324 %
325 % Contributions are always welcome.
326 % The project is hosted at \url{https://gitlab.com/Vadevesi/dmn-tex}
327
328 %
329 % \newgeometry{left=4cm}
330 %
331 % \section{Implementation}
332 %
333 %<@@=dmn>
334 %
335 % \bigskip
336 %
337 %
338 % We give the traditional declaration of a package written with |expl3|:
339 % \begin{macrocode}
340 \RequirePackage{l3keys2e}
341 \ProvidesExplPackage
342 {decision-table}
343 {\dmnfiledate}
344 {\dmnfileversion}
345 {Table of decision}
346 % \end{macrocode}
347 %
348 % \begin{macrocode}
349 \RequirePackage { nicematrix }
350 % \end{macrocode}
351 %
352 % \bigskip
353 % We define the command |\dmntable| with the tools of \pkg{xparse}.
354 % \begin{macrocode}
355 \NewDocumentCommand \dmntable { m m m m m }
356 {
357 % \end{macrocode}
358 % The clist (\emph{comma separated list}) |\l_@@_input_clist| is for the list
359 % of the names of the input fields.
360 % \begin{macrocode}
361 \clist_clear_new:N \l_@@_input_clist
362 \clist_set:Nn \l_@@_input_clist { #3 }
363 % \end{macrocode}
364 %
365 % \bigskip
366 % The clist |\l_@@_output_clist| is for the list of the names of the output fields.
367 % \begin{macrocode}
368 \clist_clear_new:N \l_@@_output_clist
369 \clist_set:Nn \l_@@_output_clist { #4 }
370 % \end{macrocode}
371 %
372 % \bigskip
373 % The integer |\l_@@_input_int| is the number of the input fields.
374 % \begin{macrocode}
375 \int_zero_new:N \l_@@_input_int
376 \int_set:Nn \l_@@_input_int { \clist_count:N \l_@@_input_clist }
377 % \end{macrocode}
378 %
379 % \bigskip
380 % The integer |\l_@@_output_int| is the number of the output fields.
381 % \begin{macrocode}
382 \int_zero_new:N \l_@@_output_int
383 \int_set:Nn \l_@@_output_int { \clist_count:N \l_@@_output_clist }
384 % \end{macrocode}
385 %
386 %
387 % \bigskip
388 % The sequence |\l_@@_cells_seq| is the sequence of all the cells of the
389 % ``body'' of the tabular.
390 % \begin{macrocode}
391 \seq_clear_new:N \l_@@_cells_seq
392 \seq_set_split:Nnn \l_@@_cells_seq { , } { #5 }
393 % \end{macrocode}
394 %
395 %
396 % \vspace{1cm}
397 % Now, we will begin the construction of the tabular (a |{NiceTabular}| of
398 % \pkg{nicematrix}).
399 %
400 % \bigskip
401 % The command |\use:x| will expand its argument. Indeed, the preamble of the
402 % |{NiceTabular}| (which has the same format as a preamble of |{tabular}| must
403 % be computed before the execution of the |\begin{NiceTabular}|.
404 % \begin{macrocode}
405 \use:x
406 {
407 \exp_not:N \begin { NiceTabular }
408 % \end{macrocode}
409 % Here is the preamble of the tabular. The command |\prg_replicate:nn| is
410 % expandable and hence will be expanded by the |use:x|.
411 % \begin{macrocode}
412 { r \prg_replicate:nn { \l_@@_input_int + \l_@@_output_int } l }
413 % \end{macrocode}
414 % Here is the list of options of the |{NiceTabular}| (a standard tabular of
415 % |{array}| don't have such list of options. Once again, we have to compute some
416 % quantities in this list of options before the execution of |\begin{NiceTabular}|.
417 % \begin{macrocode}
418 [
419 % \end{macrocode}
420 % The key |hvlines-except-corners| will draw all the rules of the tabular,
421 % excepted in the (upper right) corner.
422 % \begin{macrocode}
423 hvlines-except-corners ,
424 % \end{macrocode}
425 % The key |code-before| of |{NiceTabular}| contains instructions to color the
426 % cells \emph{before} the rules (doing so, the resulting \textsc{pdf} gives
427 % better results in the \textsc{pdf} viewers).
428 % \begin{macrocode}
429 code-before =
430 % \end{macrocode}
431 % First, a |\rectanglecolor| for the labels of the ``input'' fields. The command
432 % |\int_eval:n| is expandable and, hence, will be expanded by the |\use:x|. On
433 % the other side, we have to prevent the expansion of |\rectanglecolor| which,
434 % in fact, at that point is not defined (it will be defined by \pkg{nicematrix}
435 % after the construction of the array).
436 % \begin{macrocode}
437 \exp_not:N \rectanglecolor
438 { blue!10!green!60!black!30 }
439 { 2 - 2 }
440 { 2 - \int_eval:n { \l_@@_input_int + 1 } }
441 % \end{macrocode}
442 % A |\rectanglecolor| for the labels of the ``output'' fields.
443 % \begin{macrocode}
444 \exp_not:N \rectanglecolor
445 { green!30!blue!15 }
446 { 2 - \int_eval:n { \l_@@_input_int + 2 } }
447 { 2 - \int_eval:n { \l_@@_input_int + \l_@@_output_int + 1 } }
448 ]
449 }
450 % \end{macrocode}
451 % Now, we begin the body of the tabular (the environment |{NiceTabular}|).
452 %
453 % \medskip
454 % The body begins by a |\multicolumn| for the title. However, we have to compute
455 % the number of cells of that |\multicolumn|. That's why we have to expand the
456 % first argument of the |\multicolumn| before executing the |\multicolumn|.
457 % However, we have to do that in an expandable way in order to prevent the
458 % functionnality of the |\multicolumn| (which internally give a |\omit| of TeX).
459 % That's why we have to use |\exp_args:Ne| (|\exp_args:Nx| would not do the job).
460 % \begin{macrocode}
461 \exp_args:Ne \multicolumn
462 { \int_eval:n { \l_@@_input_int + 1 } }
463 { l }
464 { #1 } \\
465 % \end{macrocode}
466 % |#2| is the \emph{hit policy}.
467 % \begin{macrocode}
468 #2 &
469 % \end{macrocode}
470 % Now, the fields (``input fields'' and ``output fields''). By using
471 % |\clist_use:Nn|, we replace the commas by ampersands (|&|).
472 % \begin{macrocode}
473 \clist_use:Nn \l_@@_input_clist { & } &
474 \clist_use:Nn \l_@@_output_clist { & } \\
475 % \end{macrocode}
476 % Now, all the rows corresponding to the rules. We begin a loop over all the
477 % cells with |\seq_map_inline:Nn|.
478 % \begin{macrocode}
479 1 &
480 \seq_map_inline:Nn \l_@@_cells_seq
481 {
482 % \end{macrocode}
483 % |\c@jCol| and |\c@iRow| are counters provided by |{NiceTabular}| for the
484 % current column and the current row. If you are in the first column, we insert
485 % the number of rule.
486 % \begin{macrocode}
487 \int_compare:nT { \c@jCol = 0 } { \int_eval:n { \c@iRow - 1 } & }
488 % \end{macrocode}
489 % Now, we add one composante of |\l_@@_cells_seq|.
490 % \begin{macrocode}
491 ##1
492 % \end{macrocode}
493 % Before the following cell, we have, of course, to add |\\| (if we are at the
494 % end of the row) or |&| (elsewhere).
495 % \begin{macrocode}
496 \int_compare:nTF { \c@jCol = \l_@@_input_int + \l_@@_output_int + 1 }
497 { \\ }
498 { & }
499 }
500 \end { NiceTabular }
501 }
502 % \end{macrocode}
503 % The other two commands are simply more of the same.
504 % \begin{macrocode}
505 \NewDocumentCommand \dmnoutputtable { m m m m }
506 {
507 \clist_clear_new:N \l__dmn_output_clist
508 \clist_set:Nn \l__dmn_output_clist { #3 }
509 \int_zero_new:N \l__dmn_output_int
510 \int_set:Nn \l__dmn_output_int { \clist_count:N \l__dmn_output_clist }
511 \seq_clear_new:N \l__dmn_cells_seq
512 \seq_set_split:Nnn \l__dmn_cells_seq { , } { #4 }
513 \use:x
514 {
515 \exp_not:N \begin { NiceTabular }
516 { r \prg_replicate:nn { \l__dmn_output_int } l }
517 [
518 hvlines-except-corners ,
519 code-before =
520 \exp_not:N \rectanglecolor
521 { blue!10!green!60!black!30 }
522 { 2 - 2 }
523 { 2 - \int_eval:n { 1 } }
524 \exp_not:N \rectanglecolor
525 { green!30!blue!15 }
526 { 2 - \int_eval:n { 2 } }
527 { 2 - \int_eval:n { \l__dmn_output_int + 1 } }
528 ]
529 }
530 \exp_args:Ne \multicolumn
531 { \int_eval:n { 1 } }
532 { l }
533 { #1 } \\
534 #2 &
535 \clist_use:Nn \l__dmn_output_clist { & } \\
536 1 &
537 \seq_map_inline:Nn \l__dmn_cells_seq
538 {
539 \int_compare:nT { \c@jCol = 0 } { \int_eval:n { \c@iRow - 1 } & }
540 ##1
541 \int_compare:nTF { \c@jCol = \l__dmn_output_int + 1 }
542 { \\ }
543 { & }
544 }
545 \end { NiceTabular }
546 }
547
548 \NewDocumentCommand \glossarytable { m m m }
549 {
550 \clist_clear_new:N \l__clist
551 \clist_set:Nn \l__clist { #2 }
552 \int_zero_new:N \l__cint
553 \int_set:Nn \l__cint { \clist_count:N \l__clist }
554 \seq_clear_new:N \l__dmn_cells_seq
555 \seq_set_split:Nnn \l__dmn_cells_seq { , } { #3 }
556 \use:x
557 {
558 \exp_not:N \begin { NiceTabular }
559 { c \prg_replicate:nn { \l__cint -1 } c }
560 [
561 hvlines-except-corners ,
562 code-before =
563 \exp_not:N \rectanglecolor
564 { blue!30!green!10!red!40 }
565 { 1 - \int_eval:n { 1 } }
566 { 1 - \int_eval:n { \l__cint} }
567 ]
568 }
569 \exp_args:Ne \multicolumn
570 { \int_eval:n { \l__cint } }
571 { c }
572 { \textbf{#1} } \\
573 \bf \clist_use:Nn \l__clist { & \bf } \\
574 \seq_map_inline:Nn \l__dmn_cells_seq
575 {
576 \int_compare:nT { \c@jCol = 0 } { }
577 ##1
578 \int_compare:nTF { \c@jCol = \l__cint }
579 { \\ }
580 { & }
581 }
582 \end { NiceTabular }
583 }
584 \NewDocumentCommand \pdmntable { m m m m m m}
585 {
586 \clist_clear_new:N \l__dmn_input_clist
587 \clist_set:Nn \l__dmn_input_clist { #3 }
588 \clist_clear_new:N \l__dmn_output_clist
589 \clist_set:Nn \l__dmn_output_clist { #4 }
590 \clist_clear_new:N \l__suboutput_clist
591 \clist_set:Nn \l__dmn_suboutput_clist { #5 }
592 \int_zero_new:N \l__dmn_input_int
593 \int_set:Nn \l__dmn_input_int { \clist_count:N \l__dmn_input_clist }
594 \int_zero_new:N \l__dmn_output_int
595 \int_set:Nn \l__dmn_output_int { \clist_count:N \l__dmn_output_clist }
596 \int_zero_new:N \l__dmn_suboutput_int
597 \int_set:Nn \l__dmn_suboutput_int { \clist_count:N \l__dmn_suboutput_clist }
598 \seq_clear_new:N \l__dmn_cells_seq
599 \seq_set_split:Nnn \l__dmn_cells_seq { , } { #6 }
600 \seq_clear_new:N \l__dmn_inputcells_seq
601 \seq_set_split:Nnn \l__dmn_inputcells_seq { , } { #3 }
602 \use:x
603 {
604 \exp_not:N \begin { NiceTabular }
605 { r \prg_replicate:nn { \l__dmn_input_int + \l__dmn_suboutput_int + 1} l }
606 [
607 hvlines-except-corners ,
608 code-before =
609 \exp_not:N \rectanglecolor
610 { blue!10!green!60!black!30 }
611 { 2 - 2 }
612 { 2 - \int_eval:n { \l__dmn_input_int + 1 } }
613 \exp_not:N \rectanglecolor
614 { green!30!blue!15 }
615 { 2 - \int_eval:n { \l__dmn_input_int + 2 } }
616 { 2 - \int_eval:n { \l__dmn_input_int + \l__dmn_suboutput_int + 1 } }
617 \exp_not:N \rectanglecolor
618 { red!60!green!60!blue!15}
619 { 3 - \int_eval:n { 1 } }
620 { 3 - \int_eval:n { \l__dmn_input_int + \l__dmn_suboutput_int + 1 } }
621 ]
622 }
623 \exp_args:Ne \multicolumn
624 { \int_eval:n { \l__dmn_input_int + 1 } }
625 { l }
626 { #1 } \\
627 #2 &
628 \clist_use:Nn \l__dmn_input_clist { & } &
629 \exp_args:Ne \multicolumn
630 { \int_eval:n {\l__dmn_suboutput_int}}
631 { c }
632 { #4 } \\
633 \seq_map_inline:Nn \l__dmn_inputcells_seq
634 { & }
635 & \clist_use:Nn \l__dmn_suboutput_clist { & } & \\
636 %\clist_use:Nn \l__dmn_output_clist { & } \\
637 1 &
638 \seq_map_inline:Nn \l__dmn_cells_seq
639 {
640 \int_compare:nT { \c@jCol = 0 } { \int_eval:n { \c@iRow - 2 } & }
641 ##1
642 \int_compare:nTF { \c@jCol = \l__dmn_input_int + \l__dmn_suboutput_int + 1 }
643 { \\ }
644 { & }
645 }
646 \end { NiceTabular }
647 }
648 \NewDocumentCommand \pdmnoutputtable { m m m m m }
649 {
650 \clist_clear_new:N \l__dmn_output_clist
651 \clist_set:Nn \l__dmn_output_clist { #3 }
652 \clist_clear_new:N \l__suboutput_clist
653 \clist_set:Nn \l__dmn_suboutput_clist { #4 }
654 \int_zero_new:N \l__dmn_output_int
655 \int_set:Nn \l__dmn_output_int { \clist_count:N \l__dmn_output_clist }
656 \int_zero_new:N \l__dmn_suboutput_int
657 \int_set:Nn \l__dmn_suboutput_int { \clist_count:N \l__dmn_suboutput_clist }
658 \seq_clear_new:N \l__dmn_cells_seq
659 \seq_set_split:Nnn \l__dmn_cells_seq { , } { #5 }
660 \use:x
661 {
662 \exp_not:N \begin { NiceTabular }
663 { r \prg_replicate:nn { \l__dmn_suboutput_int } l }
664 [
665 hvlines-except-corners ,
666 code-before =
667 \exp_not:N \rectanglecolor
668 { blue!10!green!60!black!30 }
669 { 2 - 2 }
670 { 2 - \int_eval:n { 1 } }
671 \exp_not:N \rectanglecolor
672 { green!30!blue!15 }
673 { 2 - \int_eval:n { 2 } }
674 { 2 - \int_eval:n { \l__dmn_suboutput_int + 1 } }
675 \exp_not:N \rectanglecolor
676 { red!60!green!60!blue!15}
677 { 3 - \int_eval:n { 1 } }
678 { 3 - \int_eval:n { \l__dmn_suboutput_int + 1 } }
679 ]
680 }
681 \exp_args:Ne \multicolumn
682 { \int_eval:n { 1 } }
683 { l }
684 { #1 } \\
685 #2 &
686 \exp_args:Ne \multicolumn
687 { \int_eval:n {\l__dmn_suboutput_int}}
688 { c }
689 { #3 } \\
690 & \clist_use:Nn \l__dmn_suboutput_clist { & } \\
691 1 &
692 \seq_map_inline:Nn \l__dmn_cells_seq
693 {
694 \int_compare:nT { \c@jCol = 0 } { \int_eval:n { \c@iRow - 1 } & }
695 ##1
696 \int_compare:nTF { \c@jCol = \l__dmn_suboutput_int + 1 }
697 { \\ }
698 { & }
699 }
700 \end { NiceTabular }
701 }
702
703 \NewDocumentCommand \goaltable { m m }
704 {
705 \seq_clear_new:N \l__dmn_cells_seq
706 \seq_set_split:Nnn \l__dmn_cells_seq { , } { #2 }
707 \use:x
708 {
709 \exp_not:N \begin { NiceTabular }
710 { \prg_replicate:nn { 1 } c }
711 [
712 hvlines-except-corners ,
713 code-before =
714 \exp_not:N \rectanglecolor
715 { blue!30!green!10!red!20 }
716 { 1 - \int_eval:n { 1 } }
717 { 1 - \int_eval:n { 1} }
718 ]
719 }
720 \textbf{#1} \\
721 %\exp_args:Ne \multicolumn
722 % { \int_eval:n { 1 } }
723 % { c }
724 % { \textbf{#1} } \\
725 \seq_map_inline:Nn \l__dmn_cells_seq
726 {
727 \int_compare:nT { \c@jCol = 0 } { }
728 ##1
729 \int_compare:nTF { \c@jCol = 1 }
730 { \\ }
731 { & }
732 }
733 \end { NiceTabular }
734 }
735
736 \endinput
737 %%
738 %% End of file `decision-table.sty'.
739
740 % \end{macrocode}
741 %
742 %
743 %
744 % \tableofcontents
745 %
746 % \end{document}
747 %
748 % Local Variables:
749 % TeX-fold-mode: t
750 % TeX-fold-preserve-comments: nil
751 % flyspell-mode: nil
752 % fill-column: 80
753 % End:
754
755
756
757
758
759