summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/profcollege/latex/PfCRepresenterTableur.tex
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/profcollege/latex/PfCRepresenterTableur.tex')
-rw-r--r--macros/latex/contrib/profcollege/latex/PfCRepresenterTableur.tex55
1 files changed, 52 insertions, 3 deletions
diff --git a/macros/latex/contrib/profcollege/latex/PfCRepresenterTableur.tex b/macros/latex/contrib/profcollege/latex/PfCRepresenterTableur.tex
index 4ac96a74e6..35eed81431 100644
--- a/macros/latex/contrib/profcollege/latex/PfCRepresenterTableur.tex
+++ b/macros/latex/contrib/profcollege/latex/PfCRepresenterTableur.tex
@@ -12,6 +12,7 @@
\newcount\Affichecntcol%
\newcount\Affichecntlin%
\makeatletter%
+% Pour la version nicematrix
\newtoks\t@b%
\long\def\ifremain@lines#1\\#2\@nil{%
\csname @\ifx\@empty#2\@empty second\else first\fi oftwo\endcsname}%
@@ -24,14 +25,26 @@
\newcommand\addtot@b[1]{\t@b\expandafter{\the\t@b#1}}%
\newcommand\edftot@b[1]{\edef\temp@{#1}\expandafter\addtot@b\expandafter{\temp@}}%
+%%%%%%%%%%
+% Pour la version tabular
+\newtoks\t@bs%
+\long\def\ifremain@liness#1\\#2\@nil{%
+ \csname @\ifx\@empty#2\@empty second\else first\fi oftwo\endcsname}%
+\long\def\subst@eols#1\\#2\@nil{\addtot@bs{#1\\\hline}%
+ \ifremain@lines#2\\\@nil{\addtot@bs&\subst@eols#2\@nil}{\addtot@bs{#2\end{tabular}}}}%
+\long\def\collectcp@bodys#1\end{\subst@eols#1\@nil\end}%
+
+\newcommand\addtot@bs[1]{\t@bs\expandafter{\the\t@bs#1}}%
+\newcommand\edftot@bs[1]{\edef\temp@{#1}\expandafter\addtot@bs\expandafter{\temp@}}%
+%%%%%%%%%%%%%%%
\newlength\PfCLongInter%
\newlength\PfCTableurLargeurUn%
\newlength\PfCTableurLargeur%
-\newenvironment{Tableur}[1][]{%
+\NewDocumentEnvironment{Tableur}{so}{%
\useKVdefault[Tableur]%
- \setKV[Tableur]{#1}%
+ \setKV[Tableur]{#2}%
\setlength{\PfCTableurLargeurUn}{\fpeval{\useKV[Tableur]{LargeurUn}}pt}%
\setlength{\PfCTableurLargeur}{\fpeval{\useKV[Tableur]{Largeur}}pt}%
\ifnum\useKV[Tableur]{DebutColonnes}=0\relax
@@ -47,6 +60,42 @@
\ttfamily%
\newcolumntype{A}{>{\centering\arraybackslash}m{\PfCTableurLargeurUn}}%
\newcolumntype{B}{>{\centering\arraybackslash}m{\PfCTableurLargeur}}%
+ \IfBooleanTF{#1}{%
+ \setlength{\PfCLongInter}{-40pt+\fpeval{\useKV[Tableur]{LargeurUn}}pt+\fpeval{(\useKV[Tableur]{Colonnes}-2)*\useKV[Tableur]{Largeur}}pt+\fpeval{2*\useKV[Tableur]{Colonnes}-6}\tabcolsep+\fpeval{\useKV[Tableur]{Colonnes}-3}\arrayrulewidth}%
+ \ifboolKV[Tableur]{Bandeau}{%
+ \begin{tabular}{|p{\PfCTableurLargeur}|p{10pt}|p{50pt}|p{\PfCLongInter}|}%
+ \hhline{--~-}%
+ \useKV[Tableur]{Cellule}&\scriptsize$\blacktriangledown$&$f_x$\hfill$\sum$~\scriptsize$\blacktriangledown$\hfill$=$&\useKV[Tableur]{Formule}\hfill\scriptsize$\blacktriangledown$\\%
+ \hhline{--~-}%
+ \end{tabular}%
+ \nopagebreak%
+ \\%
+ }{}%
+ \cntlin\z@%
+ \t@bs{%
+ \begin{tabular}{%
+ |>{%
+ \cellcolor{gray!15}%
+ \global\cntcol\z@
+ \global\advance\cntlin\@ne%
+ \centering\arraybackslash%
+ \ifnum\cntlin>\@ne%
+ \fpeval{\cntlin+\Affichecntlin-1}\fi}%
+ wc{20pt}|A|*{\fpeval{\useKV[Tableur]{Colonnes}-1}}{B|}}%
+ \hline%
+ \rowcolor{gray!15}%
+ }%
+ \loop%
+ \ifnum\cntcol<\useKV[Tableur]{Colonnes}%
+ \advance\cntcol\@ne%
+ \advance\Affichecntcol\@ne%
+ \addtot@bs{&}%
+ % \edftot@bs{\@Alph{\the\cntcol}}%
+ \edftot@bs{\@Alph{\the\Affichecntcol}}%
+ \repeat%
+ \addtot@bs{\\\hline&}%
+ \collectcp@bodys
+ }{%
\setlength{\PfCLongInter}{-40pt+\fpeval{\useKV[Tableur]{LargeurUn}}pt+\fpeval{(\useKV[Tableur]{Colonnes}-2)*\useKV[Tableur]{Largeur}}pt+\fpeval{2*\useKV[Tableur]{Colonnes}-6}\tabcolsep+\fpeval{\useKV[Tableur]{Colonnes}+2}\arrayrulewidth}%
\ifboolKV[Tableur]{Bandeau}{%
\begin{NiceTabular}{p{\PfCTableurLargeur}p{10pt}p{50pt}p{\PfCLongInter}}%
@@ -111,5 +160,5 @@
% fin de modif
\repeat%
\addtot@b{\\&}%
- \collectcp@body}{\the\t@b}%
+ \collectcp@body}}{\IfBooleanTF{#1}{\the\t@bs}{\the\t@b}}%
\makeatother \ No newline at end of file