summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/profcollege/latex/PfCGaram.tex
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/profcollege/latex/PfCGaram.tex')
-rw-r--r--macros/latex/contrib/profcollege/latex/PfCGaram.tex51
1 files changed, 51 insertions, 0 deletions
diff --git a/macros/latex/contrib/profcollege/latex/PfCGaram.tex b/macros/latex/contrib/profcollege/latex/PfCGaram.tex
new file mode 100644
index 0000000000..1bcd3ddab3
--- /dev/null
+++ b/macros/latex/contrib/profcollege/latex/PfCGaram.tex
@@ -0,0 +1,51 @@
+%%%
+% Garam
+%%%
+\setKVdefault[Garam]{Taille=7,Largeur=15pt,Solution=false,CouleurSolution=Black}
+\newlength\PfCGaramHeight
+
+\NewDocumentCommand\Garam{o m}{%
+ \useKVdefault[Garam]
+ \setKV[Garam]{#1}%
+ \setlength{\PfCGaramHeight}{\useKV[Garam]{Largeur}+\tabcolsep}%
+ \reademptyitems%
+ \setsepchar[*]{ยง*,*/}%
+ \readlist*\PfCListeGaram{#2}%
+ \colorlet{PfCGaramCoulSol}{\useKV[Garam]{CouleurSolution}}%
+ \begin{NiceTabular}{*{\useKV[Garam]{Taille}}{m{\useKV[Garam]{Largeur}}}}
+ \CodeBefore
+ \xintFor* ##1 in{\xintSeq{2}{\fpeval{\useKV[Garam]{Taille}}}}\do{%
+ \tikz{\draw[dashed,LightGray] (1-|##1)--(last-|##1);}%
+ }%
+ \xintFor* ##1 in{\xintSeq{2}{\fpeval{\PfCListeGaramlen-1}}}\do{%
+ \tikz{\draw[dashed,LightGray] (##1-|1)--(##1-|last);}%
+ }%
+ \tikz{\draw (1-|1) rectangle (last-|last);}%
+ \Body
+ \xintFor* ##1 in{\xintSeq{1}{\PfCListeGaramlen}}\do{%
+ \rule{0pt}{\PfCGaramHeight}\xintFor* ##2 in {\xintSeq{1}{\useKV[Garam]{Taille}}}\do{%
+ \xintifForFirst{}{&}\StrChar{\PfCListeGaram[##1,##2,1]}{1}[\PfCCaracGaram]%
+ \IfStrEq{\PfCCaracGaram}{*}{\Block[draw,fill=black]{1-1}{}}{%
+ \IfStrEq{\PfCCaracGaram}{!}{\Block{}{\ifboolKV[Garam]{Solution}{\StrGobbleLeft{\PfCListeGaram[##1,##2,1]}{1}}{}}}{\Block{}{\color{PfCGaramCoulSol}\PfCListeGaram[##1,##2,1]}}%
+ }%
+ }\\
+ }%
+ \CodeAfter
+ % On place les symboles
+ \xintFor* ##1 in{\xintSeq{1}{\PfCListeGaramlen}}\do{%
+ \xintFor* ##2 in {\xintSeq{1}{\useKV[Garam]{Taille}}}\do{%
+ \StrChar{\PfCListeGaram[##1,##2,1]}{1}[\PfCCaracGaram]%
+ \IfStrEq{\PfCCaracGaram}{*}{}{%
+ \tikz{%
+ \StrSubstitute{\PfCListeGaram[##1,##2,2]}{x}{\times}[\PfCGaramUn]%
+ \StrSubstitute{\PfCGaramUn}{:}{\div}[\PfCGaramUn]%
+ \StrSubstitute{\PfCListeGaram[##1,##2,3]}{x}{\times}[\PfCGaramDeux]%
+ \StrSubstitute{\PfCGaramDeux}{:}{\div}[\PfCGaramDeux]%
+ \xintifForLast{}{\node at (\fpeval{##1+0.5}-|\fpeval{##2+1}) {$\PfCGaramUn$};}
+ \node at (\fpeval{##1+1}-|\fpeval{##2+0.5}) {$\PfCGaramDeux$};
+ }%
+ }%
+ }%
+ }%
+ \end{NiceTabular}
+}% \ No newline at end of file