summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/decision-table/decision-table.sty
blob: 19ece4adcc38695554988f6bb9fc1f4e22cc69fb (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
%%
%% This is file `decision-table.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% decision-table.dtx  (with options: `package')
%% 
%% Copyright (C) 2020 by S. Vandevelde, F. Pantigny
%% 
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version.  The latest version of this license is in:
%% 
%%      http://www.latex-project.org/lppl.txt
%% 
%% and version 1.3c or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
\def\dmnfileversion{0.0.3}
\def\dmnfiledate{2020/12/08}

\RequirePackage{l3keys2e}
\ProvidesExplPackage
  {decision-table}
  {\dmnfiledate}
  {\dmnfileversion}
  {Table of decision}
\RequirePackage { nicematrix }
\NewDocumentCommand \dmntable { m m m m m }
  {
    \clist_clear_new:N \l__dmn_input_clist
    \clist_set:Nn \l__dmn_input_clist { #3 }
    \clist_clear_new:N \l__dmn_output_clist
    \clist_set:Nn \l__dmn_output_clist { #4 }
    \int_zero_new:N \l__dmn_input_int
    \int_set:Nn \l__dmn_input_int { \clist_count:N \l__dmn_input_clist }
    \int_zero_new:N \l__dmn_output_int
    \int_set:Nn \l__dmn_output_int { \clist_count:N \l__dmn_output_clist }
    \seq_clear_new:N \l__dmn_cells_seq
    \seq_set_split:Nnn \l__dmn_cells_seq { , } { #5 }
    \use:x
      {
        \exp_not:N \begin { NiceTabular }
        { r \prg_replicate:nn { \l__dmn_input_int + \l__dmn_output_int } l }
        [
          hvlines-except-corners ,
          code-before =
           \exp_not:N \rectanglecolor
             { blue!10!green!60!black!30 }
             { 2 - 2 }
             { 2 - \int_eval:n { \l__dmn_input_int + 1 } }
           \exp_not:N \rectanglecolor
             { green!30!blue!15 }
             { 2 - \int_eval:n { \l__dmn_input_int + 2 } }
             { 2 - \int_eval:n { \l__dmn_input_int + \l__dmn_output_int + 1 } }
        ]
      }
    \exp_args:Ne \multicolumn
      { \int_eval:n { \l__dmn_input_int + 1 } }
      { l }
      { #1 } \\
    #2 &
    \clist_use:Nn \l__dmn_input_clist { & } &
    \clist_use:Nn \l__dmn_output_clist { & } \\
    1 &
    \seq_map_inline:Nn \l__dmn_cells_seq
      {
        \int_compare:nT { \c@jCol = 0 } { \int_eval:n { \c@iRow - 1 } & }
        ##1
        \int_compare:nTF { \c@jCol = \l__dmn_input_int + \l__dmn_output_int + 1 }
          { \\ }
          { & }
      }
    \end { NiceTabular }
  }

\endinput
%%
%% End of file `decision-table.sty'.