%%% % Tableur %%% \setKVdefault[Tableur]{Colonnes=4,Largeur=30pt,LargeurUn=30pt,Bandeau=true,Formule={},Cellule=A1,Ligne=0,Colonne=0,PasL=1,PasC=1,Selection=false}% %Idee de P. Nuns \defKV[Tableur]{Couleur=\setKV[Tableur]{Selection}}% % %Bas\'e sur un code de Christian T\'ell\'ech\'ea. \newcount\cntlin% \newcount\cntcol% \makeatletter% \newtoks\t@b% \long\def\ifremain@lines#1\\#2\@nil{% \csname @\ifx\@empty#2\@empty second\else first\fi oftwo\endcsname}% \long\def\subst@eol#1\\#2\@nil{\addtot@b{#1\\}% \ifremain@lines#2\\\@nil{\addtot@b&\subst@eol#2\@nil}{\addtot@b{#2\CodeAfter\xintifboolexpr{\useKV[Tableur]{Ligne}==0 || \useKV[Tableur]{Colonne}==0}{}{% \tikz\node at (row-\fpeval{\useKV[Tableur]{Ligne}+1+\useKV[Tableur]{PasL}}-|col-\fpeval{\useKV[Tableur]{Colonne}+1+\useKV[Tableur]{PasC}}) {\tiny$\blacksquare$};% }% \end{NiceTabular}}}}% \long\def\collectcp@body#1\end{\subst@eol#1\@nil\end}% \newcommand\addtot@b[1]{\t@b\expandafter{\the\t@b#1}}% \newcommand\edftot@b[1]{\edef\temp@{#1}\expandafter\addtot@b\expandafter{\temp@}}% \newlength\PfCLongInter% \newlength\PfCTableurLargeurUn% \newlength\PfCTableurLargeur% \RequirePackage{printlen} \newenvironment{Tableur}[1][]{% \useKVdefault[Tableur]% \setKV[Tableur]{#1}% \setlength{\PfCTableurLargeurUn}{\fpeval{\useKV[Tableur]{LargeurUn}}pt}% \setlength{\PfCTableurLargeur}{\fpeval{\useKV[Tableur]{Largeur}}pt}% \ttfamily% \newcolumntype{Y}{>{\centering\arraybackslash}m{\PfCTableurLargeurUn}}% \newcolumntype{X}{>{\centering\arraybackslash}m{\PfCTableurLargeur}}% \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}} \Block[draw,l]{}{\useKV[Tableur]{Cellule}}&\Block[draw]{}{\scriptsize$\blacktriangledown$}&\Block{}{$f_x$\hfill$\sum$~\scriptsize$\blacktriangledown$\hfill$=$}&\Block[draw]{}{\useKV[Tableur]{Formule}\hfill\scriptsize$\blacktriangledown$}\\ \end{NiceTabular}% \nopagebreak% \\% }{}% \cntlin\z@% \t@b{% \begin{NiceTabular}{% >{% \global\cntcol\z@\global\advance\cntlin\@ne% \centering\arraybackslash% \ifnum\cntlin>\@ne% \ifboolKV[Tableur]{Selection}{% \xintifboolexpr{\cntlin>\useKV[Tableur]{Ligne} && \cntlin<\fpeval{\useKV[Tableur]{Ligne}+\useKV[Tableur]{PasL}+1}}{\textcolor{white}{\number\numexpr\cntlin-1\relax}}{\number\numexpr\cntlin-1\relax}% }{\number\numexpr\cntlin-1\relax}\fi}% wc{20pt}Y*{\fpeval{\useKV[Tableur]{Colonnes}-1}}{X}}[hvlines]% \CodeBefore % on colorie en gris toute la première ligne \tikz\draw[fill=gray!15](row-1-|col-1) rectangle (row-2-|last);% % on colorie en gris toute la première colonne \tikz\draw[fill=gray!15](row-1-|col-1) rectangle (last-|col-2);% % \xintifboolexpr{\useKV[Tableur]{Ligne}==0 || \useKV[Tableur]{Colonne}==0}{}{% \ifboolKV[Tableur]{Selection}{% \xdef\PfCTabCouleur{\useKV[Tableur]{Couleur}}% % on colorie les cellules sans les tracer \tikz\draw[fill=\PfCTabCouleur!50](row-\fpeval{\useKV[Tableur]{Ligne}+1}-|col-\fpeval{\useKV[Tableur]{Colonne}+1}) rectangle (row-\fpeval{\useKV[Tableur]{Ligne}+1+\useKV[Tableur]{PasL}}-|col-\fpeval{\useKV[Tableur]{Colonne}+1+\useKV[Tableur]{PasC}});% % on trace la première cellule qui a servi à sélectionner \tikz\draw[line width=1.25pt,fill=\PfCTabCouleur!50](row-\fpeval{\useKV[Tableur]{Ligne}+1}-|col-\fpeval{\useKV[Tableur]{Colonne}+1}) rectangle (row-\fpeval{\useKV[Tableur]{Ligne}+1+1}-|col-\fpeval{\useKV[Tableur]{Colonne}+1+1});% % on colorie la zone nécessaire sur la première ligne \tikz\draw[fill=\PfCTabCouleur](row-1-|col-\fpeval{\useKV[Tableur]{Colonne}+1}) rectangle (row-2-|col-\fpeval{\useKV[Tableur]{Colonne}+1+\useKV[Tableur]{PasC}});% % on colorie la zone nécessaire sur la première colonne \tikz\draw[fill=\PfCTabCouleur](row-\fpeval{\useKV[Tableur]{Ligne}+1}-|col-1) rectangle (row-\fpeval{\useKV[Tableur]{Ligne}+1+\useKV[Tableur]{PasL}}-|col-2);% }{% \tikz\draw[line width=1.25pt](row-\fpeval{\useKV[Tableur]{Ligne}+1}-|col-\fpeval{\useKV[Tableur]{Colonne}+1}) rectangle (row-\fpeval{\useKV[Tableur]{Ligne}+1+\useKV[Tableur]{PasL}}-|col-\fpeval{\useKV[Tableur]{Colonne}+1+\useKV[Tableur]{PasC}});% }% }% \Body % }% \loop% \ifnum\cntcol<\useKV[Tableur]{Colonnes}% \advance\cntcol\@ne% \addtot@b{&}% % modif by Pascal Nuns \ifboolKV[Tableur]{Selection}{% \ifnum\cntcol>\fpeval{\useKV[Tableur]{Colonne}-1}% \ifnum\cntcol<\fpeval{\useKV[Tableur]{Colonne}+\useKV[Tableur]{PasC}}% \edftot@b{{\noexpand\textcolor{white}{\noexpand\bfseries\@Alph{\the\cntcol}}}}% \else% \edftot@b{\@Alph{\the\cntcol}}% \fi% \else% \edftot@b{\@Alph{\the\cntcol}}% \fi% }{\edftot@b{\@Alph{\the\cntcol}}}% % fin de modif \repeat% \addtot@b{\\&}% \collectcp@body}{\the\t@b}% \makeatother