summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/profcollege/PfCMotsCodes.tex
blob: 6a638a7c93d83b66b12e7365ed8af7fee261e9e8 (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
%%%
% Mots Cod\'es
%%%
\setKVdefault[MotsCodes]{LargeurT=1cm,Colonnes=5,Largeur=3cm,Solution=false,Math=false}%

\newcommand\MotsCodes[2][]{%
  \useKVdefault[MotsCodes]%
  \setKV[MotsCodes]{#1}%
  \setsepchar[*]{§*/}%
  \readlist*\ListeMotsCodes{#2}%
  \xdef\ListeMotsCodesPas{\fpeval{\ListeMotsCodeslen/\useKV[MotsCodes]{Colonnes}}}%
  \begin{NiceTabular}{*{\fpeval{\useKV[MotsCodes]{Colonnes}}}{>{\centering\arraybackslash}m{\useKV[MotsCodes]{Largeur}}}}[color-inside]
    \xintFor* ##1 in {\xintSeq {1}{\ListeMotsCodesPas}}\do{%
      \xintFor* ##2 in {\xintSeq {1}{\fpeval{\useKV[MotsCodes]{Colonnes}}}}\do{%
        \xintifForFirst{}{&}\Block[draw=black]{4-1}{}%
      }\\
      \xintFor* ##2 in {\xintSeq {1}{\fpeval{\useKV[MotsCodes]{Colonnes}}}}\do{%
        \xintifForFirst{}{&}\ListeMotsCodes[\fpeval{(##1-1)*\useKV[MotsCodes]{Colonnes}+##2},1]
      }\\
      \xintFor* ##2 in {\xintSeq {1}{\fpeval{\useKV[MotsCodes]{Colonnes}}}}\do{%
        \xintifForFirst{}{&}%
      }\\
      \xintFor* ##2 in {\xintSeq {1}{\fpeval{\useKV[MotsCodes]{Colonnes}}}}\do{%
        \xintifForFirst{}{&}\textbf{\Large\ListeMotsCodes[\fpeval{(##1-1)*\useKV[MotsCodes]{Colonnes}+##2},2]}
      }\\
    }%
  \end{NiceTabular}%
}%

\newcommand\MotsCodesTableau[3][]{%
  \useKVdefault[MotsCodes]%
  \setKV[MotsCodes]{#1}%
  \setsepchar[*]{,*/}%
  \readlist*\ListeMotsCodesTableau{#2}%
  \xdef\ListeMotsCodesMax{0}%
  \setsepchar{,}%
  \readlist*\ListeMotsCodesPhrase{#3}%
  \foreachitem\compteur\in\ListeMotsCodesTableau{%
    \xintifboolexpr{\ListeMotsCodesMax<\listlen\ListeMotsCodesTableau[\compteurcnt]}{\xdef\ListeMotsCodesMax{\fpeval{\listlen\ListeMotsCodesTableau[\compteurcnt]}}}{}%
  }%
  \begin{NiceTabular}{*{\fpeval{\ListeMotsCodesMax}}{>{\centering\arraybackslash}m{\useKV[MotsCodes]{LargeurT}}}}[color-inside]
    \xintFor* ##1 in {\xintSeq {1}{\fpeval{\ListeMotsCodesTableaulen}}}\do{%
      \xintFor* ##2 in {\xintSeq {1}{\listlen\ListeMotsCodesTableau[##1]}}\do{%
        \xintifForFirst{}{&}\ifboolKV[MotsCodes]{Solution}{%
          \StrMid{\ListeMotsCodesPhrase[##1]}{##2}{##2}[\MotsCodesMaLettre]%
          \IfStrEq{\MotsCodesMaLettre}{*}{\Block[draw=black,fill=black]{3-1}{}}{\Block[draw=black]{3-1}{\StrMid{\ListeMotsCodesPhrase[##1]}{##2}{##2}}}%
        }{%
          \IfStrEq{\ListeMotsCodesTableau[##1,##2]}{*}{\Block[draw=black,fill=black]{3-1}{}}{\Block[draw=black]{3-1}{}}%
        }%%
      }\\
      \xintFor* ##2 in {\xintSeq {1}{\listlen\ListeMotsCodesTableau[##1]}}\do{%
        \xintifForFirst{}{&}
      }\\
      \xintFor* ##2 in {\xintSeq {1}{\listlen\ListeMotsCodesTableau[##1]}}\do{%
        \xintifForFirst{}{&}\IfStrEq{\ListeMotsCodesTableau[##1,##2]}{*}{}{\footnotesize\ifboolKV[MotsCodes]{Math}{\ListeMotsCodesTableau[##1,##2]}{\num{\ListeMotsCodesTableau[##1,##2]}}}%
      }\\
    }%
  \end{NiceTabular}%
}%