summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/pas-tableur
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-08-24 21:19:23 +0000
committerKarl Berry <karl@freefriends.org>2014-08-24 21:19:23 +0000
commitb96aca1b0ee11148da514afa461dcb9e88eda0b2 (patch)
tree9a2d99bab80ff0702c3c86a84b85c38c13ac7024 /Master/texmf-dist/tex/latex/pas-tableur
parent9913fb8461243c1606b55dabd26ad4871aac1929 (diff)
pas-tableur (24aug14)
git-svn-id: svn://tug.org/texlive/trunk@35034 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/pas-tableur')
-rw-r--r--Master/texmf-dist/tex/latex/pas-tableur/pas-tableur.sty602
1 files changed, 409 insertions, 193 deletions
diff --git a/Master/texmf-dist/tex/latex/pas-tableur/pas-tableur.sty b/Master/texmf-dist/tex/latex/pas-tableur/pas-tableur.sty
index d1a735b3768..f1422a6f9f2 100644
--- a/Master/texmf-dist/tex/latex/pas-tableur/pas-tableur.sty
+++ b/Master/texmf-dist/tex/latex/pas-tableur/pas-tableur.sty
@@ -1,26 +1,24 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
-% pas-tableur.sty v1.06 encodage : UTF8 %
+% pas-tableur.sty v2.00 encodage : UTF8 %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
-% Créé par Stéphane PASQUET %
+% Créé par Stéphane PASQUET %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% V1.02 : 12/05/2012 -> Modification de la macro \tableur : on peut désormais écrire \tableur{A,B,C,D} ou \tableur{A-D}
-% V1.03 : 13/05/2012 -> Modification de la macro \celtxt : on peut désormais insérer l'accent circonflexe dans du texte et si le texte est plus large que la cellule, le trait gris de séparation des cellules n'est plus visible (le texte s'écrit par dessus).
-% V1.04 : 13/05/2012 -> Amélioration de la macro \celtxt : le texte est réduit pour ne pas effacer les traits de cellule
-% V1.05 : 25/03/2014 -> Amélioration de la macro \celtxt : conflit avec "$" et "^"
-% V1.06 : 17/04/2014 -> correction du bug sur la macro \celtxt : les options [c] et [r] fonctionnent
-
-% Informations générales
-\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{pas-tableur}[2014/04/17]
-
-\RequirePackage{tikz}
+%
+\def\fileversion{2.00}
+\def\filedate{2014/08/16}
+\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+\ProvidesClass{pas-tableur}[%
+ \filedate\space v\fileversion\space
+ LaTeX package by Stephane PASQUET]
+\@ifpackageloaded{tikz}{}{\RequirePackage{tikz}}
\usetikzlibrary{calc}
-\RequirePackage{xstring}
-\RequirePackage{multido}
+\@ifpackageloaded{xstring}{}{\RequirePackage{xstring}}
+\@ifpackageloaded{xkeyval}{}{\RequirePackage{xkeyval}}
+
% Définition des couleurs
@@ -31,215 +29,433 @@
\definecolor{blueSelecCellBottom}{cmyk}{0.75,0.34,0,0}
\definecolor{blueSelec}{cmyk}{0.23,0.06,0,0}
-% Définition des dimensions lignes/colonnes
-\def\colminwidth{7em}
-\def\lineminheight{1.57em}
+% Définition des dimensions par défaut
-% Définition des polices de caractères
-\newcommand{\helvbx}{\usefont{T1}{phv}{m}{n}}
-\newcommand{\helv}{\usefont{T1}{phv}{l}{n}}
-
-% Définition des compteurs
-\newcounter{celnumber}
-\newcounter{tmp}
-\newcounter{nbcolselected}
-\newcounter{nblineselected}
-\newcount\cntcol
-
-% Macros auxiliaires pour mémoriser les lettres désignant les colonnes
-\newcommand*\defcolumns{\cntcol\z@\valheadcols}
-\newcommand*\valheadcols[1]{\expandafter\valheadcols@#1,\valheadcols@,}
-\newcommand*\defcolumnsB{\cntcol\z@\valheadcolsB}
-\newcommand*\valheadcolsB[1]{\valheadcols@#1,\valheadcols@,}
-\def\valheadcols@#1,{%
- \ifx\valheadcols@#1%
- \else
- \advance\cntcol\@ne
- \expandafter\xdef\csname ValCol#1\endcsname{\number\cntcol}
- \expandafter\valheadcols@
- \fi
-}
-\newcommand*\ValCol[1]{\@nameuse{ValCol#1}}
+\def\col@width{7em}
+\def\numline@width{3em} % largeur de la colonne indiquant le numéros des lignes
+\def\line@height{1.57em}
-% Macros auxiliaires pour mémoriser les lettres désignant les colonnes sélectionnées
-\newcommand*\defcolselected{\cntcol\z@\valcolselected}
-\newcommand*\valcolselected[1]{\expandafter\valcolselected@#1,\valcolselected@,}
-\def\valcolselected@#1,{%
- \ifx\valcolselected@#1%
- \else
- \advance\cntcol\@ne
- \expandafter\xdef\csname ValColSelected\number\cntcol\endcsname{#1}
- \expandafter\valcolselected@
- \fi
-}
-\newcommand*\ValColSelected[1]{\@nameuse{ValColSelected#1}}
+ %==> Changer les valeurs par défaut
+ \newcommand*{\tabcolwidth}[1]{\def\col@width{#1}}
+ \newcommand*{\tabnumlinewidth}[1]{\def\numline@width{#1}}
+ \newcommand*{\tablineheight}[1]{\def\line@height{#1}}
+
+% Définition des polices de caractères
-% Macros auxiliaires pour mémoriser les lettres désignant les lignes sélectionnées
-\newcommand*\deflineselected{\cntcol\z@\vallineselected}
-\newcommand*\vallineselected[1]{\vallineselected@#1,\vallineselected@,}
-\def\vallineselected@#1,{%
- \ifx\vallineselected@#1%
- \else
- \advance\cntcol\@ne
- \expandafter\xdef\csname ValLineSelected\number\cntcol\endcsname{#1}
- \expandafter\vallineselected@
- \fi
-}
-\newcommand*\ValLineSelected[1]{\@nameuse{ValLineSelected#1}}
+\newcommand{\helvbx}{\usefont{T1}{phv}{m}{n}}
-%----------> Liste des noms de colonnes <----------
-\global\def\col@names{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
+% Construction du tableur
-%----------> Construction du tableur <-----------
-\newcommand{\tableur}[2][1] % [#1] -> nombre de lignes (par défaut, "1"), #2 -> A,B,...,Z
-{%
-% On mémorise les lettres des colonnes
-% \ValCol{A} sera égal à "1" si la 1ère colonne porte la lettre "A"
-\setcounter{celnumber}{0}
-\IfSubStr{#2}{-}
-{%
- \StrBefore{#2}{-}[\str@start] % 1ère lettre, par ex. "G"
- \StrBehind{#2}{-}[\str@end] % 2ème lettre, par ex. "L"
- \StrBetween{\col@names}{\str@start}{\str@end}[\str@col] % retourne par exemple "HIJK"
- \edef\str@col{\str@start\str@col\str@end}
- \StrLen{\str@col}[\nb@columns]
- \StrChar{\str@col}{1}[\lettre]
- \xdef\chaine{\lettre}
- \multido{\i=2+1}{\nb@columns}
- {
- \StrChar{\str@col}{\i}[\lettre]
- \xdef\chaine{\chaine,\lettre}
- } % ici, \chaine = "H,I,J,K,"
- \StrGobbleRight{\chaine}{1}[\chaine] % retire la dernière virgule : \chaine -> "H,I,J,K"
- \defcolumns{\chaine}
- \multido{\i=1+1}{\nb@columns}
- {
- \StrChar{\str@col}{\i}[\lettre]
- \node[below right,inner xsep=1ex,minimum width=\colminwidth,minimum height=\lineminheight] (c\thecelnumber) at ({\thecelnumber*\colminwidth},0) {\helvbx\lettre};
- \fill[grayTopCell] (c\thecelnumber.north west) -- (c\thecelnumber.north east) -- ($0.5*(c\thecelnumber.north east)+0.5*(c\thecelnumber.south east)$) -- ($0.5*(c\thecelnumber.south west)+0.5*(c\thecelnumber.north west)$) -- cycle;
- \fill[grayBottomCell] (c\thecelnumber.south west) -- (c\thecelnumber.south east) -- ($0.5*(c\thecelnumber.south east)+0.5*(c\thecelnumber.north east)$) -- ($0.5*(c\thecelnumber.south west)+0.5*(c\thecelnumber.north west)$) -- cycle;
- \node[below right,inner sep=1ex,minimum width=\colminwidth,minimum height=\lineminheight] at (c\thecelnumber.north west) {\helvbx\lettre};
- \stepcounter{celnumber}
- }
-}
-{
- \defcolumnsB{#2}
- \foreach \i in {#2}
- {
- \node[below right,inner xsep=1ex,minimum width=\colminwidth,minimum height=\lineminheight] (c\thecelnumber) at ({\thecelnumber*\colminwidth},0) {\helvbx\i};
- \fill[grayTopCell] (c\thecelnumber.north west) -- (c\thecelnumber.north east) -- ($0.5*(c\thecelnumber.north east)+0.5*(c\thecelnumber.south east)$) -- ($0.5*(c\thecelnumber.south west)+0.5*(c\thecelnumber.north west)$) -- cycle;
- \fill[grayBottomCell] (c\thecelnumber.south west) -- (c\thecelnumber.south east) -- ($0.5*(c\thecelnumber.south east)+0.5*(c\thecelnumber.north east)$) -- ($0.5*(c\thecelnumber.south west)+0.5*(c\thecelnumber.north west)$) -- cycle;
- \node[below right,inner sep=1ex,minimum width=\colminwidth,minimum height=\lineminheight] at (c\thecelnumber.north west) {\helvbx\i};
- \stepcounter{celnumber}
- }
-}
+ %==> Style des cellules
+ \tikzstyle{celempty} = [outer sep=0pt]
+ \tikzstyle{celhead} = [draw=black,rectangle,outer sep=0pt]
+
+ %==> Macro de redirection : étoilée ou pas étoilée ?
+ \newcommand{\tableur}{\@ifstar{\tableur@star}{\tableur@nostar}}
-% Placement des numéros de lignes
-\foreach \i in {1,...,#1}
-{
- \node[below left,inner xsep=1ex,minimum width=3em,minimum height=\lineminheight,draw,very thin] (nb) at (0,{-\i*\lineminheight}) {\helvbx\i};
- \fill[grayTopCell] (nb.north west) -- (nb.north east) -- ($0.5*(nb.north east)+0.5*(nb.south east)$) -- ($0.5*(nb.south west)+0.5*(nb.north west)$) -- cycle;
- \fill[grayBottomCell] (nb.south west) -- (nb.south east) -- ($0.5*(nb.south east)+0.5*(nb.north east)$) -- ($0.5*(nb.south west)+0.5*(nb.north west)$) -- cycle;
- \node[below left,inner xsep=1ex,minimum width=3em,minimum height=\lineminheight,draw,very thin] (nb) at (0,{-\i*\lineminheight}) {\helvbx\i};
+ %==> Macro étoilée : \tableur*{A/<l1>,B/<l2>,...}. Tableur avec colonnes de largeurs différentes
+ \newcommand{\tableur@star}[2][1]
+ {%
+ \xdef\list@of@col{#2}
+ % Placement de la première cellule en-tête
+ \StrChar{#2}{1}[\first@name]
+ \StrBetween{#2}{/}{,}[\first@width]
+ \node[minimum width={\first@width},minimum height=\line@height,celhead] (\first@name) {\helvbx\first@name};
+ \fill[grayBottomCell]
+ (\first@name.south west) --
+ (\first@name.south east) --
+ ($0.5*(\first@name.south east)+0.5*(\first@name.north east)$) --
+ ($0.5*(\first@name.south west)+0.5*(\first@name.north west)$) --
+ cycle;
+ \fill[grayTopCell]
+ (\first@name.north west) --
+ (\first@name.north east) --
+ ($0.5*(\first@name.south east)+0.5*(\first@name.north east)$) --
+ ($0.5*(\first@name.south west)+0.5*(\first@name.north west)$) --
+ cycle;
+ \node[minimum width={\first@width},minimum height=\line@height,celhead] at (\first@name) {\helvbx\first@name};
+
+ % Placement des autres en-têtes de colonnes
+
+ \foreach \name/\w [remember=\name as \lastname,count=\colnumber] in {#2}
+ {
+ \ifx\name\first@name
+ \else
+ \node[minimum width={\w},minimum height=\line@height,celhead,right] (\name) at (\lastname.east) {\helvbx\name};
+ \fill[grayBottomCell]
+ (\name.south west) --
+ (\name.south east) --
+ ($0.5*(\name.south east)+0.5*(\name.north east)$) --
+ ($0.5*(\name.south west)+0.5*(\name.north west)$) --
+ cycle;
+ \fill[grayTopCell]
+ (\name.north west) --
+ (\name.north east) --
+ ($0.5*(\name.south east)+0.5*(\name.north east)$) --
+ ($0.5*(\name.south west)+0.5*(\name.north west)$) --
+ cycle;
+ \node[minimum width={\w},minimum height=\line@height,celhead,right] at (\lastname.east) {\helvbx\name};
+ \fi
+ }
+
+ % Placement des en-têtes de lignes
+
+ \node[below left,celhead,minimum width=\numline@width,minimum height=\line@height] (numline1) at (\first@name.south west) {\helvbx 1};
+ \fill[grayBottomCell]
+ (numline1.south west) --
+ (numline1.south east) --
+ ($0.5*(numline1.south east)+0.5*(numline1.north east)$) --
+ ($0.5*(numline1.south west)+0.5*(numline1.north west)$) --
+ cycle;
+ \fill[grayTopCell]
+ (numline1.north west) --
+ (numline1.north east) --
+ ($0.5*(numline1.south east)+0.5*(numline1.north east)$) --
+ ($0.5*(numline1.south west)+0.5*(numline1.north west)$) --
+ cycle;
+ \node[below left,celhead,minimum width=\numline@width,minimum height=\line@height] (numline1) at (\first@name.south west) {\helvbx1};
+ \ifnum#1>1
+ \foreach \num@line [remember=\num@line as \lastnum (initially 1)] in {2,...,#1}
+ {
+ \node[below,celhead,minimum width=\numline@width,minimum height=\line@height] (numline\num@line) at (numline\lastnum.south) {\helvbx\num@line};
+ \fill[grayBottomCell]
+ (numline\num@line.south west) --
+ (numline\num@line.south east) --
+ ($0.5*(numline\num@line.south east)+0.5*(numline\num@line.north east)$) --
+ ($0.5*(numline\num@line.south west)+0.5*(numline\num@line.north west)$) --
+ cycle;
+ \fill[grayTopCell]
+ (numline\num@line.north west) --
+ (numline\num@line.north east) --
+ ($0.5*(numline\num@line.south east)+0.5*(numline\num@line.north east)$) --
+ ($0.5*(numline\num@line.south west)+0.5*(numline\num@line.north west)$) --
+ cycle;
+ \node[below,celhead,minimum width=\numline@width,minimum height=\line@height] (numline\num@line) at (numline\lastnum.south) {\helvbx\num@line};
+ }
+ \fi
+
+ % Tracé de la grille
+
+ \foreach \name/\w in {#2}
+ {
+ \node[celempty,below,minimum height=\line@height,minimum width=\w] (cell\name-1) at (\name.south) {};
+ \draw[graySepCell] ($(cell\name-1.south west)+(0.25pt,0)$) -- (cell\name-1.south east) -- ($(cell\name-1.north east)+(0,-0.25pt)$);
+ }
+ \ifnum#1>1
+ \foreach\numline [remember=\numline as \lastnumline (initially 1)] in {2,...,#1}
+ {
+ \foreach \name/\w in {#2}
+ {
+ \node[celempty,below,minimum height=\line@height,minimum width=\w] (cell\name-\numline) at (cell\name-\lastnumline.south) {};
+ \draw[graySepCell] ($(cell\name-\numline.south west)+(0.25pt,0)$) -- (cell\name-\numline.south east) -- ($(cell\name-\numline.north east)+(0,-0.25pt)$);
+ }
+ }
+ \fi
+ } % --> Fin de \tableur*
+
+ %==> Macro non étoilée : \tableur{A,B,C,...} ou \tableur{A-C}
+
+ %----------> Liste des noms de colonnes <----------
+ \xdef\col@names{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
+
+ \newcommand{\tableur@nostar}[2][1] % [#1] -> nombre de lignes (par défaut, "1"), #2 -> A,B,...,Z
+ {%
+ \IfSubStr{#2}{-}
+ {%
+ \StrBefore{#2}{-}[\str@start] % 1ère lettre, par ex. "G"
+ \StrBehind{#2}{-}[\str@end] % 2ème lettre, par ex. "L"
+ \StrBetween{\col@names}{\str@start}{\str@end}[\str@col] % retourne par exemple "HIJK"
+ \edef\str@col{\str@start\str@col\str@end} % retourne alors "GHIJKL"
+ \StrLen{\str@col}[\nb@columns] % nombre de colonnes
+ % --> On place la première cellule en-tête
+ \node[minimum width={\col@width},minimum height=\line@height,celhead] (\str@start) {\helvbx\str@start};
+ \fill[grayBottomCell]
+ (\str@start.south west) --
+ (\str@start.south east) --
+ ($0.5*(\str@start.south east)+0.5*(\str@start.north east)$) --
+ ($0.5*(\str@start.south west)+0.5*(\str@start.north west)$) --
+ cycle;
+ \fill[grayTopCell]
+ (\str@start.north west) --
+ (\str@start.north east) --
+ ($0.5*(\str@start.south east)+0.5*(\str@start.north east)$) --
+ ($0.5*(\str@start.south west)+0.5*(\str@start.north west)$) --
+ cycle;
+ \node[minimum width={\col@width},minimum height=\line@height,celhead] at (\str@start) {\helvbx\str@start};
+ % --> On place les autres en-têtes
+ \foreach \i [remember=\i as \lasti (initially 1)] in {2,...,\nb@columns}
+ {
+ \StrChar{\str@col}{\i}[\name]
+ \StrChar{\str@col}{\lasti}[\lastname]
+ \node[minimum width={\col@width},minimum height=\line@height,celhead,right] (\name) at (\lastname.east) {\helvbx\name};
+ \fill[grayBottomCell]
+ (\name.south west) --
+ (\name.south east) --
+ ($0.5*(\name.south east)+0.5*(\name.north east)$) --
+ ($0.5*(\name.south west)+0.5*(\name.north west)$) --
+ cycle;
+ \fill[grayTopCell]
+ (\name.north west) --
+ (\name.north east) --
+ ($0.5*(\name.south east)+0.5*(\name.north east)$) --
+ ($0.5*(\name.south west)+0.5*(\name.north west)$) --
+ cycle;
+ \node[minimum width={\col@width},minimum height=\line@height,celhead] at (\name) {\helvbx\name};
+ }
+ }
+ {
+ \StrChar{#2}{1}[\str@start]
+ \node[minimum width={\col@width},minimum height=\line@height,celhead] (\str@start) {\helvbx\str@start};
+ \fill[grayBottomCell]
+ (\str@start.south west) --
+ (\str@start.south east) --
+ ($0.5*(\str@start.south east)+0.5*(\str@start.north east)$) --
+ ($0.5*(\str@start.south west)+0.5*(\str@start.north west)$) --
+ cycle;
+ \fill[grayTopCell]
+ (\str@start.north west) --
+ (\str@start.north east) --
+ ($0.5*(\str@start.south east)+0.5*(\str@start.north east)$) --
+ ($0.5*(\str@start.south west)+0.5*(\str@start.north west)$) --
+ cycle;
+ \node[minimum width={\col@width},minimum height=\line@height,celhead] at (\str@start) {\helvbx\str@start};
+
+ \foreach \name [remember=\name as \lastname] in {#2}
+ {
+ \ifx\name\str@start
+ \else
+ \node[minimum width={\col@width},minimum height=\line@height,celhead,right] (\name) at (\lastname.east) {\helvbx\name};
+ \fill[grayBottomCell]
+ (\name.south west) --
+ (\name.south east) --
+ ($0.5*(\name.south east)+0.5*(\name.north east)$) --
+ ($0.5*(\name.south west)+0.5*(\name.north west)$) --
+ cycle;
+ \fill[grayTopCell]
+ (\name.north west) --
+ (\name.north east) --
+ ($0.5*(\name.south east)+0.5*(\name.north east)$) --
+ ($0.5*(\name.south west)+0.5*(\name.north west)$) --
+ cycle;
+ \node[minimum width={\col@width},minimum height=\line@height,celhead] at (\name) {\helvbx\name};
+ \fi
+ }
+ }
+
+
+ % Placement des en-têtes de lignes
+
+ \StrChar{#2}{1}[\first@name]
+ \node[below left,celhead,minimum width=\numline@width,minimum height=\line@height] (numline1) at (\first@name.south west) {\helvbx 1};
+ \fill[grayBottomCell]
+ (numline1.south west) --
+ (numline1.south east) --
+ ($0.5*(numline1.south east)+0.5*(numline1.north east)$) --
+ ($0.5*(numline1.south west)+0.5*(numline1.north west)$) --
+ cycle;
+ \fill[grayTopCell]
+ (numline1.north west) --
+ (numline1.north east) --
+ ($0.5*(numline1.south east)+0.5*(numline1.north east)$) --
+ ($0.5*(numline1.south west)+0.5*(numline1.north west)$) --
+ cycle;
+ \node[below left,celhead,minimum width=\numline@width,minimum height=\line@height] (numline1) at (\first@name.south west) {\helvbx1};
+ \ifnum#1>1
+ \foreach \num@line [remember=\num@line as \lastnum (initially 1)] in {2,...,#1}
+ {
+ \node[below,celhead,minimum width=\numline@width,minimum height=\line@height] (numline\num@line) at (numline\lastnum.south) {\helvbx\num@line};
+ \fill[grayBottomCell]
+ (numline\num@line.south west) --
+ (numline\num@line.south east) --
+ ($0.5*(numline\num@line.south east)+0.5*(numline\num@line.north east)$) --
+ ($0.5*(numline\num@line.south west)+0.5*(numline\num@line.north west)$) --
+ cycle;
+ \fill[grayTopCell]
+ (numline\num@line.north west) --
+ (numline\num@line.north east) --
+ ($0.5*(numline\num@line.south east)+0.5*(numline\num@line.north east)$) --
+ ($0.5*(numline\num@line.south west)+0.5*(numline\num@line.north west)$) --
+ cycle;
+ \node[below,celhead,minimum width=\numline@width,minimum height=\line@height] (numline\num@line) at (numline\lastnum.south) {\helvbx\num@line};
+ }
+ \fi
+
+ % Tracé de la grille
+
+ \IfSubStr{#2}{-}
+ {%
+ \foreach \i in {1,...,\nb@columns}
+ {
+ \StrChar{\str@col}{\i}[\name]
+ \node[celempty,below,minimum height=\line@height,minimum width=\col@width] (cell\name-1) at (\name.south) {};
+ \draw[graySepCell] ($(cell\name-1.south west)+(0.25pt,0)$) -- (cell\name-1.south east) -- ($(cell\name-1.north east)+(0,-0.25pt)$);
+ }
+ \ifnum#1>1
+ \foreach\numline [remember=\numline as \lastnumline (initially 1)] in {2,...,#1}
+ {
+ \foreach \i in {1,...,\nb@columns}
+ {
+ \StrChar{\str@col}{\i}[\name]
+ \node[celempty,below,minimum height=\line@height,minimum width=\col@width] (cell\name-\numline) at (cell\name-\lastnumline.south) {};
+ \draw[graySepCell] ($(cell\name-\numline.south west)+(0.25pt,0)$) -- (cell\name-\numline.south east) -- ($(cell\name-\numline.north east)+(0,-0.25pt)$);
+ }
+ }
+ \fi
+ }
+ {%
+ \foreach \name in {#2}
+ {
+ \node[celempty,below,minimum height=\line@height,minimum width=\col@width] (cell\name-1) at (\name.south) {};
+ \draw[graySepCell] ($(cell\name-1.south west)+(0.25pt,0)$) -- (cell\name-1.south east) -- ($(cell\name-1.north east)+(0,-0.25pt)$);
+ }
+ \ifnum#1>1
+ \foreach\numline [remember=\numline as \lastnumline (initially 1)] in {2,...,#1}
+ {
+ \foreach \name in {#2}
+ {
+ \node[celempty,below,minimum height=\line@height,minimum width=\col@width] (cell\name-\numline) at (cell\name-\lastnumline.south) {};
+ \draw[graySepCell] ($(cell\name-\numline.south west)+(0.25pt,0)$) -- (cell\name-\numline.south east) -- ($(cell\name-\numline.north east)+(0,-0.25pt)$);
+ }
+ }
+ \fi
+ }
}
-\addtocounter{celnumber}{-1}
+
+% Insérer quelque chose dans une cellule
-% Tracé de la grille
-\draw[black,very thin] (0,0) grid[xstep=\colminwidth] (c\thecelnumber.south east);
-\foreach \i in {1,...,#1}
-{
- \draw[graySepCell,very thin] (0,{-(\i+1)*\lineminheight}) -- ({(\thecelnumber+1)*\colminwidth},{-(\i+1)*\lineminheight});
-}
-\addtocounter{celnumber}{1}
-\foreach \x in {0,...,\thecelnumber}
-{
- \draw[graySepCell] ({\x*\colminwidth},-\lineminheight) -- ({\x*\colminwidth},{-(#1+1)*\lineminheight});
-}
-\addtocounter{celnumber}{-1}
-\draw (c0.south west) -- (c\thecelnumber.south east);
-\draw (c0.south west) -- ($(c0.south west)+(0,{-\lineminheight*#1})$);
-}
+\define@cmdkey [PAS] {celtxt} {width}{}
+\define@cmdkey [PAS] {celtxt} {color}{}
+\define@boolkey [PAS] {celtxt} {l}[true]{}
+\define@boolkey [PAS] {celtxt} {r}[true]{}
+\define@boolkey [PAS] {celtxt} {c}[true]{}
+\presetkeys [PAS] {celtxt} {width = \col@width, color=black}{}
-%-----------> Insérer un texte dans une cellule <---------------
+\newcommand*{\celtxt}[1][]{\cel@txt[#1]}
-\newcommand\celtxt[3][l]{%
+\newcommand\cel@txt[3][]{%
+ \setkeys[PAS]{celtxt}{#1}
\begingroup
\@makeother\^%
\@makeother\$%
- \@celtxt@{#1}{#2}{#3}%
+ \@celtxt@[#1]{#2}{#3}%
}
-\newcommand\@celtxt@[4]{%
+\newcommand\@celtxt@[4][]{%
\endgroup
+ \setkeys[PAS]{celtxt}{#1}
\StrPosition{#4}{=}[\@equalPos]
\ifnum\@equalPos=1
- \def\@scale{1}%
+ %\def\@scale{1}%
\let\@style\texttt
\else
- \def\@scale{0.9}%
+ %\def\@scale{0.9}%
\let\@style\@empty
\fi
- \node[below right] at ($(c0.south west)+({(\ValCol{#2}-1)*\colminwidth},{-(#3-1)*\lineminheight})$) {\makebox[\colminwidth][#1]{\@style{#4}\phantom{-.}}};
-}
-
-%\newsavebox{\tmp@txt}
-%\newlength{\tmp@ltxt}
-
-% Macro auxiliaire : colorie en-tête colonne
-\newcommand*\colorHead[2]
-{
- \fill[blueSelecCellTop] (c#1.north west) -- (c#1.north east) -- ($0.5*(c#1.north east)+0.5*(c#1.south east)$) -- ($0.5*(c#1.south west)+0.5*(c#1.north west)$) -- cycle;
- \fill[blueSelecCellBottom] (c#1.south west) -- (c#1.south east) -- ($0.5*(c#1.south east)+0.5*(c#1.north east)$) -- ($0.5*(c#1.south west)+0.5*(c#1.north west)$) -- cycle;
- \node[below right,inner sep=1ex,minimum width=\colminwidth,minimum height=\lineminheight] at (c#1.north west) {\helvbx#2};
- \draw[black,very thin] (0,0) grid[xstep=\colminwidth] (c\thecelnumber.south east);
- \draw (c0.south west) -- (c\thecelnumber.south east);
-}
-% Macro auxiliaire : colorie en-tête ligne
-\newcommand*\colorLine[1]
-{
- \node[below left,inner xsep=1ex,minimum width=3em,minimum height=\lineminheight,draw,very thin] (nb) at (0,{-#1*\lineminheight}) {\helvbx#1};
- \fill[blueSelecCellTop] (nb.north west) -- (nb.north east) -- ($0.5*(nb.north east)+0.5*(nb.south east)$) -- ($0.5*(nb.south west)+0.5*(nb.north west)$) -- cycle;
- \fill[blueSelecCellBottom] (nb.south west) -- (nb.south east) -- ($0.5*(nb.south east)+0.5*(nb.north east)$) -- ($0.5*(nb.south west)+0.5*(nb.north west)$) -- cycle;
- \node[below left,inner xsep=1ex,minimum width=3em,minimum height=\lineminheight,draw,very thin] (nb) at (0,{-#1*\lineminheight}) {\helvbx#1};
+ \ifPAS@celtxt@c
+ \def\pos@align{c}
+ \else
+ \ifPAS@celtxt@r
+ \def\pos@align{r}
+ \else
+ \def\pos@align{l}
+ \fi
+ \fi
+ \node at (cell#2-#3) {\makebox[\dimexpr\cmdPAS@celtxt@width-2pt][\pos@align]{\@style{\textcolor{\cmdPAS@celtxt@color}{#4}}}};
}
-\newcommand{\selecCell}[2] % #1 = colonne, #2 = ligne
-{
- \setcounter{tmp}{\ValCol{#1}}
- \addtocounter{tmp}{-1}
- \colorHead{\thetmp}{#1}
- \colorLine{#2}
- \draw[very thick,black] ($(c0.south west)+({\thetmp*\colminwidth},{-(#2-1)*\lineminheight+0.5pt})$) rectangle +(\colminwidth,-\lineminheight);
- \fill[black] ($(c0.south west)+({(\thetmp+1)*\colminwidth},{-(#2-1)*\lineminheight-\lineminheight})+(-1pt,1.5pt)$) rectangle+(3pt,-3pt);
-}
+% Cellule sélectionnée : \selecCell
-\newcommand{\multiSelec}[2] % #1 : colonnes (B,C,D) par exemple, #2 : lignes (2,3,4)
-{
- \defcolselected{#1} % on mémorise les noms des colonnes sélectionnées - \ValColSelected{1} = lettre de la première colonne
- %\xdef\firstlettercol\ValColSelected{1}
+\newcommand*\selecCell[2]
+{%
+ %==> En-tête ligne
- \deflineselected{#2} % on mémorise les noms des lignes sélectionnées - \ValLineSelected{1} = numéro de la première ligne
- %\def\firstline{\ValLineSelected{1}}
+ \fill[blueSelecCellBottom]
+ (numline#2.south west) --
+ (numline#2.south east) --
+ ($0.5*(numline#2.south east)+0.5*(numline#2.north east)$) --
+ ($0.5*(numline#2.south west)+0.5*(numline#2.north west)$) --
+ cycle;
+ \fill[blueSelecCellTop]
+ (numline#2.north west) --
+ (numline#2.north east) --
+ ($0.5*(numline#2.south east)+0.5*(numline#2.north east)$) --
+ ($0.5*(numline#2.south west)+0.5*(numline#2.north west)$) --
+ cycle;
+ \node[celhead,minimum width=\numline@width,minimum height=\line@height] at (numline#2) {\helvbx#2};
- \setcounter{nbcolselected}{0}
+ %==> En-tête colonne
- \foreach \c in {#1}
- {
- \stepcounter{nbcolselected}
- \setcounter{tmp}{\ValCol\c}
- \addtocounter{tmp}{-1}
- \colorHead{\thetmp}{\c}
- }
+ \fill[blueSelecCellBottom]
+ ($(#1.south west)+(0.25pt,0.25pt)$) --
+ ($(#1.south east)+(-0.25pt,0.25pt)$) --
+ ($0.5*(#1.south east)+0.5*(#1.north east)+(-0.25pt,0)$) --
+ ($0.5*(#1.south west)+0.5*(#1.north west)+(0.25pt,0)$) --
+ cycle;
+ \fill[blueSelecCellTop]
+ ($(#1.north west)+(0.25pt,-0.25pt)$) --
+ ($(#1.north east)+(-0.25pt,-0.25pt)$) --
+ ($0.5*(#1.south east)+0.5*(#1.north east)+(-0.25pt,0)$) --
+ ($0.5*(#1.south west)+0.5*(#1.north west)+(0.25pt,0)$) --
+ cycle;
+ \node at (#1) {\helvbx#1};
+
+ %==> Cellule cell#1-#1
- \setcounter{nblineselected}{0}
- \foreach \l in {#2}
+ \draw[very thick] (cell#1-#2.south west) rectangle (cell#1-#2.north east);
+ \fill[black] ($(cell#1-#2.south east)+(-1pt,1pt)$) rectangle +(3pt,-3pt);
+}
+
+% Sélection de plusieurs cellules : \multiSelec{A-1}{B-2} _/!\_ Nouvelle syntaxe 2014
+
+\newcommand*\multiSelec[2]
+{%
+ \fill[blueSelec,opacity=0.5] ($(cell#1.north west)+(0.25pt,-0.25pt)$) rectangle ($(cell#2.south east)+(-0.25pt,0.25pt)$);
+ \draw[very thick] (cell#1.south west) rectangle (cell#1.north east);
+ \fill[black] ($(cell#2.south east)+(-0.5pt,0.5pt)$) rectangle +(3pt,-3pt);
+
+ %==> On colorie les en-têtes "colonnes"
+
+ \StrChar{#1}{1}[\str@start] % par exemple, "G"
+ \StrChar{#2}{1}[\str@end] % par exemple, "L"
+ \StrBetween{\col@names}{\str@start}{\str@end}[\str@col] % retourne par exemple "HIJK"
+ \edef\str@col{\str@start\str@col\str@end} % retourne alors "GHIJKL"
+ \StrLen{\str@col}[\nb@columns] % nombre d'en-têtes "colonnes" à colorier
+ \foreach \i in {1,...,\nb@columns}
{
- \stepcounter{nblineselected}
- \colorLine{\l}
+ \StrChar{\str@col}{\i}[\name]
+ \fill[blueSelecCellBottom]
+ ($(\name.south west)+(0.25pt,0.25pt)$) --
+ ($(\name.south east)+(-0.25pt,0.25pt)$) --
+ ($0.5*(\name.south east)+0.5*(\name.north east)+(-0.25pt,0)$) --
+ ($0.5*(\name.south west)+0.5*(\name.north west)+(0.25pt,0)$) --
+ cycle;
+ \fill[blueSelecCellTop]
+ ($(\name.north west)+(0.25pt,-0.25pt)$) --
+ ($(\name.north east)+(-0.25pt,-0.25pt)$) --
+ ($0.5*(\name.south east)+0.5*(\name.north east)+(-0.25pt,0)$) --
+ ($0.5*(\name.south west)+0.5*(\name.north west)+(0.25pt,0)$) --
+ cycle;
+ \node at (\name) {\helvbx\name};
}
- \fill[blueSelec,opacity=.5] ($(c0.south west)+({(\ValCol{\ValColSelected{1}}-1)*\colminwidth},{-(\ValLineSelected{1}-1)*\lineminheight})$) rectangle +({\thenbcolselected*\colminwidth},{-\thenblineselected*\lineminheight});
+ %==> On colorie les en-têtes "lignes"
- \draw[very thick,black] ($(c0.south west)+({(\ValCol{\ValColSelected{1}}-1)*\colminwidth},{-(\ValLineSelected{1}-1)*\lineminheight+0.5pt})$) rectangle +(\colminwidth,-\lineminheight);
- \fill[black] ($(c0.south west)+({(\ValCol{\ValColSelected{1}}-1)*\colminwidth+\thenbcolselected*\colminwidth-1pt},{-(\ValLineSelected{1}-1)*\lineminheight-\thenblineselected*\lineminheight+1.5pt})$) rectangle+(3pt,-3pt);
+ \StrGobbleLeft{#1}{2}[\first@num]
+ \StrGobbleLeft{#2}{2}[\second@num]
+ \foreach \i in {\first@num,...,\second@num}
+ {
+ \fill[blueSelecCellBottom]
+ (numline\i.south west) --
+ (numline\i.south east) --
+ ($0.5*(numline\i.south east)+0.5*(numline\i.north east)$) --
+ ($0.5*(numline\i.south west)+0.5*(numline\i.north west)$) --
+ cycle;
+ \fill[blueSelecCellTop]
+ (numline\i.north west) --
+ (numline\i.north east) --
+ ($0.5*(numline\i.south east)+0.5*(numline\i.north east)$) --
+ ($0.5*(numline\i.south west)+0.5*(numline\i.north west)$) --
+ cycle;
+ \node[celhead,minimum width=\numline@width,minimum height=\line@height] at (numline\i) {\helvbx\i};
+ }
}
\endinput