% Author..........: C. Pierquet
% licence.........: Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txtf
% source pencil...: CC-BY-SA 4.0 https://tex.stackexchange.com/questions/504092/replicating-a-fancy-bordered-text-style-in-latex/504145#504145

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{customenvs}[2024/05/28 0.1.6 Custom classic environments]

%====HISTORIQUE
% v 0.1.6	DisplaySkip patch + Patchs pas-tableur
% v 0.1.5	Boxes for exam title + circled numbers + Vignettes + Small simple boxes creation
% v 0.1.4	Commande (en/fr) pour du texte dans une boîte arrondie, de hauteur 'figée' + 'Chat' SMS
% v 0.1.3	Environnement/Commande pour présentation d'un exercice
% v 0.1.2	Crayon de compétences
% v 0.1.1	Ajout de tableaux de compétences
% v 0.1.0	Version initiale

%====OPTIONS FR ET EN
\newif\if@enum\@enumtrue%
\DeclareOption{nonenum}{\@enumfalse}%
\DeclareOption{noenum}{\@enumfalse}%
\newif\if@tblr\@tblrtrue%
\DeclareOption{nontblr}{\@tblrfalse}%
\DeclareOption{notblr}{\@tblrfalse}%
\newif\if@multicol\@multicoltrue%
\DeclareOption{nonmulticol}{\@multicolfalse}%
\DeclareOption{nomulticol}{\@multicolfalse}%
\newif\if@xcolor\@xcolortrue%
\DeclareOption{nonxcolor}{\@xcolorfalse}%
\DeclareOption{noxcolor}{\@xcolorfalse}%
\newif\if@fa\@fatrue%
\DeclareOption{nonfa}{\@fafalse}%
\DeclareOption{nofa}{\@fafalse}%
\newif\if@pastableur\@pastableurfalse%
\DeclareOption{pastableur}{\@pastableurtrue}%
\DeclareOption*{}
\ProcessOptions\relax

%====PACKAGES UTILES À CHARGER
\if@xcolor
	\RequirePackage{xcolor}
\fi
\if@fa
	\RequirePackage{fontawesome5}
\fi
\if@enum
	\RequirePackage{enumitem}
\fi
\if@tblr
	\RequirePackage{tabularray}
\fi
\if@multicol
	\RequirePackage{multicol}
\fi
\RequirePackage{xintexpr}
\RequirePackage{randomlist}
\RequirePackage{simplekv}
\RequirePackage{xstring}
\RequirePackage{listofitems}
\RequirePackage{calc}
\RequirePackage{tikz}
\usetikzlibrary{decorations.pathmorphing,positioning,shapes.misc,calc}
\usetikzlibrary{babel}
\RequirePackage{tcolorbox}
\RequirePackage{varwidth}
\tcbuselibrary{skins}

%%----COMMANDES FR

%====DECALER VERTICALEMENT, pas documenté pour le moment...
\NewDocumentCommand\VCentrer{ O{-0.5} m }{%
	{\raisebox{#1\depth}{#2\vphantom{azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN0123456789}}}%
}

%====QCMs
\defKV[reponsesqcm]{%
	NbCols=\def\RepQCMNbCol{#1},%
	PoliceLabels=\def\RepQCMFonte{#1},%
	EspacesCL=\def\RepQCMOffset{#1},%
	Labels=\def\RepQCMTypeLabel{#1},%
	EspaceLabels=\xdef\RepQCMSpace{#1},%
	Largeur=\def\RepQCMLarg{#1}
}

\setKVdefault[reponsesqcm]{%
	EspacesCL={6pt/2pt},%
	NbCols=4,%
	Filets=false,%
	PoliceLabels={\bfseries},%
	Labels={a.},%
	EspaceLabels=\kern5pt,%
	Swap=false,%
	Largeur=0.99\linewidth
}

\NewDocumentCommand\QCMFormatteLabel{ m m }{%1=typelabel,%3=caractère
	\IfSubStr{#1}{a}%
		{%
			{\RepQCMFonte\StrSubstitute{#1}{a}{#2}}%
		}%
		{}%
	\IfSubStr{#1}{A}%
		{%
			{\RepQCMFonte\StrSubstitute{#1}{A}{#2}}%
		}%
		{}%
	\IfSubStr{#1}{1}%
		{%
			{\RepQCMFonte\StrSubstitute{#1}{1}{#2}}%
		}%
		{}%
}

\NewDocumentCommand\ReponsesQCM{ O{} m D<>{} }{%1=nbcol,2=listeréponses
	\restoreKV[reponsesqcm]%
	\setKV[reponsesqcm]{#1}%
	\IfSubStr{\RepQCMOffset}{/}%
		{\StrCut{\RepQCMOffset}{/}{\RepQCMOffsetCol}{\RepQCMOffsetLgn}}%
		{\def\RepQCMOffsetCol{\RepQCMOffset}\def\RepQCMOffsetLgn{\RepQCMOffset}}%
	\setsepchar{§}%
	\readlist*\QCMListereponses{#2}%
	\def\QCMNbRep{\QCMListereponseslen}%
	%les items créés
	\IfSubStr{\RepQCMTypeLabel}{a}%
		{%
			\xdef\RepQCMLabelA{\QCMFormatteLabel{\RepQCMTypeLabel}{a}\RepQCMSpace}%
			\xdef\RepQCMLabelB{\QCMFormatteLabel{\RepQCMTypeLabel}{b}\RepQCMSpace}%
			\xdef\RepQCMLabelC{\QCMFormatteLabel{\RepQCMTypeLabel}{c}\RepQCMSpace}%
			\xdef\RepQCMLabelD{\QCMFormatteLabel{\RepQCMTypeLabel}{d}\RepQCMSpace}%
		}{}%
	\IfSubStr{\RepQCMTypeLabel}{A}%
		{%
			\xdef\RepQCMLabelA{\QCMFormatteLabel{\RepQCMTypeLabel}{A}\RepQCMSpace}%
			\xdef\RepQCMLabelB{\QCMFormatteLabel{\RepQCMTypeLabel}{B}\RepQCMSpace}%
			\xdef\RepQCMLabelC{\QCMFormatteLabel{\RepQCMTypeLabel}{C}\RepQCMSpace}%
			\xdef\RepQCMLabelD{\QCMFormatteLabel{\RepQCMTypeLabel}{D}\RepQCMSpace}%
		}{}%
	\IfSubStr{\RepQCMTypeLabel}{1}%
		{%
			\xdef\RepQCMLabelA{\QCMFormatteLabel{\RepQCMTypeLabel}{1}\RepQCMSpace}%
			\xdef\RepQCMLabelB{\QCMFormatteLabel{\RepQCMTypeLabel}{2}\RepQCMSpace}%
			\xdef\RepQCMLabelC{\QCMFormatteLabel{\RepQCMTypeLabel}{3}\RepQCMSpace}%
			\xdef\RepQCMLabelD{\QCMFormatteLabel{\RepQCMTypeLabel}{4}\RepQCMSpace}%
		}{}%
	%en fonction du nb de colonnes
	\IfEq{\QCMNbRep}{2}%2réponses
		{%
			\ifboolKV[reponsesqcm]{Filets}%
				{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,hlines,vlines,width=\RepQCMLarg,colspec={*{2}{X[b,l]}},#3}}%
				{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,width=\RepQCMLarg,colspec={*{2}{X[b,l]}},#3}}%
				\RepQCMLabelA\QCMListereponses[1] & \RepQCMLabelB\QCMListereponses[2] \\
			\end{tblr}%
		}%
		{}%
	\IfEq{\QCMNbRep}{3}%3réponses
		{%
			\ifboolKV[reponsesqcm]{Filets}%
				{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,hlines,vlines,width=\RepQCMLarg,colspec={*{3}{X[b,l]}},#3}}%
				{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,width=\RepQCMLarg,colspec={*{3}{X[b,l]}},#3}}%
				\RepQCMLabelA\QCMListereponses[1] & \RepQCMLabelB\QCMListereponses[2] & \RepQCMLabelC\QCMListereponses[3] \\
			\end{tblr}%
		}%
		{}%
	\IfEq{\QCMNbRep}{4}%4réponses
		{%
			\IfEq{\RepQCMNbCol}{4}%4colonnes
				{%
					\ifboolKV[reponsesqcm]{Filets}%
						{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,hlines,vlines,width=\RepQCMLarg,colspec={*{4}{X[b,l]}},#3}}%
						{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,width=\RepQCMLarg,colspec={*{4}{X[b,l]}},#3}}%
						\RepQCMLabelA\QCMListereponses[1] & \RepQCMLabelB\QCMListereponses[2] & \RepQCMLabelC\QCMListereponses[3] & \RepQCMLabelD\QCMListereponses[4] \\
					\end{tblr}%
				}%
				{%
					\ifboolKV[reponsesqcm]{Filets}%
						{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,hlines,vlines,width=\RepQCMLarg,colspec={*{2}{X[b,l]}},#3}}%
						{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,width=\RepQCMLarg,colspec={*{2}{X[b,l]}},#3}}%
						\RepQCMLabelA\QCMListereponses[1] & \ifboolKV[reponsesqcm]{Swap}{\RepQCMLabelB\QCMListereponses[2]}{\RepQCMLabelC\QCMListereponses[3]} \\
						\ifboolKV[reponsesqcm]{Swap}{\RepQCMLabelC\QCMListereponses[3]}{\RepQCMLabelB\QCMListereponses[2]} & \RepQCMLabelD\QCMListereponses[4] \\
					\end{tblr}%
				}%
		}%
		{}%
}

%====CENTRAGE
\newlength{\centeraltbef}%avant
\newlength{\centeraltbeh}%après

\defKV[myaltcenter]{Avant=\setlength{\centeraltbef}{#1},Apres=\setlength{\centeraltbeh}{#1}}
\setKVdefault[myaltcenter]{Avant=0.33\baselineskip,Apres=0.33\baselineskip}

\NewDocumentEnvironment{Centrage}{ O{} }%
	{\restoreKV[myaltcenter]\setKV[myaltcenter]{#1}\par\kern\centeraltbef\centering}%
	{\par\kern\centeraltbeh}

%====MULTICOLS
\NewDocumentCommand\CoeffEspaceMulticols{ O{1} }{%
	\setlength{\multicolsep}{12pt plus 4pt minus 3pt}%
	\IfStrEq{#1}{1.25}{\setlength{\multicolsep}{15pt plus 5pt minus 3.75pt}}{}% 125% of orig. values
	\IfStrEq{#1}{0.75}{\setlength{\multicolsep}{9pt plus 3pt minus 2.25pt}}{}% 75% of orig. values
	\IfStrEq{#1}{0.66}{\setlength{\multicolsep}{8pt plus 2.67pt minus 2pt}}{}% 66% of orig. values
	\IfStrEq{#1}{0.50}{\setlength{\multicolsep}{6pt plus 2pt minus 1.5pt}}{}% 50% of orig. values
	\IfStrEq{#1}{0.33}{\setlength{\multicolsep}{4pt plus 1.33pt minus 1pt}}{}% 33% of orig. values
	\IfStrEq{#1}{0.25}{\setlength{\multicolsep}{3pt plus 1pt minus 0.75pt}}{}% 25% of orig. values
	\IfStrEq{#1}{0}{\setlength{\multicolsep}{0pt}}{}% 0% of orig. values
}

\setKVdefault[multicolsperso]{%
	Type=texte,%
	CoeffEspVert=0.50,%
	EpTrait=0pt
}

\NewDocumentEnvironment{MultiCols}{ O{} r() D<>{} }%
{%
	\useKVdefault[multicolsperso]%
	\setKV[multicolsperso]{#1}%
	\CoeffEspaceMulticols[\useKV[multicolsperso]{CoeffEspVert}]%
	\setlength{\columnseprule}{\useKV[multicolsperso]{EpTrait}}%
	\begin{multicols}{#2}%
	\IfStrEq{\useKV[multicolsperso]{Type}}{enum}{\begin{enumerate}[#3]}{}%
	\IfStrEq{\useKV[multicolsperso]{Type}}{item}{\begin{itemize}[#3]}{}%
}%
{%
	\IfStrEq{\useKV[multicolsperso]{Type}}{enum}{\end{enumerate}}{}%
	\IfStrEq{\useKV[multicolsperso]{Type}}{item}{\end{itemize}}{}%
	\end{multicols}%
	\CoeffEspaceMulticols[1]%
	\setlength{\columnseprule}{0pt}%
}

%====ITEMCHOICE
\NewDocumentCommand\CreerListeItems{ m m m }{%1=liste,%2=macro,3=nomliste
	\@ifIsList{#3}%
		{La liste \texttt{#3} existe déjà, svp choisir un autre nom.}%
		{\xdef#2{#1}\NewList{#3}}%
}

\defKV[itemchoisir]{%
	Type=\def\ChoixTypeSerie{#1}
}
\setKVdefault[itemchoisir]{%
	Alea=false,%
	Type=enum
}

\NewDocumentCommand\ListeChoixItems{ O{} m m r() D<>{} }{%1=options,2=série des items,3=nomsérie,4=liste choix,5=options enum
	%on teste si la liste considérée existe...
	\@ifIsList{#3}%
		{%
			\restoreKV[itemchoisir]%
			\setKV[itemchoisir]{#1}%
			\ClearList{#3}%
			%création de la liste
			\ifboolKV[itemchoisir]{Alea}%
				{%
					\xintFor* ##1 in {\xintCSVtoList{#2}}\do{\InsertRandomItem{#3}{##1}}
				}%
				{%
					\xintFor* ##1 in {\xintCSVtoList{#2}}\do{\InsertLastItem{#3}{##1}}
				}%
			%création de l'environnement
			\IfStrEq{\ChoixTypeSerie}{enum}%
				{\begin{enumerate}[#5]}{}%
			\IfStrEq{\ChoixTypeSerie}{item}%
				{\begin{itemize}[#5]}{}%
			\IfSubStr{\ChoixTypeSerie}{MultiCols}%
				{%
					\StrBetween[1,2]{\ChoixTypeSerie}{/}{/}[\ChoixTypeMulticols]%
					\StrBehind[2]{\ChoixTypeSerie}{/}[\NbMulticols]%
					\begin{MultiCols}[Type=\ChoixTypeMulticols](\NbMulticols)<#5>%
				}{}%
			%items choisis
			\ifboolKV[itemchoisir]{Alea}%
				{%
					\xintFor* ##1 in {\xintSeq{0}{\xinteval{#4-1}}}\do{\GetItem{#3}{##1}{ItemChoisi}\item \ItemChoisi}
				}%
				{%
					\xintFor* ##1 in {\xintCSVtoList{#4}}\do{\GetItem{#3}{\xinteval{##1-1}}{ItemChoisi}\item \ItemChoisi}
				}
			%fin de l'environnement
			\IfStrEq{\ChoixTypeSerie}{enum}%
				{\end{enumerate}}{}
			\IfStrEq{\ChoixTypeSerie}{item}
				{\end{itemize}}{}%
			\IfSubStr{\ChoixTypeSerie}{MultiCols}%
				{\end{MultiCols}}{}%
		}%
		{%
			La liste \texttt{#3} n'existe pas, veuillez la créer avec la macro \texttt{\textbackslash CreerListeItems}.%
		}%
}

%====TABLEAU DE COMPÉTENCES
%patch fa vcenter
\NewDocumentCommand{\vcenterfa}{ O{} m }{$\vcenter{\hbox{\faIcon[#1]{#2}}}$}

%labelnote
\def\LabelNoteComp{Note}
%listeniveaux
\def\LstDeuxNiv{NA § A}
\def\LstTroisNiv{NA § ECA § A}
\def\LstQuatreNiv{NA § PA § ECA § A}
%noticeniveaux
\def\NoticeDeuxNiv{Non acquis § Acquis}
\def\NoticeTroisNiv{Non acquis § En cours d'acquis. § Acquis}
\def\NoticeQuatreNiv{Non acquis § Part. acquis § En cours d'acquis. § Acquis}
%nivparbatteries
\def\DeuxNivBatterie{\vcenterfa[solid]{battery-quarter} § \vcenterfa[solid]{battery-full}}
\def\TroisNivBatterie{\vcenterfa[solid]{battery-quarter} § \vcenterfa[solid]{battery-half} § \vcenterfa[solid]{battery-full}}
\def\QuatreNivBatterie{\vcenterfa[solid]{battery-empty} § \vcenterfa[solid]{battery-quarter} § \vcenterfa[solid]{battery-half} § \vcenterfa[solid]{battery-full}}
%nivparsmileys
\def\DeuxNivSmiley{\vcenterfa[regular]{angry} § \vcenterfa[regular]{smile}}
\def\TroisNivSmiley{\vcenterfa[regular]{angry} § \vcenterfa[regular]{frown} § \vcenterfa[regular]{smile}}
\def\QuatreNivSmiley{\vcenterfa[regular]{angry} § \vcenterfa[regular]{frown} § \vcenterfa[regular]{smile} § \vcenterfa[regular]{grin}}

% ========================tableau compétences
\defKV[tblcomp]{%
	Largeur=\def\COMPETlargeur{#1},%
	LargeurNivs=\def\COMPETlargeurs{#1},%
	Niveaux=\def\COMPETniveaux{#1},%
	NoticeNiveaux=\def\COMPETnoticeniveaux{#1},%
	Titre=\def\COMPETtitre{#1},%
	PolTitre=\def\COMPETlegende{#1},%
	PolComp=\def\COMPETcomp{#1},%
	PolNotice=\def\COMPETnotice{#1},%
	LigneSep=\def\COMPETsep{#1}
}

\setKVdefault[tblcomp]{%
	Largeur=0.95\linewidth,%
	LargeurNivs={0.75cm § 1.25cm},%niv + note
	Niveaux={NA § ECA § A},%
	NoticeNiveaux={Non acquis § En cours d'acquisition § Acquis},%
	Titre=DS01,%
	PolTitre=\small\sffamily\bfseries,%
	PolNotice=\small\sffamily\bfseries,%
	PolComp=\small\sffamily,%
	LigneSep=2pt,%
	CouleurNotice=black,%
	CouleurNiveaux=black,%
	CouleurFond=lightgray!25,%
	Note=true,%
	Notice=true
}

%pour créer le body du tableau (j'ai encore du mal avec ça...)
\long\def\tblcompaddto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}

\NewDocumentCommand{\TableauCompetences}{ O{} m }{%1=options,2=liste compétences
	\useKVdefault[tblcomp]%
	\setKV[tblcomp]{#1}% on paramètres les nouvelles clés et on les simplifie
	\setsepchar{§}%
	\readlist*\ListeCompetences{#2}%
	\readlist*\ListeNiveaux{\COMPETniveaux}%
	\readlist*\ListeLargeurs{\COMPETlargeurs}%
	\readlist*\ListeNoticeNiveaux{\COMPETnoticeniveaux}%
	\def\CPtabledatacomp{}%
	\xintifboolexpr{\ListeNiveauxlen == 2}%avec 3 niveaux de compétences
		{%
			\ifboolKV[tblcomp]{Note}%
				{%
					\tblcompaddto\CPtabledatacomp{\COMPETtitre & \ListeNiveaux[1] & \ListeNiveaux[2] & \LabelNoteComp \\}%
					\xintFor* ##1 in {\xintSeq{1}{\ListeCompetenceslen}}\do{%
						\tblcompaddto\CPtabledatacomp{\ListeCompetences[\the\numexpr\therownum-1\relax] & & & \\}%
					}%
					\ifboolKV[tblcomp]{Notice}%
						{%
							\tblcompaddto\CPtabledatacomp{{\ListeNiveaux[1]} : {\ListeNoticeNiveaux[1]} / {\ListeNiveaux[2]} : {\ListeNoticeNiveaux[2]} & & & \\}
							%creation du tableau note+notice
							\begin{tblr}[expand=\CPtabledatacomp]%
								{%
									width={\COMPETlargeur},%
									hlines,vlines,colspec={X[l,b]*{2}{Q[c,b,\ListeLargeurs[1]]}Q[c,b,\ListeLargeurs[2]]},%
									rowsep=\COMPETsep,%
									row{1}={font=\COMPETlegende,fg=\useKV[tblcomp]{CouleurNiveaux},bg=\useKV[tblcomp]{CouleurFond}},%
									row{2-Y}={font=\COMPETcomp},%
									row{Z}={font=\COMPETnotice,fg=\useKV[tblcomp]{CouleurNotice}},%
									cell{2}{Z}={r=\the\numexpr\ListeCompetenceslen+1\relax}{},%
									cell{Z}{1}={c=3}{}
								}%
								\CPtabledatacomp
							\end{tblr}%
						}%
						{%
							%creation du tableau note-notice
							\begin{tblr}[expand=\CPtabledatacomp]%
								{%
									width={\COMPETlargeur},%
									hlines,vlines,colspec={X[l,b]*{2}{Q[c,b,\ListeLargeurs[1]]}Q[c,b,\ListeLargeurs[2]]},%
									rowsep=\COMPETsep,%
									row{1}={font=\COMPETlegende,fg=\useKV[tblcomp]{CouleurNiveaux},bg=\useKV[tblcomp]{CouleurFond}},%
									row{2-Z}={font=\COMPETcomp},%
									cell{2}{Z}={r=\the\numexpr\ListeCompetenceslen\relax}{}
								}%
								\CPtabledatacomp
							\end{tblr}%
						}%
				}%
				{%
					\tblcompaddto\CPtabledatacomp{\COMPETtitre & \ListeNiveaux[1] & \ListeNiveaux[2] \\}%
					\xintFor* ##1 in {\xintSeq{1}{\ListeCompetenceslen}}\do{%
						\tblcompaddto\CPtabledatacomp{\ListeCompetences[\the\numexpr\therownum-1\relax] & & \\}%
					}%
					\ifboolKV[tblcomp]{Notice}%
						{%
							\tblcompaddto\CPtabledatacomp{{\ListeNiveaux[1]} : {\ListeNoticeNiveaux[1]} / {\ListeNiveaux[2]} : {\ListeNoticeNiveaux[2]} & & \\}
							%creation du tableau -note+notice
							\begin{tblr}[expand=\CPtabledatacomp]%
								{%
									width={\COMPETlargeur},%
									hlines,vlines,colspec={X[l,b]*{2}{Q[c,b,\ListeLargeurs[1]]}},%
									rowsep=\COMPETsep,%
									row{1}={font=\COMPETlegende,fg=\useKV[tblcomp]{CouleurNiveaux},bg=\useKV[tblcomp]{CouleurFond}},%
									row{2-Y}={font=\COMPETcomp},%
									row{Z}={font=\COMPETnotice,fg=\useKV[tblcomp]{CouleurNotice}},%
									cell{Z}{1}={c=3}{}
								}%
								\CPtabledatacomp
							\end{tblr}%
						}%
						{%
							%creation du tableau -note-notice
							\begin{tblr}[expand=\CPtabledatacomp]%
								{%
									width={\COMPETlargeur},%
									hlines,vlines,colspec={X[l,b]*{2}{Q[c,b,\ListeLargeurs[1]]}},%
									rowsep=\COMPETsep,%
									row{1}={font=\COMPETlegende,fg=\useKV[tblcomp]{CouleurNiveaux},bg=\useKV[tblcomp]{CouleurFond}},%
									row{2-Z}={font=\COMPETcomp}
								}%
								\CPtabledatacomp
							\end{tblr}%
						}%
				}%
		}%
		{}%
	\xintifboolexpr{\ListeNiveauxlen == 3}%avec 3 niveaux de compétences
		{%
			\ifboolKV[tblcomp]{Note}%
				{%
					\tblcompaddto\CPtabledatacomp{\COMPETtitre & \ListeNiveaux[1] & \ListeNiveaux[2] & \ListeNiveaux[3] & \LabelNoteComp \\}%
					\xintFor* ##1 in {\xintSeq{1}{\ListeCompetenceslen}}\do{%
						\tblcompaddto\CPtabledatacomp{\ListeCompetences[\the\numexpr\therownum-1\relax] & & & & \\}%
					}%
					\ifboolKV[tblcomp]{Notice}%
						{%
							\tblcompaddto\CPtabledatacomp{{\ListeNiveaux[1]} : {\ListeNoticeNiveaux[1]} / {\ListeNiveaux[2]} : {\ListeNoticeNiveaux[2]} / {\ListeNiveaux[3]} : {\ListeNoticeNiveaux[3]} & & & & \\}
							%creation du tableau note+notice
							\begin{tblr}[expand=\CPtabledatacomp]%
								{%
									width={\COMPETlargeur},%
									hlines,vlines,colspec={X[l,b]*{3}{Q[c,b,\ListeLargeurs[1]]}Q[c,b,\ListeLargeurs[2]]},%
									rowsep=\COMPETsep,%
									row{1}={font=\COMPETlegende,fg=\useKV[tblcomp]{CouleurNiveaux},bg=\useKV[tblcomp]{CouleurFond}},%
									row{2-Y}={font=\COMPETcomp},%
									row{Z}={font=\COMPETnotice,fg=\useKV[tblcomp]{CouleurNotice}},%
									cell{2}{Z}={r=\the\numexpr\ListeCompetenceslen+1\relax}{},%
									cell{Z}{1}={c=4}{}
								}%
								\CPtabledatacomp
							\end{tblr}%
						}%
						{%
							%creation du tableau note-notice
							\begin{tblr}[expand=\CPtabledatacomp]%
								{%
									width={\COMPETlargeur},%
									hlines,vlines,colspec={X[l,b]*{3}{Q[c,b,\ListeLargeurs[1]]}Q[c,b,\ListeLargeurs[2]]},%
									rowsep=\COMPETsep,%
									row{1}={font=\COMPETlegende,fg=\useKV[tblcomp]{CouleurNiveaux},bg=\useKV[tblcomp]{CouleurFond}},%
									row{2-Z}={font=\COMPETcomp},%
									cell{2}{Z}={r=\the\numexpr\ListeCompetenceslen\relax}{}
								}%
								\CPtabledatacomp
							\end{tblr}%
						}%
				}%
				{%
					\tblcompaddto\CPtabledatacomp{\COMPETtitre & \ListeNiveaux[1] & \ListeNiveaux[2] & \ListeNiveaux[3] \\}%
					\xintFor* ##1 in {\xintSeq{1}{\ListeCompetenceslen}}\do{%
						\tblcompaddto\CPtabledatacomp{\ListeCompetences[\the\numexpr\therownum-1\relax] & & & \\}%
					}%
					\ifboolKV[tblcomp]{Notice}%
						{%
							\tblcompaddto\CPtabledatacomp{{\ListeNiveaux[1]} : {\ListeNoticeNiveaux[1]} / {\ListeNiveaux[2]} : {\ListeNoticeNiveaux[2]} / {\ListeNiveaux[3]} : {\ListeNoticeNiveaux[3]} & & & \\}
							%creation du tableau -note+notice
							\begin{tblr}[expand=\CPtabledatacomp]%
								{%
									width={\COMPETlargeur},%
									hlines,vlines,colspec={X[l,b]*{3}{Q[c,b,\ListeLargeurs[1]]}},%
									rowsep=\COMPETsep,%
									row{1}={font=\COMPETlegende,fg=\useKV[tblcomp]{CouleurNiveaux},bg=\useKV[tblcomp]{CouleurFond}},%
									row{2-Y}={font=\COMPETcomp},%
									row{Z}={font=\COMPETnotice,fg=\useKV[tblcomp]{CouleurNotice}},%
									cell{Z}{1}={c=4}{}
								}%
								\CPtabledatacomp
							\end{tblr}%
						}%
						{%
							%creation du tableau -note-notice
							\begin{tblr}[expand=\CPtabledatacomp]%
								{%
									width={\COMPETlargeur},%
									hlines,vlines,colspec={X[l,b]*{3}{Q[c,b,\ListeLargeurs[1]]}},%
									rowsep=\COMPETsep,%
									row{1}={font=\COMPETlegende,fg=\useKV[tblcomp]{CouleurNiveaux},bg=\useKV[tblcomp]{CouleurFond}},%
									row{2-Z}={font=\COMPETcomp}
								}%
								\CPtabledatacomp
							\end{tblr}%
						}%
				}%
		}%
		{}%
	\xintifboolexpr{\ListeNiveauxlen == 4}%maintenant avec 4 niveaux de compétences
		{%
			\ifboolKV[tblcomp]{Note}%
			{%
				\tblcompaddto\CPtabledatacomp{\COMPETtitre & \ListeNiveaux[1] & \ListeNiveaux[2] & \ListeNiveaux[3] & \ListeNiveaux[4] & \LabelNoteComp \\}%
				\xintFor* ##1 in {\xintSeq{1}{\ListeCompetenceslen}}\do{%
					\tblcompaddto\CPtabledatacomp{\ListeCompetences[\the\numexpr\therownum-1\relax] & & & & & \\}%
				}%
				\ifboolKV[tblcomp]{Notice}%
				{%
					\tblcompaddto\CPtabledatacomp{{\ListeNiveaux[1]} : {\ListeNoticeNiveaux[1]} / {\ListeNiveaux[2]} : {\ListeNoticeNiveaux[2]} / {\ListeNiveaux[3]} : {\ListeNoticeNiveaux[3]} / {\ListeNiveaux[4]} : {\ListeNoticeNiveaux[4]} & & & & & \\}
					%creation du tableau note+notice
					\begin{tblr}[expand=\CPtabledatacomp]%
						{%
							width={\COMPETlargeur},%
							hlines,vlines,colspec={X[l,b]*{4}{Q[c,b,\ListeLargeurs[1]]}Q[c,b,\ListeLargeurs[2]]},%
							rowsep=\COMPETsep,%
							row{1}={font=\COMPETlegende,fg=\useKV[tblcomp]{CouleurNiveaux},bg=\useKV[tblcomp]{CouleurFond}},%
							row{2-Y}={font=\COMPETcomp},%
							row{Z}={font=\COMPETnotice,fg=\useKV[tblcomp]{CouleurNotice}},%
							cell{2}{Z}={r=\the\numexpr\ListeCompetenceslen+1\relax}{},%
							cell{Z}{1}={c=5}{}
						}%
						\CPtabledatacomp
					\end{tblr}%
				}%
				{%
					%creation du tableau note-notice
					\begin{tblr}[expand=\CPtabledatacomp]%
						{%
							width={\COMPETlargeur},%
							hlines,vlines,colspec={X[l,b]*{4}{Q[c,b,\ListeLargeurs[1]]}Q[c,b,\ListeLargeurs[2]]},%
							rowsep=\COMPETsep,%
							row{1}={font=\COMPETlegende,fg=\useKV[tblcomp]{CouleurNiveaux},bg=\useKV[tblcomp]{CouleurFond}},%
							row{2-Z}={font=\COMPETcomp},%
							cell{2}{Z}={r=\the\numexpr\ListeCompetenceslen\relax}{}
						}%
						\CPtabledatacomp
					\end{tblr}%
				}%
			}%
			{%
				\tblcompaddto\CPtabledatacomp{\COMPETtitre & \ListeNiveaux[1] & \ListeNiveaux[2] & \ListeNiveaux[3] & \ListeNiveaux[4] \\}%
				\xintFor* ##1 in {\xintSeq{1}{\ListeCompetenceslen}}\do{%
					\tblcompaddto\CPtabledatacomp{\ListeCompetences[\the\numexpr\therownum-1\relax] & & & & \\}%
				}%
				\ifboolKV[tblcomp]{Notice}%
				{%
					\tblcompaddto\CPtabledatacomp{{\ListeNiveaux[1]} : {\ListeNoticeNiveaux[1]} / {\ListeNiveaux[2]} : {\ListeNoticeNiveaux[2]} / {\ListeNiveaux[3]} : {\ListeNoticeNiveaux[3]} / {\ListeNiveaux[4]} : {\ListeNoticeNiveaux[4]} & & & & \\}
					%creation du tableau -note+notice
					\begin{tblr}[expand=\CPtabledatacomp]%
						{%
							width={\COMPETlargeur},%
							hlines,vlines,colspec={X[l,b]*{4}{Q[c,b,\ListeLargeurs[1]]}},%
							rowsep=\COMPETsep,%
							row{1}={font=\COMPETlegende,fg=\useKV[tblcomp]{CouleurNiveaux},bg=\useKV[tblcomp]{CouleurFond}},%
							row{2-Y}={font=\COMPETcomp},%
							row{Z}={font=\COMPETnotice,fg=\useKV[tblcomp]{CouleurNotice}},%
							cell{Z}{1}={c=5}{}
						}%
						\CPtabledatacomp
					\end{tblr}%
				}%
				{%
					%creation du tableau -note-notice
					\begin{tblr}[expand=\CPtabledatacomp]%
						{%
							width={\COMPETlargeur},%
							hlines,vlines,colspec={X[l,b]*{4}{Q[c,b,\ListeLargeurs[1]]}},%
							rowsep=\COMPETsep,%
							row{1}={font=\COMPETlegende,fg=\useKV[tblcomp]{CouleurNiveaux},bg=\useKV[tblcomp]{CouleurFond}},%
							row{2-Z}={font=\COMPETcomp}
						}%
						\CPtabledatacomp
					\end{tblr}%
				}%
			}%
		}%
		{}%
}

%====PENSKILLS
\defKV[tachescrayon]{%
	PoliceCateg=\def\pentaksfontcateg{#1},%
	PoliceBloc=\def\pentaksfontblock{#1},%
	Couleurs=\def\pentakscolors{#1},%
	LargeurBloc=\def\pentakswidth{#1},
	Echelle=\def\pentakscale{#1}
}
\setKVdefault[tachescrayon]{%
	PoliceCateg=\bfseries\sffamily,%
	PoliceBloc=\small\ttfamily,%
	%Couleurs={"yellow/black","orange/black","magenta/black","cyan/black","teal/black","brown/black"},%
	Couleurs={yellow/black,orange/black,magenta/black,cyan/black,teal/black,brown/black},%
	LargeurBloc=5cm,%
	Echelle=1,%
	NoirBlanc=false
}

\NewDocumentCommand\CrayonDeCompetences{ O{} D<>{} m }{%
	\restoreKV[tachescrayon]%
	\setKV[tachescrayon]{#1}%
	%liste des couleurs, via listofitems ?
	\readlist*\lstColors{\pentakscolors}%
	%\edef\lstColors{\pentakscolors}%
	\begin{tikzpicture}%
		[line width=0.25\pgflinewidth,scale=\pentakscale,transform shape,#2,pics/fancy box/.style={code={%
			\path (0,0) coordinate (C0);
			\foreach \Item/\Text [count=\Count starting from 0] in {#3}
			{%
				\ifboolKV[tachescrayon]{NoirBlanc}%
					{%
						\def\mybackcolor{gray}\def\myfontcolor{black}
					}%
					{%
						\itemtomacro\lstColors[\the\numexpr\Count+1\relax]\mycolor
						\IfSubStr{\mycolor}{/}%
							{%
								\StrCut{\mycolor}{/}{\mybackcolor}{\myfontcolor}%
							}%
							{%
								\def\mybackcolor{\mycolor}\def\myfontcolor{black}%
							}%
					}%
				\node[rounded rectangle,rounded rectangle left arc=none,draw=\mybackcolor,fill=\mybackcolor,anchor=north west,font=\pentaksfontcateg,text=\myfontcolor,outer sep=0pt,inner sep=0.75ex]  (RR\Count) at (C\Count) {\vphantom{pL}\Item};
				\node[line width={\pentakscale*3\pgflinewidth},anchor=north west,below right={\pentakscale*1ex} of RR\Count.south west,draw,text width=\pentakswidth,font=\pentaksfontblock,inner sep=0.75ex] (T\Count) {\Text};
				\coordinate[below left={\pentakscale*1ex} of T\Count.south west] (C\the\numexpr\Count+1\relax);
				\filldraw[\mybackcolor] ([xshift=-1ex]C\Count) rectangle (C\the\numexpr\Count+1\relax);
				\filldraw[\mybackcolor] ([xshift=-3ex]C\Count) rectangle ([xshift=-2ex]C\the\numexpr\Count+1\relax);
				\filldraw[\mybackcolor!50!white] ([xshift=-2ex]C\Count) rectangle ([xshift=-1ex]C\the\numexpr\Count+1\relax);
				\ifnum\Count=0
					\shade[ball color=\mybackcolor!75] ([shift={(-3ex-\pentakscale*0.5\pgflinewidth,\pentakscale*0.5\pgflinewidth)}]C\Count) to[out=90,in=90]++(3ex+\pentakscale*\pgflinewidth,0) ;
				\fi
				\xdef\myCount{\Count}%last index
				}
			\ifboolKV[tachescrayon]{NoirBlanc}%
				{%
					\def\mylastbackcolor{gray}
					\filldraw[lightgray!15] ([xshift=-3ex]C\the\numexpr\myCount+1\relax) --++ (0,-0.25ex) --++ (1.5ex,-4ex) coordinate[pos=0.8] (aux1) coordinate[pos=1] (aux2) -- ($(C\the\numexpr\myCount+1\relax)+(0,-0.25ex)$) coordinate[pos=0.2] (aux3) --++ (0,0.25ex) -- cycle ;
				}%
				{%
					\itemtomacro\lstColors[\the\numexpr\myCount+1\relax]\mylastcolor
					\IfSubStr{\mylastcolor}{/}%
						{%
							\StrBefore{\mylastcolor}{/}[\mylastbackcolor]%
						}%
						{%
							\def\mylastbackcolor{\mylastcolor}%
						}%
					\filldraw[brown!10] ([xshift=-3ex]C\the\numexpr\myCount+1\relax) --++ (0,-0.25ex) --++ (1.5ex,-4ex) coordinate[pos=0.8] (aux1) coordinate[pos=1] (aux2) -- ($(C\the\numexpr\myCount+1\relax)+(0,-0.25ex)$) coordinate[pos=0.2] (aux3) --++ (0,0.25ex) -- cycle ;
				}%
			\filldraw[\mylastbackcolor] ([shift={(-3ex,3\pgflinewidth)}]C\the\numexpr\myCount+1\relax) to[out=-90,in=180]++ (0.5ex-0.5\pgflinewidth,-0.5ex) to[out=0,in=-90]++ (0.5ex-0.5\pgflinewidth,0.5ex) -- cycle ;
			\filldraw[\mylastbackcolor] ([shift={(-1ex+\pgflinewidth,3\pgflinewidth)}]C\the\numexpr\myCount+1\relax) to[out=-90,in=180]++ (0.5ex-0.5\pgflinewidth,-0.5ex) to[out=0,in=-90]++ (0.5ex-0.5\pgflinewidth,0.5ex) -- cycle ;
			\filldraw[\mylastbackcolor!50!white] ([shift={(-2ex,3\pgflinewidth)}]C\the\numexpr\myCount+1\relax) to[out=-90,in=180]++ (0.5ex,-0.5ex) to[out=0,in=-90]++ (0.5ex,0.5ex) -- cycle ;
			\filldraw[line join=cap,gray,fill=gray] (aux1) -- (aux2) -- (aux3);
		}}]
		\pic{fancy box={#2}};
	\end{tikzpicture}%
}

%====EXERCICE PERSO

\newcounter{numeroexo}
\setcounter{numeroexo}{0}
\newlength{\eptraitexo}
\setlength{\eptraitexo}{1.1pt}
\newlength{\eptraitexospace}
\setlength{\eptraitexospace}{1.5\eptraitexo}
\newlength{\tmp@image@hauteur@totale}
\newlength{\tmp@image@profondeur}

\colorlet{macouleurexo}{blue!50!black}

\newcommand\tmpstyleexo{\bfseries\LARGE\sffamily}%
\newcommand\tmplabelexo{Exercice~}%

\defKV[globalstyleexo]{%
	Libelle=\renewcommand\tmplabelexo{#1},%
	Couleur=\colorlet{macouleurexo}{#1},%
	Police=\renewcommand\tmpstyleexo{#1},%
	EpTrait=\setlength{\eptraitexo}{#1}
}

\setKVdefault[globalstyleexo]{%
	Libelle={Exercice~},%
	Couleur={blue!50!black},%
	Police={\bfseries\LARGE\sffamily},%
	EpTrait={1.1pt}
}

\NewDocumentCommand\StyleEnvtExo{ O{} }{%
	\restoreKV[globalstyleexo]%
	\setKV[globalstyleexo]{#1}%
}
\NewDocumentCommand\StyleEnvtExoDefaut{ }{%
	\restoreKV[globalstyleexo]%
}

\defKV[EnvtExercice]{%
	Type=\def\EnvtExoType{#1},%
	ComplementTitre=\def\EnvtExoCpltTitre{#1},%
	CodeDebut=\def\EnvtExoCodeAvant{#1},%
	%Couleur=\def\EnvtExoCouleur{#1},%
	EchelleImage=\def\EnvtExoScaleImg{#1},%
	Decoration=\def\EnvtExoDeco{#1},%
	Trait=\def\EnvtExoTrait{#1}
}
\setKVdefault[EnvtExercice]{
	Type=Classique,%
	ComplementTitre={},%
	CodeDebut={},%
	%Couleur=macouleurexo,%
	EchelleImage=1.15,%
	Compteur=true,%
	Decoration={},%
	Trait=plein
}

\NewDocumentEnvironment{EnvtExo}{ !O{} }%
{%
	\useKVdefault[EnvtExercice]%
	\setKV[EnvtExercice]{#1}%
	\addtocounter{numeroexo}{1}%
	\ifboolKV[EnvtExercice]{Compteur}{}{\addtocounter{numeroexo}{-1}}%
	\def\hrulefill{\leavevmode\leaders\hrule height \eptraitexo\hfill\kern\z@}%épaisseur
	\noindent\begingroup\color{macouleurexo}%
	\IfStrEq{\EnvtExoType}{Classique}%OK exo°____vide
		{%
			%label avec numéro et complément
			\tmpstyleexo\tmplabelexo\ifboolKV[EnvtExercice]{Compteur}{\thenumeroexo}{}\EnvtExoCpltTitre%
			%trait éventuel
			\IfStrEqCase{\EnvtExoTrait}{%
				{plein}{\,\hrulefill}%
				{pointilles}{\,\dotfill}%
				{dashilles}{\,\hdashrule{\fill}{\eptraitexo}{\eptraitexospace}}%
				{non}{\hfill}%
			}%
			%décoration éventuelle
			\IfSubStr{\EnvtExoDeco}{Icone}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoIcon]%
					\,\scalebox{0.85}[0.85]{\EnvtExoIcon}%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Ceinture}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoCouleur]%
					\,\CeintureCouleur{\EnvtExoCouleur}%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Chrono}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoChrono]%
					\,\pictochrono[ColTime=macouleurexo!50]{\EnvtExoChrono}%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Points}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoPts]%
					\IfStrEq{\EnvtExoPts}{1}{\def\pts{point}}{\def\pts{points}}%
					\,(\EnvtExoPts\ \pts)%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Image}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoImg]%
					\settototalheight{\tmp@image@hauteur@totale}{\hbox{\tmpstyleexo qB}}%
					\,$\vcenter{\hbox{\includegraphics[height=\EnvtExoScaleImg\tmp@image@hauteur@totale]{\EnvtExoImg}}}$%
				}{}%
		}{}%
	\IfSubStr{\EnvtExoType}{Perso}%OK perso____déco
		{%
			\StrBehind{\EnvtExoType}{/}[\EnvtExoLabel]%
			%label avec numéro et complément
			\tmpstyleexo\EnvtExoLabel\ifboolKV[EnvtExercice]{Compteur}{\thenumeroexo}{}\EnvtExoCpltTitre%
			%trait éventuel
			\IfStrEqCase{\EnvtExoTrait}{%
				{plein}{\,\hrulefill}%
				{pointilles}{\,\dotfill}%
				{dashilles}{\,\hdashrule{\fill}{\eptraitexo}{\eptraitexospace}}%
				{non}{\hfill}%
			}%
			%décoration éventuelle
			\IfSubStr{\EnvtExoDeco}{Icone}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoIcon]%
					\,\scalebox{0.85}[0.85]{\EnvtExoIcon}%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Ceinture}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoCouleur]%
					\,\CeintureCouleur{\EnvtExoCouleur}%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Chrono}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoChrono]%
					\,\pictochrono[ColTime=macouleurexo!50]{\EnvtExoChrono}%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Points}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoPts]%
					\IfStrEq{\EnvtExoPts}{1}{\def\pts{point}}{\def\pts{points}}%
					\,(\EnvtExoPts\ \pts)%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Image}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoImg]%
					\settototalheight{\tmp@image@hauteur@totale}{\hbox{\tmpstyleexo qB}}%
					\,$\vcenter{\hbox{\includegraphics[height=\EnvtExoScaleImg\tmp@image@hauteur@totale]{\EnvtExoImg}}}$%
				}{}%
		}{}%
	\endgroup%
	\def\hrulefill{\leavevmode\leaders\hrule height 0.4pt\hfill\kern\z@}%
	\par%
	\EnvtExoCodeAvant%
}%
{}%

\NewDocumentCommand\TitreExo{ !O{} }{%
	\useKVdefault[EnvtExercice]%
	\setKV[EnvtExercice]{#1}%
	\addtocounter{numeroexo}{1}%
	\ifboolKV[EnvtExercice]{Compteur}{}{\addtocounter{numeroexo}{-1}}%
	\def\hrulefill{\leavevmode\leaders\hrule height \eptraitexo\hfill\kern\z@}%épaisseur
	\noindent\begingroup\color{macouleurexo}%
	\IfStrEq{\EnvtExoType}{Classique}%OK exo°____vide
		{%
			%label avec numéro et complément
			\tmpstyleexo\tmplabelexo\ifboolKV[EnvtExercice]{Compteur}{\thenumeroexo}{}\EnvtExoCpltTitre%
			%trait éventuel
			\IfStrEqCase{\EnvtExoTrait}{%
				{plein}{\,\hrulefill}%
				{pointilles}{\,\dotfill}%
				{dashilles}{\,\hdashrule{\fill}{\eptraitexo}{\eptraitexospace}}%
				{non}{\hfill}%
			}%
			%décoration éventuelle
			\IfSubStr{\EnvtExoDeco}{Icone}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoIcon]%
					\,\scalebox{0.85}[0.85]{\EnvtExoIcon}%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Ceinture}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoCouleur]%
					\,\CeintureCouleur{\EnvtExoCouleur}%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Chrono}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoChrono]%
					\,\pictochrono[ColTime=macouleurexo!50]{\EnvtExoChrono}%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Points}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoPts]%
					\IfStrEq{\EnvtExoPts}{1}{\def\pts{point}}{\def\pts{points}}%
					\,(\EnvtExoPts\ \pts)%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Image}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoImg]%
					\settototalheight{\tmp@image@hauteur@totale}{\hbox{\tmpstyleexo qB}}%
					\,$\vcenter{\hbox{\includegraphics[height=\EnvtExoScaleImg\tmp@image@hauteur@totale]{\EnvtExoImg}}}$%
				}{}%
		}{}%
	\IfSubStr{\EnvtExoType}{Perso}%OK perso____déco
		{%
			\StrBehind{\EnvtExoType}{/}[\EnvtExoLabel]%
			%label avec numéro et complément
			\tmpstyleexo\EnvtExoLabel\ifboolKV[EnvtExercice]{Compteur}{\thenumeroexo}{}\EnvtExoCpltTitre%
			%trait éventuel
			\IfStrEqCase{\EnvtExoTrait}{%
				{plein}{\,\hrulefill}%
				{pointilles}{\,\dotfill}%
				{dashilles}{\,\hdashrule{\fill}{\eptraitexo}{\eptraitexospace}}%
				{non}{\hfill}%
			}%
			%décoration éventuelle
			\IfSubStr{\EnvtExoDeco}{Icone}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoIcon]%
					\,\scalebox{0.85}[0.85]{\EnvtExoIcon}%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Ceinture}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoCouleur]%
					\,\CeintureCouleur{\EnvtExoCouleur}%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Chrono}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoChrono]%
					\,\pictochrono[ColTime=macouleurexo!50]{\EnvtExoChrono}%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Points}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoPts]%
					\IfStrEq{\EnvtExoPts}{1}{\def\pts{point}}{\def\pts{points}}%
					\,(\EnvtExoPts\ \pts)%
				}{}%
			\IfSubStr{\EnvtExoDeco}{Image}%
				{%
					\StrBehind{\EnvtExoDeco}{/}[\EnvtExoImg]%
					\settototalheight{\tmp@image@hauteur@totale}{\hbox{\tmpstyleexo qB}}%
					\,$\vcenter{\hbox{\includegraphics[height=\EnvtExoScaleImg\tmp@image@hauteur@totale]{\EnvtExoImg}}}$%
				}{}%
		}{}%
	\endgroup%
	\def\hrulefill{\leavevmode\leaders\hrule height 0.4pt\hfill\kern\z@}%
	\par%
	\EnvtExoCodeAvant%
}

%====BOITE ARRONDIE
\newlength{\tmpheightbox}
\defKV[BoiteArrondie]{EspH=\def\RoundedBoxDelta{#1},Style=\def\RoundedBoxStyle{#1}}
\setKVdefault[BoiteArrondie]{%
	Fond=red,%
	Texte=white,%
	EspH=0.125em,%
	Style=rect
}
\NewDocumentCommand\BoiteArrondie{ O{} m O{char} }{%
	\restoreKV[BoiteArrondie]%
	\setKV[BoiteArrondie]{#1}%
	\settototalheight{\tmpheightbox}{\hbox{(EazertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN)#2}}%hauteur globale
	\IfStrEqCase{\RoundedBoxStyle}{%
		{rect}{\tikz[remember picture,baseline=(#3.base)]{\node[minimum height=\tmpheightbox,shape=rectangle,rounded corners=0.25em,fill={\useKV[BoiteArrondie]{Fond}},inner sep=0.75pt,outer sep=0pt,text={\useKV[BoiteArrondie]{Texte}}] (#3) {\vphantom{(qE)}\kern\RoundedBoxDelta#2\kern\RoundedBoxDelta};}}%
		{cercle}{\tikz[remember picture,baseline=(#3.base)]{\node[shape=circle,minimum height=\tmpheightbox,fill={\useKV[BoiteArrondie]{Fond}},inner sep=0.75pt,outer sep=0pt,text={\useKV[BoiteArrondie]{Texte}}] (#3) {\vphantom{(qE)}#2};}}%
	}\relax
}

%%====Chat SMS

%===Données utiles
\newlength{\WidthofSMS}
\newlength{\HeightofSMS}
\newlength{\OffsetofSMS}
\newlength{\WidthofSMSavatar}
\newlength{\MarginofSMSavatar}
\colorlet{smscolp}{teal!75!cyan!75!white}
\colorlet{smscoltitle}{white}

%===Styles [FR/EN]
\tcbset{SMSglobal/.style={
	enhanced,arc=0pt,outer arc=0pt,colback=\ProjectSmsColback,toptitle=0.3cm,bottomtitle=0.3cm,title={\null},
	overlay={
		%la barre de titre
		\node[anchor=east,smscoltitle,font=\large] at ([xshift=-1mm]title.east) {\faVideo~~\faPhone*~~\faEllipsisV};
		\node[draw=none,anchor=west,inner sep=1pt,text=smscoltitle,font=\large] at ([xshift=1mm]title.west) (picture) {\ProjectSmsAvat};
		\node[draw=none,anchor=west,text=smscoltitle,font=\large,text depth=0pt,inner sep=1pt] at (picture.east) {\sffamily\bfseries\vphantom{pB}\NameofSMS} ;
		%le bas
		\draw[line width=0.85pt,darkgray] ([yshift=1cm]frame.south west) -- ([yshift=1cm]frame.south east);
		\node[draw=smscolp!75!black,top color=lightgray!40,bottom color=lightgray!40,middle color=white,line width=1pt,rounded corners=2pt,text width={{\WidthofSMS-2.5cm}},minimum height=0.75cm,font=\large\ProjectSmsFonte,text=darkgray,inner xsep=6pt] at ([shift={(0,0.5cm)}]frame.south) {\textcolor{gray}{\rule[-0.1cm]{1pt}{0.5cm}}\,\ProjectSmsWrite};
		\node[draw=none,font=\LARGE,text=darkgray!50,anchor=east,align=center] at ([shift={(-1mm,0.5cm)}]frame.south east) (send) {\faPaperPlane};
		\node[draw=none,font=\LARGE,text=darkgray!50,anchor=west,align=center] at ([shift={(1mm,0.5cm)}]frame.south west) (add) {\faPlusCircle};
		},
	boxrule=0.85pt,colframe=darkgray,
	title style={top color=smscolp!90!black,bottom color=smscolp!90!black,middle color=smscolp!75},
	bottom=1.15cm,top=0mm,left=1mm,right=1mm
	}
}

%===Keys [FR]
\defKV[ProjetSMS]{%
	Hauteur=\def\ProjectSmsHeight{#1},%
	Largeur=\setlength{\WidthofSMS}{#1},%
	Marge=\setlength{\OffsetofSMS}{#1},%
	Couleur=\colorlet{smscolp}{#1},%
	CouleurFond=\def\ProjectSmsColback{#1},%
	CouleurR=\def\ProjectSmsColIn{#1},%
	CouleurE=\def\ProjectSmsColOut{#1},%
	CouleurTitre=\colorlet{smscoltitle}{#1},%
	PoliceTxt=\def\ProjectSmsFonte{#1},%
	Avatar=\def\ProjectSmsAvatar{#1},%
	TxtEcrire=\def\ProjectSmsWrite{#1}
}
\setKVdefault[ProjetSMS]{%
	Hauteur=auto,%
	Largeur=7cm,%
	Marge=1.5cm,%
	CouleurFond={lightgray!5},%
	CouleurR=lime!25,%
	CouleurE=teal!25,%
	TxtEcrire={Écrire\ldots},%
	PoliceTxt=\normalfont,%
	Avatar=\faAddressCard,%
	AffAvatar=false,%
	NoirBlanc=false
}

%===Envt [FR]
\NewDocumentEnvironment{EnvSMS}{ O{} m }
{
	\restoreKV[ProjetSMS]%
	\setKV[ProjetSMS]{#1}%
	\def\NameofSMS{#2}%
		\IfSubStr{\ProjectSmsAvatar}{Image}%
		{%
			\StrBehind{\ProjectSmsAvatar}{/}[\tmpimgavatar]%
			\def\ProjectSmsAvat{\includegraphics[height=0.5cm]{\tmpimgavatar}}%
			\ifboolKV[ProjetSMS]{AffAvatar}%
				{%
					\setlength{\WidthofSMSavatar}{\widthof{\includegraphics[height=0.5\baselineskip]{\tmpimgavatar}}}%
					\setlength{\MarginofSMSavatar}{\WidthofSMSavatar+2pt}%
				}%
				{%
					\setlength{\MarginofSMSavatar}{0pt}%
				}%
		}%
		{%
			\def\ProjectSmsAvat{\ProjectSmsAvatar}%
			\ifboolKV[ProjetSMS]{AffAvatar}%
				{%
					\setlength{\WidthofSMSavatar}{\widthof{\tiny\ProjectSmsAvatar}}%
					\setlength{\MarginofSMSavatar}{\WidthofSMSavatar+2pt}%
				}%
				{%
					\setlength{\MarginofSMSavatar}{0pt}%
				}%
		}%
	\IfStrEq{\ProjectSmsHeight}{auto}%
		{%
			\tcbset{SMSsize/.style={width=\WidthofSMS}}%
		}%
		{%
			\setlength{\HeightofSMS}{\ProjectSmsHeight}%
			\tcbset{SMSsize/.style={width=\WidthofSMS,height=\HeightofSMS,valign=bottom}}%
		}%
	\ifboolKV[ProjetSMS]{NoirBlanc}%
		{%
			\colorlet{smscolp}{lightgray!25}%
			\def\ProjectSmsColback{lightgray!5}%
			\def\ProjectSmsColIn{lightgray!10}%
			\def\ProjectSmsColOut{lightgray!10}%
			\colorlet{smscoltitle}{gray}%
		}%
		{}%
	\tcolorbox[SMSsize,SMSglobal]%
}
{
	\endtcolorbox%
}

%===Macros [FR]
\NewDocumentCommand\SMSrec{ s m m }{%
	\ifboolKV[ProjetSMS]{AffAvatar}%
		{%
			\IfSubStr{\ProjectSmsAvatar}{Image}%
				{%
					\tcbset{SMSAffLogo/.style={left skip=\MarginofSMSavatar,overlay={\node[anchor=north east] at ([yshift={1mm+1pt}]interior.north west) {\includegraphics[height=0.5\baselineskip]{\tmpimgavatar}};}}}%
				}%
				{%
					\tcbset{SMSAffLogo/.style={left skip=\MarginofSMSavatar,overlay={\node[anchor=north east,font=\tiny,text=gray] at ([yshift={1mm+1pt}]interior.north west) {\ProjectSmsAvatar};}}}%
				}%
		}%
		{%
			\tcbset{SMSAffLogo/.style={}}%
		}%
	\tcbox[enhanced,interior code={},before skip=0.5mm,after skip=0.5mm,halign=left,left=1.5mm,right=1.5mm,
	frame code={
		\filldraw[\ProjectSmsColIn,draw=black,rounded corners=4pt]
		(frame.south east) rectangle (frame.north west) ;
	},
	width={\WidthofSMS-\OffsetofSMS},top=1mm,bottom=1mm,
	capture=minipage,fontupper=\small\ProjectSmsFonte,
	attach boxed title to top left,
	coltitle=black,fonttitle=\scriptsize\sffamily,
	boxed title style={size=fbox,bottom=0pt,boxsep=2pt,frame empty,interior empty},
	title={\@ifpackageloaded{babel}{\NoAutoSpacing#2}{#2}\IfBooleanTF{#1}{$\cdot$\scalebox{0.6}[0.6]{\faCheckCircle[regular]\!\faCheckCircle[regular]}~}{}},left=1mm,right=1mm,boxsep=0mm,SMSAffLogo]{#3}%
}
\NewDocumentCommand\SMSenv{ s m m }{%
	\tcbox[enhanced,interior code={},before skip=0.5mm,after skip=0.5mm,halign=left,left=1.5mm,right=1.5mm,
	frame code={
		\filldraw[\ProjectSmsColOut,draw=black,rounded corners=4pt]
		(frame.south east) rectangle (frame.north west) ;
	},
	width={\WidthofSMS-\OffsetofSMS},top=1mm,bottom=1mm,flush right,
	capture=minipage,fontupper=\small\ProjectSmsFonte,
	attach boxed title to top right,
	coltitle=black,fonttitle=\scriptsize\sffamily,
	boxed title style={size=fbox,bottom=0pt,boxsep=2pt,frame empty,interior empty},
	title={\@ifpackageloaded{babel}{\NoAutoSpacing#2}{#2}\IfBooleanTF{#1}{}{$\cdot$\scalebox{0.6}[0.6]{\faCheckCircle[regular]\!\faCheckCircle[regular]}~}},left=1mm,right=1mm,boxsep=0mm]{#3}%
}


%%----COMMANDES EN

%====QCMs
\defKV[answersmcq]{%
	NumCols=\def\RepQCMNbCol{#1},%
	FontLabels=\def\RepQCMFonte{#1},%
	SpaceCR=\def\RepQCMOffset{#1},%
	Labels=\def\RepQCMTypeLabel{#1},%
	SpaceLabels=\xdef\RepQCMSpace{#1},%
	Width=\def\RepQCMLarg{#1}
}

\setKVdefault[answersmcq]{%
	SpaceCR={6pt/2pt},%
	NumCols=4,%
	Lines=false,%
	FontLabels={\bfseries},%
	Labels={a.},%
	SpaceLabels=\kern5pt,%
	Swap=false,%
	Width=0.99\linewidth
}

\NewDocumentCommand\MCQFormatLabel{ m m }{%1=typelabel,%3=caractère
	\IfSubStr{#1}{a}%
		{%
			{\RepQCMFonte\StrSubstitute{#1}{a}{#2}}%
		}%
		{}%
	\IfSubStr{#1}{A}%
		{%
			{\RepQCMFonte\StrSubstitute{#1}{A}{#2}}%
		}%
		{}%
	\IfSubStr{#1}{1}%
		{%
			{\RepQCMFonte\StrSubstitute{#1}{1}{#2}}%
		}%
		{}%
}

\NewDocumentCommand\AnswersMCQ{ O{} m D<>{} }{%1=nbcol,2=listeréponses
	\restoreKV[answersmcq]%
	\setKV[answersmcq]{#1}%
	\IfSubStr{\RepQCMOffset}{/}%
		{\StrCut{\RepQCMOffset}{/}{\RepQCMOffsetCol}{\RepQCMOffsetLgn}}%
		{\def\RepQCMOffsetCol{\RepQCMOffset}\def\RepQCMOffsetLgn{\RepQCMOffset}}%
	\setsepchar{§}%
	\readlist*\QCMListereponses{#2}%
	\def\QCMNbRep{\QCMListereponseslen}%
	%les items créés
	\IfSubStr{\RepQCMTypeLabel}{a}%
		{%
			\xdef\RepQCMLabelA{\MCQFormatLabel{\RepQCMTypeLabel}{a}\RepQCMSpace}%
			\xdef\RepQCMLabelB{\MCQFormatLabel{\RepQCMTypeLabel}{b}\RepQCMSpace}%
			\xdef\RepQCMLabelC{\MCQFormatLabel{\RepQCMTypeLabel}{c}\RepQCMSpace}%
			\xdef\RepQCMLabelD{\MCQFormatLabel{\RepQCMTypeLabel}{d}\RepQCMSpace}%
		}{}%
	\IfSubStr{\RepQCMTypeLabel}{A}%
		{%
			\xdef\RepQCMLabelA{\MCQFormatLabel{\RepQCMTypeLabel}{A}\RepQCMSpace}%
			\xdef\RepQCMLabelB{\MCQFormatLabel{\RepQCMTypeLabel}{B}\RepQCMSpace}%
			\xdef\RepQCMLabelC{\MCQFormatLabel{\RepQCMTypeLabel}{C}\RepQCMSpace}%
			\xdef\RepQCMLabelD{\MCQFormatLabel{\RepQCMTypeLabel}{D}\RepQCMSpace}%
		}{}%
	\IfSubStr{\RepQCMTypeLabel}{1}%
		{%
			\xdef\RepQCMLabelA{\MCQFormatLabel{\RepQCMTypeLabel}{1}\RepQCMSpace}%
			\xdef\RepQCMLabelB{\MCQFormatLabel{\RepQCMTypeLabel}{2}\RepQCMSpace}%
			\xdef\RepQCMLabelC{\MCQFormatLabel{\RepQCMTypeLabel}{3}\RepQCMSpace}%
			\xdef\RepQCMLabelD{\MCQFormatLabel{\RepQCMTypeLabel}{4}\RepQCMSpace}%
		}{}%
	%en fonction du nb de colonnes
	\IfEq{\QCMNbRep}{2}%2réponses
		{%
			\ifboolKV[answersmcq]{Lines}%
				{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,hlines,vlines,width=\RepQCMLarg,colspec={*{2}{X[b,l]}},#3}}%
				{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,width=\RepQCMLarg,colspec={*{2}{X[b,l]}},#3}}%
				\RepQCMLabelA\QCMListereponses[1] & \RepQCMLabelB\QCMListereponses[2] \\
			\end{tblr}%
		}%
		{}%
	\IfEq{\QCMNbRep}{3}%3réponses
		{%
			\ifboolKV[answersmcq]{Lines}%
				{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,hlines,vlines,width=\RepQCMLarg,colspec={*{3}{X[b,l]}},#3}}%
				{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,width=\RepQCMLarg,colspec={*{3}{X[b,l]}},#3}}%
				\RepQCMLabelA\QCMListereponses[1] & \RepQCMLabelB\QCMListereponses[2] & \RepQCMLabelC\QCMListereponses[3] \\
			\end{tblr}%
		}%
		{}%
	\IfEq{\QCMNbRep}{4}%4réponses
		{%
			\IfEq{\RepQCMNbCol}{4}%4colonnes
				{%
					\ifboolKV[answersmcq]{Lines}%
						{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,hlines,vlines,width=\RepQCMLarg,colspec={*{4}{X[b,l]}},#3}}%
						{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,width=\RepQCMLarg,colspec={*{4}{X[b,l]}},#3}}%
						\RepQCMLabelA\QCMListereponses[1] & \RepQCMLabelB\QCMListereponses[2] & \RepQCMLabelC\QCMListereponses[3] & \RepQCMLabelD\QCMListereponses[4] \\
					\end{tblr}%
				}%
				{%
					\ifboolKV[answersmcq]{Lines}%
						{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,hlines,vlines,width=\RepQCMLarg,colspec={*{2}{X[b,l]}},#3}}%
						{\begin{tblr}{rowsep=\RepQCMOffsetLgn,colsep=\RepQCMOffsetCol,width=\RepQCMLarg,colspec={*{2}{X[b,l]}},#3}}%
						\RepQCMLabelA\QCMListereponses[1] & \ifboolKV[answersmcq]{Swap}{\RepQCMLabelB\QCMListereponses[2]}{\RepQCMLabelC\QCMListereponses[3]} \\
						\ifboolKV[answersmcq]{Swap}{\RepQCMLabelC\QCMListereponses[3]}{\RepQCMLabelB\QCMListereponses[2]} & \RepQCMLabelD\QCMListereponses[4] \\
					\end{tblr}%
				}%
		}%
		{}%
}

%====ITEMCHOICE
\NewDocumentCommand\CreateItemsList{ m m m }{%1=liste,%2=macro,3=nomliste
	\@ifIsList{#3}%
		{The list \texttt{#3} already exists, pick an other name.}%
		{\xdef#2{#1}\NewList{#3}}%
}

\defKV[itemchoice]{%
	Type=\def\ChoixTypeSerie{#1}
}
\setKVdefault[itemchoice]{%
	Random=false,%
	Type=enum
}

\NewDocumentCommand\ListItemsChoice{ O{} m m r() D<>{} }{%1=options,2=série des items,3=nomsérie,4=liste choix,5=options enum
	%on teste si la liste considérée existe...
	\@ifIsList{#3}%
		{%
			\restoreKV[itemchoice]%
			\setKV[itemchoice]{#1}%
			\ClearList{#3}%
			%création de la liste
			\ifboolKV[itemchoice]{Random}%
				{%
					\xintFor* ##1 in {\xintCSVtoList{#2}}\do{\InsertRandomItem{#3}{##1}}
				}%
				{%
					\xintFor* ##1 in {\xintCSVtoList{#2}}\do{\InsertLastItem{#3}{##1}}
				}%
			%création de l'environnement
			\IfStrEq{\ChoixTypeSerie}{enum}%
				{\begin{enumerate}[#5]}{}%
			\IfStrEq{\ChoixTypeSerie}{item}%
				{\begin{itemize}[#5]}{}%
			\IfSubStr{\ChoixTypeSerie}{MultiCols}%
				{%
					\StrBetween[1,2]{\ChoixTypeSerie}{/}{/}[\ChoixTypeMulticols]%
					\StrBehind[2]{\ChoixTypeSerie}{/}[\NbMulticols]%
					\begin{MultiCols}[Type=\ChoixTypeMulticols](\NbMulticols)<#5>%
				}{}%
			%items choisis
			\ifboolKV[itemchoice]{Random}%
				{%
					\xintFor* ##1 in {\xintSeq{0}{\xinteval{#4-1}}}\do{\GetItem{#3}{##1}{ItemChoisi}\item \ItemChoisi}
				}%
				{%
					\xintFor* ##1 in {\xintCSVtoList{#4}}\do{\GetItem{#3}{\xinteval{##1-1}}{ItemChoisi}\item \ItemChoisi}
				}
			%fin de l'environnement
			\IfStrEq{\ChoixTypeSerie}{enum}%
				{\end{enumerate}}{}
			\IfStrEq{\ChoixTypeSerie}{item}
				{\end{itemize}}{}%
			\IfSubStr{\ChoixTypeSerie}{MultiCols}%
				{\end{MultiCols}}{}%
		}%
		{%
			The list \texttt{#3} doesn't exist, please use \texttt{\textbackslash CreerListeItems} to create it.%
		}%
}

%====PENSKILLS
\defKV[pentasks]{%
	FontCateg=\def\pentaksfontcateg{#1},%
	FontBlock=\def\pentaksfontblock{#1},%
	Colors=\def\pentakscolors{#1},%
	BlockWidth=\def\pentakswidth{#1},
	Scale=\def\pentakscale{#1}
}
\setKVdefault[pentasks]{%
	FontCateg=\bfseries\sffamily,%
	FontBlock=\small\ttfamily,%
	%Colors={"yellow/black","orange/black","magenta/black","cyan/black","teal/black","brown/black"},%
	Colors={yellow/black,orange/black,magenta/black,cyan/black,teal/black,brown/black},%
	BlockWidth=5cm,%
	Scale=1,%
	BlackWhite=false
}

\NewDocumentCommand\PencilSkills{ O{} D<>{} m }{%
	\restoreKV[pentasks]%
	\setKV[pentasks]{#1}%
	%\edef\lstColors{\pentakscolors}%
	\readlist*\lstColors{\pentakscolors}%
	\begin{tikzpicture}%
		[line width=0.25\pgflinewidth,scale=\pentakscale,transform shape,#2,pics/fancy box/.style={code={%
			\path (0,0) coordinate (C0);
			\foreach \Item/\Text [count=\Count starting from 0] in {#3}
			{%
				\ifboolKV[pentasks]{BlackWhite}%
					{%
						\def\mybackcolor{gray}\def\myfontcolor{black}
					}%
					{%
						%\pgfmathsetmacro{\mycolor}{{\lstColors}[\Count]}
						\itemtomacro\lstColors[\the\numexpr\Count+1\relax]\mycolor
						\IfSubStr{\mycolor}{/}%
							{%
								\StrCut{\mycolor}{/}{\mybackcolor}{\myfontcolor}%
							}%
							{%
								\def\mybackcolor{\mycolor}\def\myfontcolor{\mycolor}%
							}%
					}%
				\node[rounded rectangle,rounded rectangle left arc=none,draw=\mybackcolor,fill=\mybackcolor,anchor=north west,font=\pentaksfontcateg,text=\myfontcolor,outer sep=0pt,inner sep=0.75ex]  (RR\Count) at (C\Count) {\vphantom{pL}\Item};
				\node[line width={\pentakscale*3\pgflinewidth},anchor=north west,below right={\pentakscale*1ex} of RR\Count.south west,draw,text width=\pentakswidth,font=\pentaksfontblock,inner sep=0.75ex] (T\Count) {\Text};
				\coordinate[below left={\pentakscale*1ex} of T\Count.south west] (C\the\numexpr\Count+1\relax);
				\filldraw[\mybackcolor] ([xshift=-1ex]C\Count) rectangle (C\the\numexpr\Count+1\relax);
				\filldraw[\mybackcolor] ([xshift=-3ex]C\Count) rectangle ([xshift=-2ex]C\the\numexpr\Count+1\relax);
				\filldraw[\mybackcolor!50!white] ([xshift=-2ex]C\Count) rectangle ([xshift=-1ex]C\the\numexpr\Count+1\relax);
				\ifnum\Count=0
					\shade[ball color=\mybackcolor!75] ([shift={(-3ex-\pentakscale*0.5\pgflinewidth,\pentakscale*0.5\pgflinewidth)}]C\Count) to[out=90,in=90]++(3ex+\pentakscale*\pgflinewidth,0) ;
%					(C\Count);
				\fi
				\xdef\myCount{\Count}%last index
				}
			\ifboolKV[pentasks]{BlackWhite}%
				{%
					\def\mylastbackcolor{gray}
					\filldraw[lightgray!15] ([xshift=-3ex]C\the\numexpr\myCount+1\relax) --++ (0,-0.25ex) --++ (1.5ex,-4ex) coordinate[pos=0.8] (aux1) coordinate[pos=1] (aux2) -- ($(C\the\numexpr\myCount+1\relax)+(0,-0.25ex)$) coordinate[pos=0.2] (aux3) --++ (0,0.25ex) -- cycle ;
				}%
				{%
					%\pgfmathsetmacro{\mylastcolor}{{\lstColors}[\myCount]}
					\itemtomacro\lstColors[\the\numexpr\myCount+1\relax]\mylastcolor
					\IfSubStr{\mylastcolor}{/}%
						{%
							\StrBefore{\mylastcolor}{/}[\mylastbackcolor]%
						}%
						{%
							\def\mylastbackcolor{\mylastcolor}%
						}%
					\filldraw[brown!10] ([xshift=-3ex]C\the\numexpr\myCount+1\relax) --++ (0,-0.25ex) --++ (1.5ex,-4ex) coordinate[pos=0.8] (aux1) coordinate[pos=1] (aux2) -- ($(C\the\numexpr\myCount+1\relax)+(0,-0.25ex)$) coordinate[pos=0.2] (aux3) --++ (0,0.25ex) -- cycle ;
				}%
			\filldraw[\mylastbackcolor] ([shift={(-3ex,3\pgflinewidth)}]C\the\numexpr\myCount+1\relax) to[out=-90,in=180]++ (0.5ex-0.5\pgflinewidth,-0.5ex) to[out=0,in=-90]++ (0.5ex-0.5\pgflinewidth,0.5ex) -- cycle ;
			\filldraw[\mylastbackcolor] ([shift={(-1ex+\pgflinewidth,3\pgflinewidth)}]C\the\numexpr\myCount+1\relax) to[out=-90,in=180]++ (0.5ex-0.5\pgflinewidth,-0.5ex) to[out=0,in=-90]++ (0.5ex-0.5\pgflinewidth,0.5ex) -- cycle ;
			\filldraw[\mylastbackcolor!50!white] ([shift={(-2ex,3\pgflinewidth)}]C\the\numexpr\myCount+1\relax) to[out=-90,in=180]++ (0.5ex,-0.5ex) to[out=0,in=-90]++ (0.5ex,0.5ex) -- cycle ;
			\filldraw[line join=cap,gray,fill=gray] (aux1) -- (aux2) -- (aux3);
		}}]
		\pic{fancy box={#2}};
	\end{tikzpicture}%
}

%====ROUNDED BOX
% \defKV[RoundedBox]{hmargin=\def\RoundedBoxDelta{#1},style=\def\RoundedBoxStyle{#1}}
% \setKVdefault[RoundedBox]{%
	% bg=red,%
	% txt=white,%
	% hmargin=0.25em,%
	% style=rect
% }

% \NewDocumentCommand\RoundedBox{ O{} m O{char} }{%
	% \restoreKV[RoundedBox]%
	% \setKV[RoundedBox]{#1}%
	% \settototalheight{\tmpheightbox}{\hbox{(EazertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN)#2}}%hauteur globale
	% \IfStrEqCase{\RoundedBoxStyle}{%
		% {rect}{\tikz[remember picture,baseline=(#3.base)]{\node[minimum height=\tmpheightbox,shape=rectangle,rounded corners=0.25em,fill={\useKV[RoundedBox]{bg}},inner sep=0.75pt,outer sep=0pt,text={\useKV[RoundedBox]{txt}}] (#3) {\vphantom{(qE)}\kern\RoundedBoxDelta#2\kern\RoundedBoxDelta};}}%
		% {circle}{\tikz[remember picture,baseline=(#3.base)]{\node[minimum height=\tmpheightbox,shape=circle,fill={\useKV[RoundedBox]{bg}},inner sep=0.75pt,outer sep=0pt,text={\useKV[RoundedBox]{txt}}] (#3) {\vphantom{(qE)}#2};}}%
	% }\relax
% }

%====Chat SMS
%===Keys [EN]
\defKV[ProjectSMS]{%
	height=\def\ProjectSmsHeight{#1},%
	width=\setlength{\WidthofSMS}{#1},%
	margin=\setlength{\OffsetofSMS}{#1},%
	color=\colorlet{smscolp}{#1},%
	colback=\def\ProjectSmsColback{#1},%
	colorin=\def\ProjectSmsColIn{#1},%
	colorout=\def\ProjectSmsColOut{#1},%
	coltitle=\colorlet{smscoltitle}{#1},%
	fonttxt=\def\ProjectSmsFonte{#1},%
	avatar=\def\ProjectSmsAvatar{#1},%
	writetxt=\def\ProjectSmsWrite{#1}
}
\setKVdefault[ProjectSMS]{%
	height=auto,%
	width=7cm,%
	margin=1.5cm,%
	colback=lightgray!5,%
	colorin=lime!25,%
	colorout=teal!25,%
	writetxt={Write\ldots},%
	fonttxt=\normalfont,%
	avatar=\faAddressCard,%
	dispavatar=false,%
	blackwhite=false
}

%===Envt [EN]
\NewDocumentEnvironment{ChatSMS}{ O{} m }
{
	\restoreKV[ProjectSMS]%
	\setKV[ProjectSMS]{#1}%
	\def\NameofSMS{#2}%
	\IfSubStr{\ProjectSmsAvatar}{img}%
		{%
			\StrBehind{\ProjectSmsAvatar}{/}[\tmpimgavatar]%
			\def\ProjectSmsAvat{\includegraphics[height=0.5cm]{\tmpimgavatar}}%
			\ifboolKV[ProjectSMS]{dispavatar}%
				{%
					\setlength{\WidthofSMSavatar}{\widthof{\includegraphics[height=0.5\baselineskip]{\tmpimgavatar}}}%
					\setlength{\MarginofSMSavatar}{\WidthofSMSavatar+2pt}%
				}%
				{%
					\setlength{\MarginofSMSavatar}{0pt}%
				}%
		}%
		{%
			\def\ProjectSmsAvat{\ProjectSmsAvatar}%
			\ifboolKV[ProjectSMS]{dispavatar}%
				{%
					\setlength{\WidthofSMSavatar}{\widthof{\tiny\ProjectSmsAvatar}}%
					\setlength{\MarginofSMSavatar}{\WidthofSMSavatar+2pt}%
				}%
				{%
					\setlength{\MarginofSMSavatar}{0pt}%
				}%
		}%
	\IfStrEq{\ProjectSmsHeight}{auto}%
		{%
			\tcbset{SMSsize/.style={width=\WidthofSMS}}%
		}%
		{%
			\setlength{\HeightofSMS}{\ProjectSmsHeight}%
			\tcbset{SMSsize/.style={width=\WidthofSMS,height=\HeightofSMS,valign=bottom}}%
		}%
	\ifboolKV[ProjectSMS]{blackwhite}%
		{%
			\colorlet{smscolp}{lightgray!25}%
			\def\ProjectSmsColback{lightgray!5}%
			\def\ProjectSmsColIn{lightgray!10}%
			\def\ProjectSmsColOut{lightgray!10}%
			\colorlet{smscoltitle}{gray}%
		}%
		{}%
	\tcolorbox[SMSsize,SMSglobal]%
}
{
	\endtcolorbox%
}

%===Macros [EN]
\NewDocumentCommand\InSMS{ s m m }{%
	\ifboolKV[ProjectSMS]{dispavatar}%
		{%
			\IfSubStr{\ProjectSmsAvatar}{img}%
				{%
					\tcbset{SMSAffLogo/.style={left skip=\MarginofSMSavatar,overlay={\node[anchor=north east] at ([yshift={1mm+1pt}]interior.north west) {\includegraphics[height=0.5\baselineskip]{\tmpimgavatar}};}}}%
				}%
				{%
					\tcbset{SMSAffLogo/.style={left skip=\MarginofSMSavatar,overlay={\node[anchor=north east,font=\tiny,text=gray] at ([yshift={1mm+1pt}]interior.north west) {\ProjectSmsAvatar};}}}%
				}%
		}%
		{%
			\tcbset{SMSAffLogo/.style={}}%
		}%
	\tcbox[enhanced,interior code={},before skip=0.5mm,after skip=0.5mm,halign=left,left=1.5mm,right=1.5mm,
	frame code={
		\filldraw[\ProjectSmsColIn,draw=black,rounded corners=4pt]
		(frame.south east) rectangle (frame.north west) ;
	},
	width={\WidthofSMS-\OffsetofSMS},top=1mm,bottom=1mm,
	capture=minipage,fontupper=\small\ProjectSmsFonte,
	attach boxed title to top left,
	coltitle=black,fonttitle=\scriptsize\sffamily,
	boxed title style={size=fbox,bottom=0pt,boxsep=2pt,frame empty,interior empty},
	title={#2\IfBooleanTF{#1}{$\cdot$\scalebox{0.6}[0.6]{\faCheckCircle[regular]\!\faCheckCircle[regular]}~}{}},left=1mm,right=1mm,boxsep=0mm,SMSAffLogo]{#3}%
}
\NewDocumentCommand\OutSMS{ s m m }{%
	\tcbox[enhanced,interior code={},before skip=0.5mm,after skip=0.5mm,halign=left,left=1.5mm,right=1.5mm,
	frame code={
		\filldraw[\ProjectSmsColOut,draw=black,rounded corners=4pt]
		(frame.south east) rectangle (frame.north west) ;
	},
	width={\WidthofSMS-\OffsetofSMS},top=1mm,bottom=1mm,flush right,
	capture=minipage,fontupper=\small\ProjectSmsFonte,
	attach boxed title to top right,
	coltitle=black,fonttitle=\scriptsize\sffamily,
	boxed title style={size=fbox,bottom=0pt,boxsep=2pt,frame empty,interior empty},
	title={#2\IfBooleanTF{#1}{}{$\cdot$\scalebox{0.6}[0.6]{\faCheckCircle[regular]\!\faCheckCircle[regular]}~}},left=1mm,right=1mm,boxsep=0mm]{#3}%
}

%====SMALL BOXES CREATION
\tikzset{simpleboxrulearrow/.style={line width=0.8pt,|->,>=latex}}

% \NewTColorBox{SimpleBox}{ O{blue} D<>{} m }{
	% enhanced,nobeforeafter,blanker,size=small,bottom=1mm,before=\par\noindent,%top=0mm,left=1mm,right=1mm,
	% title={#3},fonttitle=\sffamily\bfseries\color{#1},lefttitle=1em,
	% finish={\draw[#1,simpleboxrulearrow] ([xshift=1em]title.west) --++ (-1em,0) |- (frame.south east) -- ($(frame.south east)!0.5!(frame.north east)$) ;},%
	% #2
% }

\NewTColorBox{BoiteSimple}{ O{blue} D<>{} m }{
	enhanced,nobeforeafter,blanker,size=small,bottom=1mm,before=\par\noindent,%top=0mm,left=1mm,right=1mm,
	title={#3},fonttitle=\sffamily\bfseries\color{#1},lefttitle=1em,
	finish={\draw[#1,simpleboxrulearrow] ([xshift=1em]title.west) --++ (-1em,0) |- (frame.south east) -- ($(frame.south east)!0.5!(frame.north east)$) ;},%
	#2
}

% \NewDocumentCommand\GenSimpleBox{ O{blue} m }{%
	% 1 = couleur
	% 2 = nom
	% \NewTColorBox{#2}{ O{} m }{
		% enhanced,nobeforeafter,blanker,size=small,bottom=1mm,before=\par\noindent,%top=0mm,left=1mm,right=1mm,
		% title={##2},fonttitle=\sffamily\bfseries\color{#1},lefttitle=1em,
		% finish={\draw[#1,simpleboxrulearrow] ([xshift=1em]title.west) --++ (-1em,0) |- (frame.south east) -- ($(frame.south east)!0.5!(frame.north east)$) ;},%
		% ##1
	% }
% }

\NewDocumentCommand\GenereBoiteSimple{ O{blue} m }{%
	%1 = couleur
	%2 = nom
	\NewTColorBox{#2}{ O{} m }{
		enhanced,nobeforeafter,blanker,size=small,bottom=1mm,before=\par\noindent,%top=0mm,left=1mm,right=1mm,
		title={##2},fonttitle=\sffamily\bfseries\color{#1},lefttitle=1em,
		finish={\draw[#1,simpleboxrulearrow] ([xshift=1em]title.west) --++ (-1em,0) |- (frame.south east) -- ($(frame.south east)!0.5!(frame.north east)$) ;},%
		##1
	}
}

%====CIRCLEDNUMBERSSIMPLE
\defKV[CircledBoxNumber]{bg=\def\tmpbordernbcircbox{#1}}
\setKVdefault[CircledBoxNumber]{bg={},txt=black,bthick=0.5pt,bcol=black,raise=true}

\newlength{\tmpheightnbcircbox}
\newlength{\tmpdepthnbcircbox}
\NewDocumentCommand\CircledNumber{ O{} m O{circnb} }{%
	\restoreKV[CircledBoxNumber]%
	\setKV[CircledBoxNumber]{#1}%
	\settototalheight{\tmpheightnbcircbox}{(1234567890)}%hauteur globale
	\settodepth{\tmpdepthnbcircbox}{(1234567890)}%
	\ifboolKV[CircledBoxNumber]{raise}%
		{%
			\IfEq{\tmpbordernbcircbox}{}%
				{%
					{\tikz[baseline={([yshift=\tmpdepthnbcircbox]current bounding box.south)}]\node[outer sep=0pt,inner sep=0.5pt,minimum height={\tmpheightnbcircbox-\useKV[CircledBoxNumber]{bthick}},draw,{\useKV[CircledBoxNumber]{bcol}},line width={\useKV[CircledBoxNumber]{bthick}},circle,text={\useKV[CircledBoxNumber]{txt}}] (#3) {\ifnum#2<10 #2\else\scalebox{0.5}[1]{#2}\fi} ;}%
				}%
				{%
					{\tikz[baseline={([yshift=\tmpdepthnbcircbox]current bounding box.south)}]\node[outer sep=0pt,inner sep=0.5pt,minimum height={\tmpheightnbcircbox-\useKV[CircledBoxNumber]{bthick}},draw,{\useKV[CircledBoxNumber]{bcol}},line width={\useKV[CircledBoxNumber]{bthick}},circle,fill={\useKV[CircledBoxNumber]{bg}},text={\useKV[CircledBoxNumber]{txt}}] (#3) {\ifnum#2<10 #2\else\scalebox{0.5}[1]{#2}\fi} ;}%
				}%
		}%
		{%
			\IfEq{\tmpbordernbcircbox}{}%
				{%
					{\tikz[baseline=(#3.base)] \node[outer sep=0pt,inner sep=0.5pt,minimum height={\tmpheightnbcircbox-\useKV[CircledBoxNumber]{bthick}},draw,{\useKV[CircledBoxNumber]{bcol}},line width={\useKV[CircledBoxNumber]{bthick}},circle,text={\useKV[CircledBoxNumber]{txt}}] (#3) {\ifnum#2<10 #2\else\scalebox{0.5}[1]{#2}\fi} ;}%
				}%
				{%
					{\tikz[baseline=(#3.base)] \node[outer sep=0pt,inner sep=0.5pt,minimum height={\tmpheightnbcircbox-\useKV[CircledBoxNumber]{bthick}},draw,{\useKV[CircledBoxNumber]{bcol}},line width={\useKV[CircledBoxNumber]{bthick}},circle,fill={\useKV[CircledBoxNumber]{bg}},text={\useKV[CircledBoxNumber]{txt}}] (#3) {\ifnum#2<10 #2\else\scalebox{0.5}[1]{#2}\fi} ;}%
				}%
		}%
}

%====EXAM BOX TITLE(s)
\NewDocumentCommand\LetPhantomBox{}{%
	\vphantom{(ÉAZERTYUIOPQSDFGHJKLMWXCVBN,éàço)}%
}

\tcbset{StyleTitreSujet/.style={%
	enhanced,size=small,
	colback=white!5,boxrule=1.25pt,
	attach boxed title to top left={xshift=0.5cm,yshift=1mm-\tcboxedtitleheight},
	varwidth boxed title*=-3cm,
	boxed title style={frame code={
			\path[fill=tcbcolframe!50!black]
			([yshift=-1mm,xshift=-1mm]frame.north west)
			arc[start angle=0,end angle=180,radius=1mm]
			([yshift=-1mm,xshift=1mm]frame.north east)
			arc[start angle=180,end angle=0,radius=1mm];
			\path[fill=tcbcolframe] ([xshift=-2mm]frame.north west) -- ([xshift=2mm]frame.north east) [rounded corners=1mm]-- ([xshift=1mm,yshift=-1mm]frame.north east) -- (frame.south east) -- (frame.south west) -- ([xshift=-1mm,yshift=-1mm]frame.north west) [sharp corners]-- cycle;
		},interior engine=empty,size=fbox,
	},
	fonttitle=\bfseries\sffamily,
	fontupper=\huge\bfseries\sffamily,
	}
}

\defKV[tcbtitresujet]{%
	AlignH=\def\tcbtitresujethalign{#1}
}

\setKVdefault[tcbtitresujet]{%
	Couleur=black,
	AlignH=center
}

\NewDocumentEnvironment{TitreSujet}{ O{} D<>{} m }%
{%
	\restoreKV[tcbtitresujet]%
	\setKV[tcbtitresujet]{#1}%
	\IfStrEqCase{\tcbtitresujethalign}{%
		{right}{\tcbset{StyleTitreSujetAlign/.style={halign=flush right}}}%
		{left}{\tcbset{StyleTitreSujetAlign/.style={halign=flush left}}}%
	}[\tcbset{StyleTitreSujetAlign/.style={halign=flush center}}]%
	\tcolorbox[colupper={\useKV[tcbtitresujet]{Couleur}},colframe={\useKV[tcbtitresujet]{Couleur}},StyleTitreSujet,StyleTitreSujetAlign,title={\vphantom{QJ}#3},before upper=\LetPhantomBox,after upper=\LetPhantomBox,#2]%
}%
{%
	\endtcolorbox%
}

\tcbset{StyleTitreSujetSousEpreuve/.style={%
		center,after skip=1pt,size=small,boxsep=3pt,boxrule=1pt,colback=white,left=2pt,right=2pt,%
		sharp corners,rounded corners=downhill,arc=8pt,
		fontupper={\sffamily\bfseries\large}
	}
}

\NewDocumentCommand\SousTitreSujetEpreuve{ O{black} m }{%
	\tcbset{StyleTitreSujetSousEpreuveCouleur/.style={colframe=#1,colupper=#1}}
	\IfStrEqCase{#2}{%
		{}{\tcbox[StyleTitreSujetSousEpreuve,StyleTitreSujetSousEpreuveCouleur]{#2}}%
		{U21}{\tcbox[StyleTitreSujetSousEpreuve,StyleTitreSujetSousEpreuveCouleur,before upper=\faSortNumericDown\:\:,after upper=\:\:\faProjectDiagram]{Épreuve U2 - Mathématiques pour l'Informatique}}%
		{U2}{\tcbox[StyleTitreSujetSousEpreuve,StyleTitreSujetSousEpreuveCouleur,before upper=\faSortNumericDown\:\:,after upper=\:\:\faProjectDiagram]{Épreuve U2 - Mathématiques pour l'Informatique}}%
		{U2CG}{\tcbox[StyleTitreSujetSousEpreuve,StyleTitreSujetSousEpreuveCouleur,before upper=\faSortNumericDown\:\:,after upper=\:\:\faProjectDiagram]{Épreuve U2 - Mathématiques appliquées}}%
		{UF2}{\tcbox[StyleTitreSujetSousEpreuve,StyleTitreSujetSousEpreuveCouleur,before upper=\faDice\:\:,after upper=\:\:\faChartLine]{Épreuve UF2 - Mathématiques Approfondies}}%
		{U41OL}{\tcbox[StyleTitreSujetSousEpreuve,StyleTitreSujetSousEpreuveCouleur,before upper=\faDice\:\:,after upper=\:\:\faBezierCurve]{Épreuve U41 - Mathématiques}}
	}%
}

\NewDocumentCommand\SujetTitreExo{ O{black} m }{%
	\tcolorbox[enhanced,width=\linewidth,size=small,colback=white,colframe=#1,boxrule=0.75pt,fontupper=\color{#1}\Large\sffamily\bfseries,sharp corners,rounded corners=south,arc=4pt,before upper=\LetPhantomBox]
	#2
	\endtcolorbox%
}

%====vignettes
\NewDocumentCommand\LetPhantomVignette{}{%
	\vphantom{(AZERTYUIOPQSDFGHJKLMWXCVBN,éàço)}%
}

\tcbset{cevignettes/.style={%
		nobeforeafter,box align=base,boxsep=0pt,enhanced,sharp corners=all,rounded corners=southeast,arc=2pt,boxrule=0.65pt,left=1.75pt,right=1.25pt,top=1.25pt,bottom=0.5pt,colback=white,before upper=\LetPhantomVignette
	}
}

\tcbset{cevignettepy/.style={%
		cevignettes,left=6pt,coltitle=tcbcolframe,
		underlay={\begin{tcbclipinterior}\fill[fill=tcbcolframe!33]($(interior.south west)$) rectangle node[rotate=90,font=\tiny\sffamily,tcbcolframe!75!black]{\scalebox{0.55}[0.75]{\textbf{PY}}} ($(interior.north west)+(5pt,0pt)$);\end{tcbclipinterior}}
	}
}

\tcbset{cevignettealgo/.style={%
		cevignettes,left=6pt,coltitle=tcbcolframe,
		underlay={\begin{tcbclipinterior}\fill[fill=tcbcolframe!33]($(interior.south west)$) rectangle node[rotate=90,font=\tiny\sffamily,tcbcolframe!75!black]{\scalebox{0.55}[0.75]{\textbf{ALGO}}} ($(interior.north west)+(5pt,0pt)$);\end{tcbclipinterior}}
	}
}

\tcbset{cevignettetableur/.style={%
		cevignettes,left=6pt,coltitle=tcbcolframe,
		underlay={\begin{tcbclipinterior}\fill[fill=tcbcolframe!33]($(interior.south west)$) rectangle node[rotate=90,font=\tiny\sffamily,tcbcolframe!75!black]{\scalebox{0.5}[0.75]{\textbf{EXCEL}}} ($(interior.north west)+(5pt,0pt)$);\end{tcbclipinterior}}
	}
}

\tcbset{cevignetteMPM/.style={%
		cevignettes,left=6pt,coltitle=white,
		underlay={\begin{tcbclipinterior}\fill[fill=tcbcolframe!33]($(interior.south west)$) rectangle node[rotate=90,font=\tiny\sffamily,tcbcolframe!75!black]{\scalebox{0.55}[0.75]{\textbf{MPM}}} ($(interior.north west)+(5pt,0pt)$);\end{tcbclipinterior}}
	}
}

\tcbset{cevignettegraph/.style={%
		cevignettes,left=6pt,coltitle=white,
		underlay={\begin{tcbclipinterior}\fill[fill=tcbcolframe!33]($(interior.south west)$) rectangle node[rotate=90,font=\tiny\sffamily,tcbcolframe!75!black]{\scalebox{0.55}[0.75]{\textbf{GRPH}}} ($(interior.north west)+(5pt,0pt)$);\end{tcbclipinterior}}
	}
}

\tcbset{cevignetteshell/.style={%
		cevignettes,left=6pt,coltitle=white,
		underlay={\begin{tcbclipinterior}\fill[fill=tcbcolframe!33]($(interior.south west)$) rectangle node[rotate=90,font=\tiny\sffamily,tcbcolframe!75!black] {\scalebox{0.5}[0.75]{\textbf{SHELL}}} ($(interior.north west)+(5pt,0pt)$);\end{tcbclipinterior}}
	}
}

\tcbset{cevignettelatex/.style={%
		cevignettes,left=6pt,coltitle=white,
		underlay={\begin{tcbclipinterior}\fill[fill=tcbcolframe!33]($(interior.south west)$) rectangle node[rotate=90,font=\tiny\sffamily,tcbcolframe!75!black]{\scalebox{0.55}[0.75]{\textbf{\LaTeX}}} ($(interior.north west)+(5pt,0pt)$);\end{tcbclipinterior}}
	}
}

\tcbset{cevignettexcas/.style={%
		cevignettes,left=6pt,coltitle=white,colback=white,%
		underlay={\begin{tcbclipinterior}\fill[fill=tcbcolframe!33]($(interior.south west)$) rectangle node[rotate=90,font=\tiny\sffamily,tcbcolframe!75!black]{\scalebox{0.55}[0.75]{\textbf{XCAS}}} ($(interior.north west)+(5pt,0pt)$);\end{tcbclipinterior}}
	}
}

\defKV[cevignette]{Type=\def\cevignettetype{#1},Couleur=\def\cevignettecolor{#1},Police=\def\cevignettefont{#1}}
\setKVdefault[cevignette]{Type={},Couleur={darkgray},Police=\footnotesize}

\NewDocumentCommand\AffVignette{ s O{} m }{%
	\restoreKV[cevignette]%
	\setKV[cevignette]{#2}%
	\IfStrEqCase{\cevignettetype}{%
		{}{\tcbox[colframe=\cevignettecolor,fontupper={\cevignettefont},cevignettes]{\IfBooleanTF{#1}{\NoAutoSpacing}{}#3}}%
		{algo}{\tcbox[colframe=\cevignettecolor,fontupper={\cevignettefont\ttfamily},cevignettealgo]{\IfBooleanTF{#1}{\NoAutoSpacing}{}#3}}%
		{py}{\tcbox[colframe=\cevignettecolor,fontupper={\cevignettefont\ttfamily},cevignettepy]{\IfBooleanTF{#1}{\NoAutoSpacing}{}#3}}%
		{pypit}{\tcbox[colframe=\cevignettecolor,fontupper={\cevignettefont\ttfamily},cevignettepy]{\piton{#3}}}%
		{pyl}{\tcbox[colframe=\cevignettecolor,fontupper={\cevignettefont\ttfamily},cevignettepy]{\piton{\py{#3}}}}%
		{mpm}{\tcbox[colframe=\cevignettecolor,fontupper={\cevignettefont},cevignetteMPM]{\IfBooleanTF{#1}{\NoAutoSpacing}{}#3}}%
		{grph}{\tcbox[colframe=\cevignettecolor,fontupper={\cevignettefont},cevignettegraph]{\IfBooleanTF{#1}{\NoAutoSpacing}{}#3}}%
		{xcas}{\tcbox[colframe=\cevignettecolor,fontupper={\cevignettefont},cevignettexcas]{\IfBooleanTF{#1}{\NoAutoSpacing}{}#3}}%
		{shell}{\tcbox[colframe=\cevignettecolor,fontupper={\cevignettefont\ttfamily},cevignetteshell]{\IfBooleanTF{#1}{\NoAutoSpacing}{}#3}}%
		{tex}{\tcbox[colframe=\cevignettecolor,fontupper={\cevignettefont\ttfamily},cevignettelatex]{\IfBooleanTF{#1}{\NoAutoSpacing}{}#3}}%
		{sheet}{\tcbox[colframe=\cevignettecolor,fontupper={\cevignettefont},cevignettetableur]{\IfBooleanTF{#1}{\NoAutoSpacing}{}#3}}%
	}\relax%
}

%====DisplaySkip [en]
\defKV[DisplaySkip]{%
	aboveds=\def\ceabovedisplayskip{#1},%
	abovedsshort=\def\ceabovedisplayskipshort{#1},%
	belowdds=\def\cebelowdisplayskip{#1},%
	belowdsshort=\def\cebelowdisplayskipshort{#1},%
	global=\def\globaldisplayskip{#1}
}

\setKVdefault[DisplaySkip]{%
	aboveds={12pt plus 3pt minus 9pt},%
	abovedsshort={0pt plus 3pt},%
	belowdds={12pt plus 3pt minus 9pt},%
	belowdsshort={7pt plus 3pt minus 4pt},%
	global={},%
	shrink=false
}
\NewDocumentCommand\ChangeSpacingDisplaySkip{ O{} }{%
	\restoreKV[DisplaySkip]%
	\setKV[DisplaySkip]{#1}%
	\ifboolKV[DisplaySkip]{shrink}%
		{%
			\AtBeginDocument{%
				\abovedisplayskip=0.33\baselineskip
				\abovedisplayshortskip=0.33\baselineskip
				\belowdisplayskip=0.33\baselineskip
				\belowdisplayshortskip=0.33\baselineskip
			}
		}%
		{%
			\IfStrEq{\globaldisplayskip}{}%
				{%
					\AtBeginDocument{%
						\abovedisplayskip=\ceabovedisplayskip
						\abovedisplayshortskip=\ceabovedisplayskipshort
						\belowdisplayskip=\cebelowdisplayskip
						\belowdisplayshortskip=\cebelowdisplayskipshort
					}
				}%
				{%
					\AtBeginDocument{%
						\abovedisplayskip=\globaldisplayskip
						\abovedisplayshortskip=\globaldisplayskip
						\belowdisplayskip=\globaldisplayskip
						\belowdisplayshortskip=\globaldisplayskip
					}
				}%
		}%
}

%====DisplaySkip [fr]
\defKV[DisplaySkipFr]{%
	Avant=\def\ceabovedisplayskip{#1},%
	AvantS=\def\ceabovedisplayskipshort{#1},%
	Apres=\def\cebelowdisplayskip{#1},%
	ApresS=\def\cebelowdisplayskipshort{#1},%
	Global=\def\globaldisplayskip{#1}
}

\setKVdefault[DisplaySkipFr]{%
	Avant={12pt plus 3pt minus 9pt},%
	AvantS={0pt plus 3pt},%
	Apres={12pt plus 3pt minus 9pt},%
	ApresS={7pt plus 3pt minus 4pt},%
	Global={},%
	Dense=false
}
\NewDocumentCommand\ChangerDisplaySkip{ O{} }{%
	\restoreKV[DisplaySkipFr]%
	\setKV[DisplaySkipFr]{#1}%
	\ifboolKV[DisplaySkipFr]{Dense}%
		{%
			\AtBeginDocument{%
				\abovedisplayskip=0.33\baselineskip
				\abovedisplayshortskip=0.33\baselineskip
				\belowdisplayskip=0.33\baselineskip
				\belowdisplayshortskip=0.33\baselineskip
			}
		}%
		{%
			\IfStrEq{\globaldisplayskip}{}%
				{%
					\AtBeginDocument{%
						\abovedisplayskip=\ceabovedisplayskip
						\abovedisplayshortskip=\ceabovedisplayskipshort
						\belowdisplayskip=\cebelowdisplayskip
						\belowdisplayshortskip=\cebelowdisplayskipshort
					}
				}%
				{%
					\AtBeginDocument{%
						\abovedisplayskip=\globaldisplayskip
						\abovedisplayshortskip=\globaldisplayskip
						\belowdisplayskip=\globaldisplayskip
						\belowdisplayshortskip=\globaldisplayskip
					}
				}%
		}%
}

%====Patchs pas-tableur
\if@pastableur

\RequirePackage{pas-tableur}

\renewcommand{\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.2pt,0)$) -- (cell#2-#3.south east) -- ($(cell#2-#3.north east)+(0,-0.2pt)$);%
	}
	
\renewcommand{\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]%
		\def\pastableur@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%
		\def\pastableur@coord{(#4)}%
	\fi%
	\node[cellstyle] (#2) at \pastableur@coord {\helvbx#5};%
	\fill[grayBottomCell] (#2.south west) rectangle (#2.north east) ;%
	\fill[grayTopCell] (#2.north west) rectangle ($0.5*(#2.south east)+0.5*(#2.north east)$) ;%
	\node[minimum width={#1},minimum height=\line@height,cellstyle] at \pastableur@coord {\helvbx#5};%
}

\NewDocumentCommand\celcouleur{ O{graySepCell!50} m }{%OK
	\draw[draw=none,fill=#1] ($(cell#2.south west)+(0.2pt,0.2pt)$) rectangle ($(cell#2.north east) + (-0.2pt,-0.2pt)$) ;%
}

\defKV[celparam]{align=\def\pastableurfusalign{#1},width=\def\pastableurfuswidth{#1}}
\setKVdefault[celparam]{align=left,width={\col@width}}

\NewDocumentCommand\celfusion{ O{} m m m }{%OK
	\restoreKV[celparam]%
	\setKV[celparam]{#1}%
	\IfStrEq{#4}{}%
		{%
			\draw[draw=none,fill=white] ($(cell#2.south west)+(0.2pt,0.2pt)$) rectangle ($(cell#3.north east) + (-0.2pt,-0.2pt)$);
		}%
		{%
			\draw[draw=none,fill=white] ($(cell#2.south west)+(0.2pt,0.2pt)$) rectangle ($(cell#3.north east) + (-0.2pt,-0.2pt)$) node[midway,text width=\dimexpr\pastableurfuswidth-4pt,align=\pastableurfusalign] {#4};
		}%
}

\NewDocumentCommand\celnumbreak{ m m m }{%
	\def\numpointilles{#1}
	\xdef\numavant{\inteval{\numpointilles-1}}%
	\def\numdebut{#2}\def\numfin{#3}
	\foreach \num@line [remember=\num@line as \lastnum (initially \numavant)] in {\numpointilles}
		{%
			\pastab@draw@cell{\numline@width}{numline\num@line}{3}{numline\lastnum.south east}{\dots}%
		}%
	\foreach \num@line [remember=\num@line as \lastnum (initially \numpointilles)] in {\numdebut,\numfin}
		{%
			\pastab@draw@cell{\numline@width}{numline\num@line}{3}{numline\lastnum.south east}{\num@line}%
		}%
}

\NewDocumentCommand\lignetxt{ s O{} m D<>{1} m }{%3=num ligne,%5=liste
	\IfBooleanTF{#1}%
		{
			\foreach \x [count=\i] in {#5}
			{%
				\xdef\j{\inteval{\i+(#4-1)}}%
				\StrChar{ABCDEFGHIJKLMNOPQRSTUVWXYZ}{\j}[\iltr]%
				\IfEq{\x}{}{}{\celtxt*[#2]{\iltr}{#3}{\x}}%
			}%
		}%
		{%
			\foreach \x [count=\i] in {#5}
			{%
				\xdef\j{\inteval{\i+(#4-1)}}%
				\StrChar{ABCDEFGHIJKLMNOPQRSTUVWXYZ}{\j}[\iltr]%
				\IfEq{\x}{}{}{\celtxt[#2]{\iltr}{#3}{\x}}%
			}%
		}%
}

\NewDocumentCommand\colonnetxt{ s O{} m D<>{1} m }{%3=lettre colonne,%5=liste
	\IfBooleanTF{#1}%
		{
			\foreach \x [count=\i] in {#5}
			{%
				\xdef\j{\inteval{\i+(#4-1)}}
				\IfStrEq{\x}{}{}{\celtxt*[#2]{#3}{\j}{\x}}%
			}%
		}%
		{%
			\foreach \x [count=\i] in {#5}
			{%
				\xdef\j{\inteval{\i+(#4-1)}}
				\IfStrEq{\x}{}{}{\celtxt[#2]{#3}{\j}{\x}}%
			}%
		}%
}

\fi

\endinput