TeX - LaTeX Asked by Roger Céspedes on July 6, 2021
I made some modifications to the pas-tableur package so that it better resembles Excel 2019, unfortunately I cannot modify the beginning of the row numbering, I attach the image I would like to achieve.
documentclass[serif,aspectratio=169]{beamer}
usetheme{CambridgeUS}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage[spanish,es-tabla]{babel}
usepackage{pgf,tikz}
% the package "tab-excel" from the file "tab-excel.sty" is added ----------------------------------------------
usepackage{tab-excel}
begin{document}
begin{frame}{excel}
begin{tikzpicture}
tableur*[8]{A/2cm ,B/3cm ,C/2cm,D/2cm}
celtxt*[c]{A}{1}{$ n $}
celtxt*[c]{B}{1}{$ u_n $}
celtxt[c]{C}{2}{dd}
selecCell{B}{3}
celtxt{B}{3}{=$C$1*B2+0.1}
multiSelec{B-6}{C-7}
end{tikzpicture}
end{frame}
end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Here starts the modified package
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% pas-tableur.sty v2.01 encodage : UTF8 %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% Cree par Stephane PASQUET %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
deffileversion{2.1}
deffiledate{2016/01/31}
NeedsTeXFormat{LaTeX2e}[1999/12/01]
ProvidesClass{pas-tableur}[%
filedatespace vfileversionspace
LaTeX package by Stephane PASQUET]
RequirePackage{tikz}
usetikzlibrary{calc}
RequirePackage{xstring}
RequirePackage{xkeyval}
%
% Definition des couleurs
%
definecolor{grayTopCell}{RGB}{102 ,102 ,102}
definecolor{grayBottomCell}{RGB}{102 ,102 ,102}
definecolor{graySepCell}{RGB}{102 ,102 ,102}
definecolor{blueSelecCellTop}{RGB}{51 ,51 ,51}
definecolor{blueSelecCellBottom}{RGB}{51 ,51 ,51}
definecolor{verde}{RGB}{33, 115, 70}
definecolor{gris}{RGB}{196,196,196}
%definecolor{grayTopCell}{cmyk}{0.08,0.05,0.06,0}
%definecolor{grayBottomCell}{cmyk}{0.1,0.07,0.08,0}
%definecolor{graySepCell}{cmyk}{0.29,0.21,0.21,0}
%definecolor{blueSelecCellTop}{cmyk}{0.52,0.17,0,0}
%definecolor{blueSelecCellBottom}{cmyk}{0.75,0.34,0,0}
definecolor{blueSelec}{cmyk}{0.23,0.06,0,0}
%
% Definition des dimensions par defaut
%
defcol@width{7em}
defnumline@width{3em} % largeur de la colonne indiquant le numeros des lignes
defline@height{1.57em}
%
%==> Changer les valeurs par defaut
newcommand*{tabcolwidth}[1]{defcol@width{#1}}
newcommand*{tabnumlinewidth}[1]{defnumline@width{#1}}
newcommand*{tablineheight}[1]{defline@height{#1}}
%
% Definition des polices de caracteres
%
newcommand{helvbx}{usefont{T1}{phv}{m}{n}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Construction du tableur %
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%==> Macro intermediaire : trace de la premiere cellule
%
newcommand{pastab@draw@cell}[5]
% #1 : first@width, #2 : first@name, #3 : 0=colonne1 / 1=autres colonnes /
% 2 = ligne 1, #4 : coord., #5 : contenu
{%
ifnum#3=0%
tikzstyle{cellstyle} = [celhead,minimum width={#1},minimum height=line@height]%
defpastableur@coord{(0,0)}%
else%
ifnum#3=1%
tikzstyle{cellstyle} = [celhead,right,minimum width={#1},minimum height=line@height]%
else
ifnum#3=2%
tikzstyle{cellstyle} = [below left,celhead,minimum width={#1},minimum height=line@height]
else%
tikzstyle{cellstryle} = [below,celhead,minimum width={#1},minimum height=line@height]
fi%
fi%
defpastableur@coord{(#4)}%
fi%
node[cellstyle] (#2) at pastableur@coord {helvbx#5};%
fill[grayTopCell]
(#2.north west) --
(#2.north east) --
(#2.south east) --
(#2.south west) --
cycle;%
node[color=white,minimum width={#1},minimum height=line@height,cellstyle] at pastableur@coord {helvbx#5};%
}
%
%==> Macro intermediaire : trace de la grille
%
newcommand{pastableur@grid}[4] % #1 : width, #2 : name, #3 : numline, #4 : coord.
{%
node[celempty,below,minimum height=line@height,minimum width=#1] (cell#2-#3) at (#4) {};%
draw[graySepCell] ($(cell#2-#3.south west)+(0.25pt,0)$) -- (cell#2-#3.south east) -- ($(cell#2-#3.north east)+(0,-0.25pt)$);%
}
%
%==> Style des cellules
%
tikzstyle{celempty} = [outer sep=0pt]
tikzstyle{celhead} = [draw=graySepCell!50,rectangle,outer sep=0pt]
%
%==> Macro de redirection : etoilee ou pas etoilee ?
%
newcommand{tableur}{@ifstar{tableur@star}{tableur@nostar}}
%
%==> Macro etoilee : tableur*{A/<l1>,B/<l2>,...}. Tableur avec colonnes de largeurs differentes
%
newcommand{tableur@star}[2][1]
{%
xdeflist@of@col{#2}%
% Placement de la premiere cellule en-tête
StrChar{#2}{1}[first@name]%
StrBetween{#2}{/}{,}[first@width]%
pastab@draw@cell{first@width}{first@name}{0}{}{first@name}
% Placement des autres en-têtes de colonnes
foreach name/w [remember=name as lastname,count=colnumber] in {#2}
{%
ifxnamefirst@name%
else%
pastab@draw@cell{w}{name}{1}{lastname.east}{name}
fi%
}%
% Placement des en-têtes de lignes INICIA EL CONTADOR
pastab@draw@cell{numline@width}{numline1}{2}{[email protected] west}{1}
ifnum#1>1%
foreach num@line [remember=num@line as lastnum (initially 1)] in {2,...,#1}
{%
pastab@draw@cell{numline@width}{numlinenum@line}{3}{numlinelastnum.south east}{num@line}%
}%
fi%
% Trace de la grille
foreach name/w in {#2}
{%
pastableur@grid{w}{name}{1}{name.south}%
}%
ifnum#1>1%
foreachnumline [remember=numline as lastnumline (initially 1)] in {2,...,#1}
{%
foreach name/w in {#2}
{%
pastableur@grid{w}{name}{numline}{cellname-lastnumline.south}%
}%
}%
fi%
} % --> Fin de tableur*
%
%==> Macro non etoilee : tableur{A,B,C,...} ou tableur{A-C}
%
xdefcol@names{ABCDEFGHIJKLMNOPQRSTUVWXYZ} %----------> Liste des noms de colonnes <----------
%
newcommand{tableur@nostar}[2][1] % [#1] -> nombre de lignes (par defaut, "1"), #2 -> A,B,...,Z
{%
IfSubStr{#2}{-}
{%
StrBefore{#2}{-}[str@start] % 1ere lettre, par ex. "G"
StrBehind{#2}{-}[str@end] % 2eme lettre, par ex. "L"
StrBetween{col@names}{str@start}{str@end}[str@col] % retourne par exemple "HIJK"
edefstr@col{str@startstr@colstr@end} % retourne alors "GHIJKL"
StrLen{str@col}[nb@columns] % nombre de colonnes
% --> On place la premiere cellule en-tête
pastab@draw@cell{col@width}{str@start}{0}{}{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]%
pastab@draw@cell{col@width}{name}{1}{lastname.east}{name}%
}%
}%
{%
StrChar{#2}{1}[str@start]%
pastab@draw@cell{col@width}{str@start}{0}{}{str@start}%
foreach name [remember=name as lastname] in {#2}
{%
ifxnamestr@start%
else%
pastab@draw@cell{col@width}{name}{1}{lastname.east}{name}%
fi%
}%
}%
% Placement des en-têtes de lignes
StrChar{#2}{1}[first@name]%
pastab@draw@cell{numline@width}{numline1}{2}{[email protected] west}{1}
ifnum#1>1%
foreach num@line [remember=num@line as lastnum (initially 1)] in {2,...,#1}
{%
pastab@draw@cell{numline@width}{numlinenum@line}{3}{numlinelastnum.south east}{num@line}%
}%
fi%
% Trace de la grille
IfSubStr{#2}{-}
{%
foreach i in {1,...,nb@columns}
{%
StrChar{str@col}{i}[name]%
pastableur@grid{col@width}{name}{1}{name.south}%
}%
ifnum#1>1%
foreachnumline [remember=numline as lastnumline (initially 1)] in {2,...,#1}
{%
foreach i in {1,...,nb@columns}
{%
StrChar{str@col}{i}[name]%
pastableur@grid{col@width}{name}{numline}{cellname-lastnumline.south}%
}%
}%
fi%
}
{%
foreach name in {#2}
{%
pastableur@grid{col@width}{name}{1}{name.south}%
}%
ifnum#1>1%
foreachnumline [remember=numline as lastnumline (initially 1)] in {2,...,#1}
{%
foreach name in {#2}
{%
pastableur@grid{col@width}{name}{numline}{cellname-lastnumline.south}%
}%
}%
fi%
}%
} % --> Fin de tableur
%
% Inserer quelque chose dans une cellule : celtxt [modif. du 2016/01/21 due `a "Un bon petit"]
%
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}{}
%
newcommand*celtxt@catcoderegime@begin{}
newcommand*celtxt@catcoderegime@end{}
%
newcommand*celtxt
{%
@ifstar{%
letceltxt@catcoderegime@end@empty
letceltxt@catcoderegime@begin@empty
celtxt@i
}{%
defceltxt@catcoderegime@begin{%
begingroup
@makeother^%
@makeother$%
}%
letceltxt@catcoderegime@endendgroup
celtxt@i
}%
}
%
newcommand*{celtxt@i}[1][]{celtxt@ii{#1}}
%
newcommand*celtxt@ii[3]
{%
setkeys[PAS]{celtxt}{#1}%
celtxt@catcoderegime@begin
celtxt@iii{#1}{#2}{#3}%
}
%
newcommand*celtxt@iii[4]
{%
celtxt@catcoderegime@end
IfBeginWith{#4}{=}{letpastab@styletexttt}{letpastab@style@empty}
ifPAS@celtxt@c
defpos@align{c}%
else
ifPAS@celtxt@r
defpos@align{r}%
else
defpos@align{l}%
fi
fi
node at (cell#2-#3) {makebox[dimexprcmdPAS@celtxt@width-2pt][pos@align]{pastab@style{textcolor{cmdPAS@celtxt@color}{#4}}}};%
}
%
% Cellule selectionnee : selecCell
%
newcommand*selecCell[2]
{%
%==> En-tête ligne
%
pastableur@colorcell{numline#2}{0}
node[color=white,celhead,minimum width=numline@width,minimum height=line@height] at (numline#2) {helvbx#2};%
%
%==> En-tête colonne
%
pastableur@colorcell{#1}{1}
node[color=white] at (#1) {helvbx#1};%
%
%==> Cellule cell#1-#1
%
draw[color=verde,very thick] (cell#1-#2.south west) rectangle (cell#1-#2.north east);%
fill[verde] ($(cell#1-#2.south east)+(-1pt,1pt)$) rectangle +(3pt,-3pt);%
} % fin de selecCell
%
% Selection de plusieurs cellules : multiSelec{A-1}{B-2} _/!_ Nouvelle syntaxe 2014
%
newcommand*multiSelec[2]
{%
fill[gris,opacity=0.5] ($(cell#1.north west)+(0.25pt,-0.25pt)$) rectangle ($(cell#2.south east)+(-0.25pt,0.25pt)$);%
% draw[color=verde,very thick] (cell#1.south west) rectangle (cell#1.north east);%
fill[white] (cell#1.south west) rectangle (cell#1.north east);%
draw[color=verde,very thick] ($(cell#1.north west)+(0.25pt,-0.25pt)$) rectangle ($(cell#2.south east)+(-0.25pt,0.25pt)$);%
fill[verde] ($(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"
edefstr@col{str@startstr@colstr@end} % retourne alors "GHIJKL"
StrLen{str@col}[nb@columns] % nombre d'en-têtes "colonnes" `a colorier
foreach i in {1,...,nb@columns}
{%
StrChar{str@col}{i}[name]%
pastableur@colorcell{name}{1}
node[color=white] at (name) {helvbxname};%
}%
%
%==> On colorie les en-têtes "lignes"
%
StrGobbleLeft{#1}{2}[first@num]%
StrGobbleLeft{#2}{2}[second@num]%
foreach i in {first@num,...,second@num}
{%
pastableur@colorcell{numlinei}{0}
node[color=white,celhead,minimum width=numline@width,minimum height=line@height] at (numlinei) {helvbxi};%
}%
}% fin de multiSelec
%
%
%
newlengthpastableur@decal
newcommand{pastableur@colorcell}[2] % #1 : name, #2 : 0=en-tetes "lignes" / 1=en-tetes "colonnes"
{%
ifnum#2=0%
setlengthpastableur@decal{0pt}%
else%
setlengthpastableur@decal{0.25pt}%
fi%
fill[blueSelecCellBottom]
($(#1.south west)+(pastableur@decal,-pastableur@decal)$) --
($(#1.south east)+(-pastableur@decal,pastableur@decal)$) --
($0.5*(#1.south east)+0.5*(#1.north east)+(-pastableur@decal,0)$) --
($0.5*(#1.south west)+0.5*(#1.north west)+(pastableur@decal,0)$) --
cycle;%
fill[blueSelecCellTop]
($(#1.north west)+(pastableur@decal,-pastableur@decal)$) --
($(#1.north east)+(-pastableur@decal,-pastableur@decal)$) --
($(#1.south east)+(-pastableur@decal,pastableur@decal)$) --
($(#1.south west)+(pastableur@decal,-pastableur@decal)$) --
cycle;%
}%
endinput
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP