summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/profcollege/latex/PfCTablesOperations.tex
blob: c88c18363ce6df8c9f6624d0cf90e924ada2c7c3 (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
%%%
% Tables Addition-Multiplication
%%%
\setKVdefault[Tables]{Addition=false,Soustraction=false,Multiplication,Seul=false,Debut=0,Fin=10,Couleur=white}

% pour m\'emoire
\newcommand\TableMultiplicationComplete{%
  \xdef\NbColTabMul{\fpeval{\useKV[Tables]{Fin}+1-\useKV[Tables]{Debut}}}%
  \begin{tabular}{|>{\columncolor{gray!15}\centering\arraybackslash}p{1.5em}|*{\NbColTabMul}{>{\centering\arraybackslash}p{1.5em}|}}%
    \hline
    $\times$\xintFor* ##1 in {\xintSeq {\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{%
    &\cellcolor{gray!15}\fpeval{##1}
      }
    \\
    \hline
    \xintFor* ##1 in {\xintSeq {0}{10}}\do{%
    ##1\xintFor* ##2 in {\xintSeq {\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{%
    &\fpeval{##2*##1}
      }
    \\
    \hline
    }
  \end{tabular}%
}
%%%%

\newcommand\TableMultiplicationCompleteColore{%
  \xdef\NbColTabMul{\fpeval{\useKV[Tables]{Fin}+1-\useKV[Tables]{Debut}}}%
  \begin{tabular}{|>{\columncolor{gray!15}\centering}p{15pt}|*{\NbColTabMul}{>{\centering\arraybackslash}p{15pt}|}}%
    \hline
    $\times$\xintFor* ##1 in {\xintSeq {\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{%
    &\cellcolor{gray!15}\fpeval{##1}%
      }
    \\
    \hline
    \xintFor* ##1 in {\xintSeq {0}{10}}\do{%
    ##1\xintFor* ##2 in {\xintSeq {\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{%
    &\xintifboolexpr{##2<##1}{\cellcolor{\useKV[Tables]{Couleur}!\fpeval{##1*10}}}{\xintifboolexpr{##2>##1}{\cellcolor{\useKV[Tables]{Couleur}!\fpeval{##2*10}}}{}}\fpeval{##2*##1}%
      }%
    \\
    \hline
    }%
  \end{tabular}%
}%

\newcommand\TableAdditionComplete{%
  \xdef\NbColTabMul{\fpeval{\useKV[Tables]{Fin}+1-\useKV[Tables]{Debut}}}%
  \begin{tabular}{|>{\columncolor{gray!15}\centering}p{15pt}|*{\NbColTabMul}{>{\centering\arraybackslash}p{15pt}|}}%
    \hline
    $+$\xintFor* ##1 in {\xintSeq {\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{%
    &\cellcolor{gray!15}\fpeval{##1}
      }
    \\
    \hline
    \xintFor* ##1 in {\xintSeq {0}{10}}\do{%
    ##1\xintFor* ##2 in {\xintSeq {\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{%
    &\fpeval{##2+##1}
      }
    \\
    \hline
    }
  \end{tabular}%
}

\newcommand\TableMultiplicationSeule[1]{%
  \ensuremath{%
    \begin{array}{ccccc}%
      \xintFor* ##1 in {\xintSeq
      {\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{
      ##1&\times&#1&=&\fpeval{##1*#1}\\
      }
    \end{array}
  }%
}%

\newcommand\TableAdditionSeule[1]{%
  \ensuremath{%
    \begin{array}{ccccc}
      \xintFor* ##1 in {\xintSeq
      {\useKV[Tables]{Debut}}{\useKV[Tables]{Fin}}}\do{
      ##1&+&#1&=&\fpeval{##1+#1}\\
      }
    \end{array}
  }%
}%

\newcommand\TableSoustractionSeule[1]{%
  \ensuremath{%
    \begin{array}{ccccc}
      \xintFor* ##1 in {\xintSeq
      {\fpeval{#1+\useKV[Tables]{Debut}}}{\fpeval{#1+\useKV[Tables]{Fin}}}}\do{
      ##1&-&#1&=&\fpeval{##1-#1}\\
      }
    \end{array}
  }%
}%

\newcommand\Tables[2][]{%
  \useKVdefault[Tables]%
  \setKV[Tables]{#1}%
  \ifboolKV[Tables]{Seul}{%
    \ifboolKV[Tables]{Soustraction}{%
      \TableSoustractionSeule{#2}%
    }{%
      \ifboolKV[Tables]{Addition}{%
        \TableAdditionSeule{#2}%
      }{%
        \TableMultiplicationSeule{#2}%
      }%
    }%
  }{%
    \ifboolKV[Tables]{Soustraction}{%
      La clé Soustraction n'est pas disponible ici.%
    }{%
      \ifboolKV[Tables]{Addition}{%
        \TableAdditionComplete%
      }{%
        \TableMultiplicationCompleteColore%
      }%
    }%
  }%
}%