texlive[65659] Master/texmf-dist: profcollege (28jan23)

commits+karl at tug.org commits+karl at tug.org
Sat Jan 28 22:07:06 CET 2023


Revision: 65659
          http://tug.org/svn/texlive?view=revision&revision=65659
Author:   karl
Date:     2023-01-28 22:07:06 +0100 (Sat, 28 Jan 2023)
Log Message:
-----------
profcollege (28jan23)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/profcollege/ProfCollege-doc.pdf
    trunk/Master/texmf-dist/doc/latex/profcollege/ProfCollege-doc.zip
    trunk/Master/texmf-dist/metapost/profcollege/PfCCalculatrice.mp
    trunk/Master/texmf-dist/tex/latex/profcollege/ProfCollege.sty

Modified: trunk/Master/texmf-dist/doc/latex/profcollege/ProfCollege-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/profcollege/ProfCollege-doc.zip
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/metapost/profcollege/PfCCalculatrice.mp
===================================================================
--- trunk/Master/texmf-dist/metapost/profcollege/PfCCalculatrice.mp	2023-01-28 21:06:35 UTC (rev 65658)
+++ trunk/Master/texmf-dist/metapost/profcollege/PfCCalculatrice.mp	2023-01-28 21:07:06 UTC (rev 65659)
@@ -41,7 +41,7 @@
 vardef Test(expr cptk,cptnt)=
   pair Decalage;
   if nblignes mod 2=0:
-    Decalage:=u*((20-length(cptnt)+cptk)*6,-8*(nblignes-1));
+    Decalage:=u*((LargeurEcran,-8*(nblignes-1))-6*(length(cptnt)-cptk,0));
   else:
     Decalage:=u*(decahoriz,-8*(nblignes-1));
     decahoriz:=decahoriz+6;
@@ -175,7 +175,7 @@
   decahoriz:=0;
   nblignes:=nblignes+1;
   path Ecran;
-  Ecran:=(u*(0,-1)--u*(120,-1)--u*(120,7)--u*(0,7)--cycle) shifted(u*(0,-8*(nblignes-1)));
+  Ecran:=(u*(0,-1)--u*(LargeurEcran,-1)--u*(LargeurEcran,7)--u*(0,7)--cycle) shifted(u*(0,-8*(nblignes-1)));
   fill Ecran withcolor if print=true:0.8white else:CouleurEcran fi;
   draw Ecran withcolor if print=true:0.8white else:CouleurEcran fi;
   for k=0 upto length(nt)-1:
@@ -184,16 +184,15 @@
   endfor;
   for k=1 upto NB:
     nblignes:=nblignes+1;
-    Ecran:=(u*(0,-1)--u*(120,-1)--u*(120,7)--u*(0,7)--cycle) shifted(u*(0,-8*(nblignes-1)));
+    Ecran:=(u*(0,-1)--u*(LargeurEcran,-1)--u*(LargeurEcran,7)--u*(0,7)--cycle) shifted(u*(0,-8*(nblignes-1)));
     fill Ecran withcolor if print=true:0.8white else:CouleurEcran fi;
     draw Ecran withcolor if print=true:0.8white else:CouleurEcran fi;
   endfor;
   nblignes:=nblignes+1;
-  Ecran:=(u*(0,-1)--u*(120,-1)--u*(120,7)--u*(0,7)--cycle) shifted(u*(0,-8*(nblignes-1)));
+  Ecran:=(u*(0,-1)--u*(LargeurEcran,-1)--u*(LargeurEcran,7)--u*(0,7)--cycle) shifted(u*(0,-8*(nblignes-1)));
   fill Ecran withcolor if print=true:0.8white else:CouleurEcran fi;
   draw Ecran withcolor if print=true:0.8white else:CouleurEcran fi;
   for k=0 upto length(rep)-1:
-    BlocAffichage;
     Test(k,rep);
   endfor;
 enddef;

Modified: trunk/Master/texmf-dist/tex/latex/profcollege/ProfCollege.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/profcollege/ProfCollege.sty	2023-01-28 21:06:35 UTC (rev 65658)
+++ trunk/Master/texmf-dist/tex/latex/profcollege/ProfCollege.sty	2023-01-28 21:07:06 UTC (rev 65659)
@@ -2,9 +2,9 @@
 % licence    : Released under the LaTeX Project Public License v1.3c
 % or later, see http://www.latex-project.org/lppl.txtf
 \NeedsTeXFormat{LaTeX2e}%
-\def\filedate{2023/01/01}%
+\def\filedate{2023/01/23}%
 \let\PfCfiledate\filedate%
-\def\fileversion{0.99-z-d}%
+\def\fileversion{0.99-z-e}%
 \let\PfCfileversion\fileversion%
 \ProvidesPackage{ProfCollege}[\filedate\space v\fileversion\space Aide pour utiliser LaTeX au college]
 
@@ -348,8 +348,664 @@
 }
 
 %%%
+% Ronde infernale
+%%%
+\newcommand\TestNombrePremier[1]{%
+  % #1 le nombre \`a tester
+  \newcount\anp\newcount\bnp\newcount\cnp%
+  \anp=#1\relax
+  \bnp=2\relax
+  \premier=-1\relax
+  \whiledo{\anp > 1}{%
+    \modulo{\the\anp}{\the\bnp}
+    \ifnum\remainder=0\relax%
+      \global\premier=\numexpr\premier+1\relax%
+      \cnp=\numexpr\anp/\bnp\relax%
+      \anp=\cnp\relax%
+    \else%
+      \bnp=\numexpr\bnp+1\relax%
+    \fi%
+  }%
+}%
+
+\newcommand\PfCRIListeDiviseur[1]{%#1 : nombre entier
+  \newcount\anp\newcount\bnp%
+  \anp=\fpeval{abs(#1)}%
+  \bnp=2\relax%
+  \xdef\PfCRIRetiensListeDiviseurs{}%
+  \ifnum#1=0%
+  \xdef\PfCRIRetiensListeDiviseurs{\fpeval{randint(2,5)},\fpeval{randint(6,9)}}%
+  \else
+  \whiledo{\bnp<\anp}{%
+    \modulo{\the\anp}{\the\bnp}{}%
+    \ifnum\remainder=0%
+    \ifnum#1>0
+    \xdef\PfCRIRetiensListeDiviseurs{\PfCRIRetiensListeDiviseurs \the\bnp,}%
+    \else
+    \xdef\PfCRIRetiensListeDiviseurs{\PfCRIRetiensListeDiviseurs \the\bnp,-\the\bnp,}%
+    \fi
+    \fi%
+    \bnp=\numexpr\bnp+1%
+  }%
+  \ifnum#1>0
+  \xdef\PfCRIRetiensListeDiviseurs{\PfCRIRetiensListeDiviseurs \the\anp,1}
+  \else
+  \xdef\PfCRIRetiensListeDiviseurs{\PfCRIRetiensListeDiviseurs \the\anp,-\the\anp}
+  \fi
+  \fi
+}
+
+\setKVdefault[RondeInfernale]{Solution=false,Relatifs=false,Etapes=4,Perso=false,Cles=false,Vide,Rayon=2.5cm,Graines=false,Rectangle=false}%
+\defKV[RondeInfernale]{Graine=\setKV[RondeInfernale]{Graines}}%
+\defKV[RondeInfernale]{Cle=\setKV[RondeInfernale]{Cles}\setKV[RondeInfernale]{Vide=false}}%
+\defKV[RondeInfernale]{ListeOperations=\setKV[RondeInfernale]{Perso}}%
+\defKV[RondeInfernale]{ListeNombres=\setKV[RondeInfernale]{Perso}}%
+% 
+\NewDocumentCommand\RondeInfernale{o}{%
+  \useKVdefault[RondeInfernale]%
+  \setKV[RondeInfernale]{#1}%
+  % Graine
+  \ifboolKV[RondeInfernale]{Graines}{\PfCGraineAlea{\useKV[RondeInfernale]{Graine}}}{}%
+  % Nombre clé
+  \ifboolKV[RondeInfernale]{Cles}{%
+    \xdef\PfCRINombreCle{\useKV[RondeInfernale]{Cle}}%
+  }{%
+    \ifboolKV[RondeInfernale]{Relatifs}{%
+      \xdef\PfCRIListeNegatifs{-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8,9,10}
+      \MelangeListe{\PfCRIListeNegatifs}{1}
+      \readlist*\PfCRIListeCle{\faa}
+      \xdef\PfCRINombreCle{\PfCRIListeCle[1]}%
+    }{%
+      \xdef\PfCRINombreCle{\fpeval{randint(2,9)}}%
+    }%
+  }%
+  \ifboolKV[RondeInfernale]{Perso}{%
+    \xdef\PfCRIRecupOperations{\useKV[RondeInfernale]{ListeOperations}}%
+    \xdef\PfCRIRecupNombres{\useKV[RondeInfernale]{ListeNombres}}%
+  }{%
+    % On définit les éléments nécessaires
+    \xdef\PfCRIListeToutesOperations{+,-,*,/}%
+    \xdef\PfCRIListeOperationsSansDiv{+,-,*}%
+    \xdef\PfCRIListeOperationsSansMul{+,-,/}%
+    \xdef\PfCRIListeOperationsSimple{+,-}%
+    \xdef\PfCRIRecupOperations{}%
+    \xdef\PfCRIRecupNombres{}%
+    \xdef\PfCRIRecupResultats{}%
+    \xdef\PfCRINombreATester{\PfCRINombreCle}%
+    \xdef\PfCRIRetiensNbEtapes{\useKV[RondeInfernale]{Etapes}}%
+    \setsepchar{,}\ignoreemptyitems%
+    % Liste des opérations jusqu'à l'étape n-1
+    \xintFor* ##1 in{\xintSeq{1}{\fpeval{\useKV[RondeInfernale]{Etapes}-1}}}\do{%
+      \TestNombrePremier{\PfCRINombreATester}\relax%
+      \xintifboolexpr{\premier==0}{%
+        % Définition des opérations
+        \MelangeListe{\PfCRIListeOperationsSansDiv}{1}%
+        \readlist*\PfCRIRetiensLoperation{\faa}%
+        \xdef\PfCRIRecupOperations{\PfCRIRecupOperations \faa}%
+        \xdef\PfCRIOperateur{\fpeval{randint(2,9)}}%
+        \xdef\PfCRIRecupNombres{\PfCRIRecupNombres \PfCRIOperateur,}%
+        \xdef\PfCRIResultat{\fpeval{\PfCRINombreATester\PfCRIRetiensLoperation[1]\PfCRIOperateur}}%
+        \xdef\PfCRIRecupResultats{\PfCRIRecupResultats \PfCRIResultat,}%
+        \xdef\PfCRINombreATester{\PfCRIResultat}%
+      }{%
+        \MelangeListe{\PfCRIListeToutesOperations}{1}%
+        \readlist*\PfCRIRetiensLoperation{\faa}%
+        \xdef\PfCRIRecupOperations{\PfCRIRecupOperations \faa}%
+        \IfStrEq{\PfCRIRetiensLoperation[1]}{/}{%
+          \PfCRIListeDiviseur{\PfCRINombreATester}%
+          \MelangeListe{\PfCRIRetiensListeDiviseurs}{1}%
+          \readlist*\PfCRIRetiensLeDiviseur{\faa}%
+          \xdef\PfCRIOperateur{\PfCRIRetiensLeDiviseur[1]}%
+        }{%
+          \xdef\PfCRIOperateur{\fpeval{randint(2,9)}}%
+        }%
+        \xdef\PfCRIRecupNombres{\PfCRIRecupNombres \PfCRIOperateur,}%
+        \xdef\PfCRIResultat{\fpeval{\PfCRINombreATester\PfCRIRetiensLoperation[1]\PfCRIOperateur}}%
+        \xdef\PfCRIRecupResultats{\PfCRIRecupResultats \PfCRIResultat,}%
+        \xdef\PfCRINombreATester{\PfCRIResultat}%
+      }%
+    }%
+    % Dernière opération
+    \xintifboolexpr{\fpeval{abs(\PfCRINombreATester)-abs(\PfCRINombreCle)}>0}{%
+      \modulo{\PfCRINombreATester}{\PfCRINombreCle}{}%
+      \xintifboolexpr{\remainder==0}{%
+        \MelangeListe{\PfCRIListeOperationsSansMul}{1}%
+        \xdef\PfCRIRecupOperations{\PfCRIRecupOperations \faa}%
+        \ignoreemptyitems%
+        \readlist*\PfCRIRetiensLoperation{\faa}%
+        \IfStrEq{\PfCRIRetiensLoperation[1]}{/}{%
+          \xdef\PfCRINombreATester{\fpeval{\PfCRINombreATester/\PfCRINombreCle}}%
+        }{%
+          \IfStrEq{\PfCRIRetiensLoperation[1]}{-}{%
+            \xdef\PfCRINombreATester{\fpeval{\PfCRINombreATester-\PfCRINombreCle}}%
+          }{%
+            \xdef\PfCRINombreATester{\fpeval{\PfCRINombreCle-\PfCRINombreATester}}%
+          }%
+        }%
+        \xdef\PfCRIRecupNombres{\PfCRIRecupNombres \PfCRINombreATester}%
+      }{%
+        \MelangeListe{\PfCRIListeOperationsSimple}{1}%
+        \xdef\PfCRIRecupOperations{\PfCRIRecupOperations \faa}%
+        \ignoreemptyitems%
+        \readlist*\PfCRIRetiensLoperation{\faa}%
+        \IfStrEq{\PfCRIRetiensLoperation[1]}{-}{%
+          \xdef\PfCRINombreATester{\fpeval{\PfCRINombreATester-\PfCRINombreCle}}%
+        }{%
+          \xdef\PfCRINombreATester{\fpeval{\PfCRINombreCle-\PfCRINombreATester}}%
+        }%
+        \xdef\PfCRIRecupNombres{\PfCRIRecupNombres \PfCRINombreATester}%
+      }%
+    }{%
+      \xintifboolexpr{\fpeval{abs(\PfCRINombreATester)-abs(\PfCRINombreCle)}==0}{%
+        \xdef\PfCRIRecupOperations{\PfCRIRecupOperations *}%
+        \ignoreemptyitems%
+        \readlist*\PfCRIRIListeOperations{\PfCRIRecupOperations}%
+        \xdef\PfCRIRecupNombres{\PfCRIRecupNombres 1}%
+      }{%
+        \xintifboolexpr{\PfCRINombreATester==0}{%
+          \MelangeListe{\PfCRIListeOperationsSimple}{1}%
+          \xdef\PfCRIRecupOperations{\PfCRIRecupOperations \faa}%
+          \ignoreemptyitems%
+          \readlist*\PfCRIRetiensLoperation{\faa}%
+          \IfStrEq{\PfCRIRetiensLoperation[1]}{-}{%
+            \xdef\PfCRINombreATester{\fpeval{\PfCRINombreATester-\PfCRINombreCle}}%
+          }{%
+            \xdef\PfCRINombreATester{\fpeval{\PfCRINombreCle-\PfCRINombreATester}}%
+          }%
+          \xdef\PfCRIRecupNombres{\PfCRIRecupNombres \PfCRINombreATester}%
+        }{%
+          \modulo{\PfCRINombreCle}{\PfCRINombreATester}{}%
+          \xintifboolexpr{\remainder==0}{%-1
+            \MelangeListe{\PfCRIListeToutesOperations}{1}%
+            \xdef\PfCRIRecupOperations{\PfCRIRecupOperations \faa}%
+            \readlist*\PfCRIRetiensLoperation{\faa}%
+            \ignoreemptyitems%
+            \readlist*\PfCRIRIListeOperations{\PfCRIRecupOperations}%
+            \IfStrEq{\PfCRIRetiensLoperation[1]}{*}{%
+              \xdef\PfCRINombreATester{\fpeval{\PfCRINombreCle/\PfCRINombreATester}}%
+              \xdef\PfCRIRecupNombres{\PfCRIRecupNombres \PfCRINombreATester}%
+            }{
+              \IfStrEq{\PfCRIRetiensLoperation[1]}{-}{%
+                \xdef\PfCRINombreATester{\fpeval{\PfCRINombreATester-\PfCRINombreCle}}%
+              }{%
+                \xdef\PfCRINombreATester{\fpeval{\PfCRINombreCle-\PfCRINombreATester}}%
+              }%
+              \xdef\PfCRIRecupNombres{\PfCRIRecupNombres \PfCRINombreATester}%
+            }%
+          }{%
+            \MelangeListe{\PfCRIListeOperationsSimple}{1}%
+            \xdef\PfCRIRecupOperations{\PfCRIRecupOperations \faa}%
+            \ignoreemptyitems%
+            \readlist*\PfCRIRIListeOperations{\PfCRIRecupOperations}%
+            \IfStrEq{\PfCRIRIListeOperations[\PfCRIRetiensNbEtapes]}{-}{%
+              \xdef\PfCRINombreATester{\fpeval{\PfCRINombreATester-\PfCRINombreCle}}%
+            }{%
+              \xdef\PfCRINombreATester{\fpeval{\PfCRINombreCle-\PfCRINombreATester}}%
+            }%
+            \xdef\PfCRIRecupNombres{\PfCRIRecupNombres \PfCRINombreATester}%
+          }%
+        }%
+      }%
+    }%
+  }%
+  \ignoreemptyitems%
+  \readlist*\PfCRIRIOperations{\PfCRIRecupOperations}%
+  \readlist*\PfCRIRINombres{\PfCRIRecupNombres}%
+  \reademptyitems%
+  % On prépare le dessin
+  \xdef\PfCRINombresDessin{}%
+  \xdef\PfCRIOperationsDessin{}%
+  \foreachitem\compteur\in\PfCRIRINombres{%
+    \xintifboolexpr{\PfCRIRINombres[\compteurcnt]<0}{%
+      \xdef\PfCRINombresDessin{\PfCRINombresDessin "(\num{\PfCRIRINombres[\compteurcnt]})",}%
+    }{%
+      \xdef\PfCRINombresDessin{\PfCRINombresDessin "\num{\PfCRIRINombres[\compteurcnt]}",}%
+    }%
+  }%
+  \foreachitem\compteur\in\PfCRIRIOperations{%
+    \xdef\PfCRIOperationsDessin{\PfCRIOperationsDessin "\PfCRIRIOperations[\compteurcnt]",}%
+  }%
+  % On dessine
+  \BuildRondeInfernale{\PfCRINombresDessin}{\PfCRIOperationsDessin}%
+}%
+
+\NewDocumentCommand\BuildRondeInfernale{m m}{%
+  \ifluatex
+  \mplibforcehmode
+  \begin{mplibcode}
+    boolean Vide,Rectangle,Perso;
+    Vide=\useKV[RondeInfernale]{Vide};
+    Rectangle=\useKV[RondeInfernale]{Rectangle};
+    Perso=\useKV[RondeInfernale]{Perso};
+    if Perso:
+    string Depart;
+    Depart=\useKV[RondeInfernale]{Cle};
+    else:
+    numeric Depart;
+    Depart=\PfCRINombreCle;
+    fi;
+
+    numeric Rayon;
+    Rayon=\useKV[RondeInfernale]{Rayon};
+
+    string Nombre[];
+    
+    vardef Compte(text t)=%On compte le nb d'étapes et on retient les nombres
+    nbcase:=0;
+    for p_=t:
+    nbcase:=nbcase+1;
+    Nombre[nbcase]=p_;
+    endfor;
+    enddef;
+
+    vardef AfficheRonde(text t)=%On fait l'affichage des opérations
+    n:=0;
+    for k=1 upto nbcase:
+    fill cercles(rotation(A[k],O,0.5*(360/nbcase)),5mm) withcolor white;
+    endfor;
+    for p_=t:
+    n:=n+1;
+    if p_="*":
+    label(TEX("$\times"&Nombre[n]&"$"),rotation(A[nbcase-n],O,0.5*(360/nbcase)));
+    elseif p_="/":
+    label(TEX("$\div"&Nombre[n]&"$"),rotation(A[nbcase-n],O,0.5*(360/nbcase)));
+    else:
+    label(TEX("$"&p_&Nombre[n]&"$"),rotation(A[nbcase-n],O,0.5*(360/nbcase)));
+        fi;
+    endfor;
+    enddef;
+
+    vardef AfficheRectangle(text t)=%On fait l'affichage des opérations
+    n:=0;
+    for p_=t:
+    n:=n+1;
+    if n=nbcase:
+    if p_="*":
+    label.bot(TEX("$\times"&Nombre[n]&"$"),1/2[A[n-1],A[0]]+u*(0,-1));
+    elseif p_="/":
+    label.bot(TEX("$\div"&Nombre[n]&"$"),1/2[A[n-1],A[0]]+u*(0,-1));
+    else:
+    label.bot(TEX("$"&p_&Nombre[n]&"$"),1/2[A[n-1],A[0]]+u*(0,-1));
+    fi;
+    else:
+    if p_="*":
+    label.top(TEX("$\times"&Nombre[n]&"$"),1/2[A[n-1],A[n]]);
+    elseif p_="/":
+    label.top(TEX("$\div"&Nombre[n]&"$"),1/2[A[n-1],A[n]]);
+    else:
+    label.top(TEX("$"&p_&Nombre[n]&"$"),1/2[A[n-1],A[n]]);
+    fi;
+    fi;
+    endfor;
+    enddef;
+
+    vardef BaseRonde=
+    pair O,A[];
+    O=(0,0);
+    path cc;
+    cc=cercles(O,Rayon);
+    A[0]=pointarc(cc,0);
+    A[nbcase+1]=A[0];
+    for k=1 upto nbcase:
+    A[k]=rotation(A[0],O,k*(360/nbcase));
+    endfor;
+    for k=0 upto nbcase:
+    drawarrow reverse(arccercle(A[k],A[k+1],O) cutbefore cercles(A[k],5mm) cutafter cercles(A[k+1],5mm)) withpen pencircle scaled 1.5;
+    endfor;
+    for k=0 upto nbcase:
+    fill cercles(A[k],5mm) withcolor white;
+    trace cercles(A[k],5mm) withpen pencircle scaled 1.5;
+    endfor;
+    enddef;
+
+    vardef BoiteRectangle=
+    save $;
+    path $;
+    $=u*(0.9,-0.5){dir 0}..{dir 90}(u*(1,-0.4))--(u*(1,0.4)){dir 90}..{dir180}(u*(0.9,0.5))--u*(-0.9,0.5){dir 180}..{dir-90}(u*(-1,0.4))--(u*(-1,-0.4)){dir-90}..{dir0}(u*(-0.9,-0.5))--cycle;
+    $
+    enddef;
+    
+    vardef BaseRectangle=
+    pair O,A[];
+    O=(0,0);
+    A[0]=O;
+    for k=1 upto nbcase:
+    A[k]-A[k-1]=(Rayon+2cm,0);
+    endfor;
+    for k=0 upto nbcase-2:
+    drawarrow (A[k]--A[k+1]) cutbefore (BoiteRectangle shifted A[k]) cutafter (BoiteRectangle shifted A[k+1]) withpen pencircle scaled 1.5;
+    endfor;
+    drawarrow (A[nbcase-1]--(A[nbcase-1]+u*(0,-1))--(A[0]+u*(0,-1))--A[0]) cutbefore (BoiteRectangle shifted A[nbcase-1]) cutafter (BoiteRectangle shifted A[0]) withpen pencircle scaled 1.5;
+    for k=0 upto nbcase-1:
+    trace (BoiteRectangle shifted A[k]) withpen pencircle scaled 1.5;
+    endfor;
+    enddef;
+    
+    Compte(#1);
+    
+    if Rectangle:
+    BaseRectangle;
+    AfficheRectangle(#2);
+    else:
+    BaseRonde;
+    AfficheRonde(#2);
+    fi;
+    if Vide=false:
+    if Perso:
+    label(TEX("$"&Depart&"$"),A[0]);
+    else:
+    label(TEX("$"&decimal(Depart)&"$"),A[0]);
+    fi;
+    fi;
+  \end{mplibcode}
+  \else
+  \begin{mpost}[mpsettings={%
+      boolean Vide,Rectangle,Perso;Vide=\useKV[RondeInfernale]{Vide};Rectangle=\useKV[RondeInfernale]{Rectangle};Perso=\useKV[RondeInfernale]{Perso};if Perso:string Depart;Depart=\useKV[RondeInfernale]{Cle};else:numeric Depart;Depart=\PfCRINombreCle;fi;numeric Rayon;Rayon=\useKV[RondeInfernale]{Rayon};}]
+    string Nombre[];
+    
+    vardef Compte(text t)=%On compte le nb d'étapes et on retient les nombres
+    nbcase:=0;
+    for p_=t:
+    nbcase:=nbcase+1;
+    Nombre[nbcase]=p_;
+    endfor;
+    enddef;
+
+    vardef AfficheRonde(text t)=%On fait l'affichage des opérations
+    n:=0;
+    for k=1 upto nbcase:
+    fill cercles(rotation(A[k],O,0.5*(360/nbcase)),5mm) withcolor white;
+    endfor;
+    for p_=t:
+    n:=n+1;
+    if p_="*":
+    label(LATEX("$\times"&Nombre[n]&"$"),rotation(A[nbcase-n],O,0.5*(360/nbcase)));
+    elseif p_="/":
+    label(LATEX("$\div"&Nombre[n]&"$"),rotation(A[nbcase-n],O,0.5*(360/nbcase)));
+    else:
+    label(LATEX("$"&p_&Nombre[n]&"$"),rotation(A[nbcase-n],O,0.5*(360/nbcase)));
+    fi;
+    endfor;
+    enddef;
+
+    vardef AfficheRectangle(text t)=%On fait l'affichage des opérations
+    n:=0;
+    for p_=t:
+    n:=n+1;
+    if n=nbcase:
+    if p_="*":
+    label.bot(LATEX("$\times"&Nombre[n]&"$"),1/2[A[n-1],A[0]]+u*(0,-1));
+    elseif p_="/":
+    label.bot(LATEX("$\div"&Nombre[n]&"$"),1/2[A[n-1],A[0]]+u*(0,-1));
+    else:
+    label.bot(LATEX("$"&p_&Nombre[n]&"$"),1/2[A[n-1],A[0]]+u*(0,-1));
+    fi;
+    else:
+    if p_="*":
+    label.top(TEX("$\times"&Nombre[n]&"$"),1/2[A[n-1],A[n]]);
+    elseif p_="/":
+    label.top(TEX("$\div"&Nombre[n]&"$"),1/2[A[n-1],A[n]]);
+    else:
+    label.top(TEX("$"&p_&Nombre[n]&"$"),1/2[A[n-1],A[n]]);
+    fi;
+    fi;
+    endfor;
+    enddef;
+
+    vardef BaseRonde=
+    pair O,A[];
+    O=(0,0);
+    path cc;
+    cc=cercles(O,Rayon);
+    A[0]=pointarc(cc,0);
+    A[nbcase+1]=A[0];
+    for k=1 upto nbcase:
+    A[k]=rotation(A[0],O,k*(360/nbcase));
+    endfor;
+    for k=0 upto nbcase:
+    drawarrow reverse(arccercle(A[k],A[k+1],O) cutbefore cercles(A[k],5mm) cutafter cercles(A[k+1],5mm)) withpen pencircle scaled 1.5;
+    endfor;
+    for k=0 upto nbcase:
+    fill cercles(A[k],5mm) withcolor white;
+    trace cercles(A[k],5mm) withpen pencircle scaled 1.5;
+    endfor;
+    enddef;
+
+    vardef BoiteRectangle=
+    save $;
+    path $;
+    $=u*(0.9,-0.5){dir 0}..{dir 90}(u*(1,-0.4))--(u*(1,0.4)){dir 90}..{dir180}(u*(0.9,0.5))--u*(-0.9,0.5){dir 180}..{dir-90}(u*(-1,0.4))--(u*(-1,-0.4)){dir-90}..{dir0}(u*(-0.9,-0.5))--cycle;
+    $
+    enddef;
+    
+    vardef BaseRectangle=
+    pair O,A[];
+    O=(0,0);
+    A[0]=O;
+    for k=1 upto nbcase:
+    A[k]-A[k-1]=(Rayon,0);
+    endfor;
+    for k=0 upto nbcase-2:
+    drawarrow (A[k]--A[k+1]) cutbefore (BoiteRectangle shifted A[k]) cutafter (BoiteRectangle shifted A[k+1]) withpen pencircle scaled 1.5;
+    endfor;
+    drawarrow (A[nbcase-1]--(A[nbcase-1]+u*(0,-1))--(A[0]+u*(0,-1))--A[0]) cutbefore (BoiteRectangle shifted A[nbcase-1]) cutafter (BoiteRectangle shifted A[0]) withpen pencircle scaled 1.5;
+    for k=0 upto nbcase-1:
+    trace (BoiteRectangle shifted A[k]) withpen pencircle scaled 1.5;
+    endfor;
+    enddef;
+    
+    Compte(#1);
+    
+    if Rectangle:
+    BaseRectangle;
+    AfficheRectangle(#2);
+    else:
+    BaseRonde;
+    AfficheRonde(#2);
+    fi;
+    if Vide=false:
+    if Perso:
+    label(TEX("$"&Depart&"$"),A[0]);
+    else:
+    label(TEX("$"&decimal(Depart)&"$"),A[0]);
+    fi;
+    fi;
+  \end{mplibcode}
+  \fi
+}%
+
+
+%%%
+% Message caché
+%%%
+\setKVdefault[Hidden]{TLargeur=5,THauteur=3,Solution=false,Hauteur=70pt,Largeur=120pt,Jeu=false,Solution}
+\defKV[Hidden]{Plateau=\setKV[Hidden]{Jeu}\setKV[Hidden]{Solution=false}}
+
+\newlength\PfCHiddenHeight%
+\newlength\PfCHiddenWidth%
+
+\NewDocumentCommand\MessageCache{o m m}{%1 options 2 questions/réponses 3 message
+  % on récupère les options
+  \useKVdefault[Hidden]%
+  \setKV[Hidden]{#1}%
+  % on définit les dimensions des cases
+  \setlength{\PfCHiddenHeight}{\useKV[Hidden]{Hauteur}+\tabcolsep}%
+  \setlength{\PfCHiddenWidth}{\useKV[Hidden]{Largeur}}%
+  % On récupère les questions
+  \setsepchar[*]{§*/}%
+  \readlist*\PfCHiddenQuestions{#2}%
+  \setsepchar{,}
+  \ifboolKV[Hidden]{Solution}{%
+    % On donne les questions et la phrase
+    \begin{center}
+      \begin{NiceTabular}{*{\useKV[Hidden]{TLargeur}}{m{\PfCHiddenWidth}}}%[hvlines]
+        \xintFor* ##1 in{\xintSeq{1}{\useKV[Hidden]{THauteur}}}\do{%
+          \rule{0pt}{\PfCHiddenHeight}\xintFor* ##2 in {\xintSeq{1}{\useKV[Hidden]{TLargeur}}}\do{%
+            \Block[draw]{1-1}{\PfCHiddenQuestions[\fpeval{\useKV[Hidden]{THauteur}*(##1-1)+##2},1]}\xintifForLast{}{&}
+          }\\
+        }%
+        \CodeAfter%
+        \StrGobbleLeft{#3}{0}[\PhraseCorrection]%
+        \xintFor* ##1 in{\xintSeq{1}{\useKV[Hidden]{THauteur}}}\do{%
+          \xintFor* ##2 in{\xintSeq{1}{\fpeval{\useKV[Hidden]{TLargeur}-1}}}\do{%
+            \StrLeft{\PhraseCorrection}{1}[\LettreAAfficher]\StrGobbleLeft{\PhraseCorrection}{1}[\PhraseCorrection]%
+            \tikz{\node[anchor=south] at (\fpeval{##1+1}-|\fpeval{##2+1}) {\huge\bfseries\LettreAAfficher};}%
+          }%
+        }%
+      \end{NiceTabular}
+    \end{center}
+  }{%
+    % On donne le plateau des solutions
+    \begin{center}
+      \begin{NiceTabular}{*{\useKV[Hidden]{TLargeur}}{m{\PfCHiddenWidth}}}%[hvlines]
+        \xintFor* ##1 in{\xintSeq{1}{\useKV[Hidden]{THauteur}}}\do{%
+          \rule{0pt}{\PfCHiddenHeight}\xintFor* ##2 in {\xintSeq{1}{\useKV[Hidden]{TLargeur}}}\do{%
+            \Block[draw]{1-1}{\PfCHiddenQuestions[\fpeval{\useKV[Hidden]{THauteur}*(##1-1)+##2},2]}\xintifForLast{}{&}
+          }\\
+        }%
+      \end{NiceTabular}
+    \end{center}
+  }
+}%
+
+%%%
+% Puzzle Somme Pyramide
+%%%
+\setKVdefault[ClesPuzzleP]{Largeur=40pt,Etages=4,Graines=false,Solutions=false,Jeu,EnonceQuestion=false,NbLignes=7}
+\defKV[ClesPuzzleP]{Graine=\setKV[ClesPuzzleP]{Graines}}%
+\defKV[ClesPuzzleP]{Solution=\setKV[ClesPuzzleP]{Solutions}\setKV[ClesPuzzleP]{Jeu=false}}%
+\defKV[ClesPuzzleP]{Questions=\setKV[ClesPuzzleP]{EnonceQuestion}\setKV[ClesPuzzleP]{Jeu=false}}%
+\newcounter{PfCPuzzlePcpt}
+\newcounter{PfCPuzzlePavcpt}
+\newlength{\PfCPuzzleP}
+
+\NewDocumentCommand\PuzzlePyramideListeLettres{}{%
+  \setcounter{PfCPuzzlePcpt}{0}%
+  \setcounter{PfCPuzzlePavcpt}{\PfCPuzzlePCptLettre[1]}\Alph{PfCPuzzlePavcpt}, \setcounter{PfCPuzzlePavcpt}{\PfCPuzzlePCptLettre[2]}\Alph{PfCPuzzlePavcpt}, \setcounter{PfCPuzzlePavcpt}{\PfCPuzzlePCptLettre[3]}\Alph{PfCPuzzlePavcpt}, \setcounter{PfCPuzzlePavcpt}{\PfCPuzzlePCptLettre[4]}\Alph{PfCPuzzlePavcpt} et \setcounter{PfCPuzzlePavcpt}{\PfCPuzzlePCptLettre[5]}\Alph{PfCPuzzlePavcpt}%
+}
+
+\NewDocumentCommand\PuzzlePyramide{o m}{%
+  \useKVdefault[ClesPuzzleP]%
+  \setKV[ClesPuzzleP]{#1}%
+  \ifboolKV[ClesPuzzleP]{Graines}{\PfCGraineAlea{\useKV[ClesPuzzleP]{Graine}}}{}%
+  \setsepchar{§}
+  \readlist*\PfCPuzzlePQuestions{#2}%
+  \setsepchar{,}
+  \setlength{\PfCPuzzleP}{\useKV[ClesPuzzleP]{Largeur}}%
+  \xdef\PfCPuzzlePLettres{1}%
+  \xintFor* ##1 in{\xintSeq{2}{\fpeval{\useKV[ClesPuzzleP]{Etages}*(\useKV[ClesPuzzleP]{Etages}+1)/2}}}\do{%
+    \xdef\PfCPuzzlePLettres{\PfCPuzzlePLettres,##1}%
+  }%
+  \MelangeListe{\PfCPuzzlePLettres}{\fpeval{\useKV[ClesPuzzleP]{Etages}*(\useKV[ClesPuzzleP]{Etages}+1)/2}}%
+  \readlist*{\PfCPuzzlePCptLettre}{\faa}%
+  \xdef\PuzzlePyramideLettres{\PuzzlePyramideListeLettres}%
+  \setcounter{PfCPuzzlePcpt}{0}%
+  \ifboolKV[ClesPuzzleP]{Solutions}{%
+%    % Plateau de jeu
+    \begin{center}
+      \begin{NiceTabular}{*{\fpeval{\useKV[ClesPuzzleP]{Etages}*2}}{m{\PfCPuzzleP}}}%[hvlines]
+        \xintFor* ##1 in {\xintSeq{1}{\fpeval{\useKV[ClesPuzzleP]{Etages}}}}\do{%
+          \xintifForLast{\Block[draw]{\useKV[ClesPuzzleP]{NbLignes}-2}{\stepcounter{PfCPuzzlePcpt}\setcounter{PfCPuzzlePavcpt}{\PfCPuzzlePCptLettre[\thePfCPuzzlePcpt]}{\Huge\Alph{PfCPuzzlePavcpt}}}&}{\Block[draw]{\useKV[ClesPuzzleP]{NbLignes}-2}{\stepcounter{PfCPuzzlePcpt}\setcounter{PfCPuzzlePavcpt}{\PfCPuzzlePCptLettre[\thePfCPuzzlePcpt]}{\Huge\Alph{PfCPuzzlePavcpt}}}&&}
+        }\\%
+        \xintFor* ##1 in {\xintSeq{2}{\useKV[ClesPuzzleP]{NbLignes}}}\do{%
+          \xintFor* ##2 in {\xintSeq{1}{\fpeval{\useKV[ClesPuzzleP]{Etages}*2}}}\do{%
+            \xintifForLast{\\}{&}
+          }%
+        }%
+        \xintFor* ##1 in {\xintSeq{1}{\fpeval{\useKV[ClesPuzzleP]{Etages}-1}}}\do{%
+          \xintFor* ##2 in {\xintSeq{1}{##1}}\do{%
+            \xintifForFirst{}{&}
+          }\xintFor* ##2 in {\xintSeq{1}{\fpeval{\useKV[ClesPuzzleP]{Etages}-##1}}}\do{%
+            &\Block[draw]{\useKV[ClesPuzzleP]{NbLignes}-2}{\stepcounter{PfCPuzzlePcpt}\setcounter{PfCPuzzlePavcpt}{\PfCPuzzlePCptLettre[\thePfCPuzzlePcpt]}{\Huge\Alph{PfCPuzzlePavcpt}}}&
+          }%
+          \\
+          \xintFor* ##3 in {\xintSeq{2}{\useKV[ClesPuzzleP]{NbLignes}}}\do{%
+            \xintFor* ##4 in {\xintSeq{1}{\fpeval{\useKV[ClesPuzzleP]{Etages}*2}}}\do{%
+              \xintifForLast{\\}{&}
+            }%
+          }%
+        }%
+      \end{NiceTabular}
+    \end{center}
+  }{%
+    \ifboolKV[ClesPuzzleP]{EnonceQuestion}{%
+      % Plateau des questions
+      \setcounter{PfCPuzzlePcpt}{0}%
+      \begin{center}
+        \begin{NiceTabular}{*{10}{m{\PfCPuzzleP}}}%[hvlines]
+          \xintFor* ##3 in {\xintSeq{1}{\fpeval{ceil(\PfCPuzzlePQuestionslen/5)}}}\do{%
+            \xintFor* ##1 in {\xintSeq{1}{5}}\do{%
+              \xintifForLast{%
+                \Block[draw]{\useKV[ClesPuzzleP]{NbLignes}-2}{%
+                  \stepcounter{PfCPuzzlePcpt}%
+                  \xintifboolexpr{\thePfCPuzzlePcpt>\PfCPuzzlePQuestionslen}{}{%
+                    \xintFor* ##4 in{\xintSeq{1}{\PfCPuzzlePQuestionslen}}\do{%
+                      \xintifboolexpr{\thePfCPuzzlePcpt==\PfCPuzzlePCptLettre[##4]}{\PfCPuzzlePQuestions[##4]}{}%
+                    }%
+                  }%
+                }&%
+              }{%
+                \Block[draw]{\useKV[ClesPuzzleP]{NbLignes}-2}{%
+                  \stepcounter{PfCPuzzlePcpt}%
+                  \xintifboolexpr{\thePfCPuzzlePcpt>\PfCPuzzlePQuestionslen}{}{%
+                    \xintFor* ##4 in{\xintSeq{1}{\PfCPuzzlePQuestionslen}}\do{%
+                      \xintifboolexpr{\thePfCPuzzlePcpt==\PfCPuzzlePCptLettre[##4]}{\PfCPuzzlePQuestions[##4]}{}%
+                    }%
+                  }%
+                }%
+                &&%
+              }%
+            }\\%
+            \xintFor* ##1 in {\xintSeq{2}{\useKV[ClesPuzzleP]{NbLignes}}}\do{%
+              \xintFor* ##2 in {\xintSeq{1}{10}}\do{%
+                \xintifForLast{\\}{&}
+              }%
+            }%
+          }%
+          \CodeAfter
+          \setcounter{PfCPuzzlePcpt}{0}%
+          \xintFor* ##1 in {\xintSeq{1}{\fpeval{ceil(\PfCPuzzlePQuestionslen/5)}}}\do{%
+            \xintFor* ##2 in {\xintSeq{1}{5}}\do{%
+              \tikz{\node[anchor={north west},xshift=1mm,yshift=-1mm] at (\fpeval{(##1-1)*\useKV[ClesPuzzleP]{NbLignes}+1}-|\fpeval{2*##2-1}) {\stepcounter{PfCPuzzlePcpt}\Large\bfseries\Alph{PfCPuzzlePcpt}};}%
+              \tikz{\node[anchor={south east},xshift=-2mm,yshift=-2mm,rectangle,draw] at (\fpeval{##1*\useKV[ClesPuzzleP]{NbLignes}}-|\fpeval{2*##2+1}) {\large\bfseries\hbox to 1.2\PfCPuzzleP{\rule{0pt}{1.8ex}}};}%
+            }%
+          }%
+        \end{NiceTabular}
+      \end{center}%
+    }{%
+      % Plateau de jeu
+      \begin{center}
+        \begin{NiceTabular}{*{\fpeval{\useKV[ClesPuzzleP]{Etages}*2}}{m{\PfCPuzzleP}}}%[hvlines]
+          \xintFor* ##1 in {\xintSeq{1}{\fpeval{\useKV[ClesPuzzleP]{Etages}}}}\do{%
+            \xintifForLast{\Block[draw]{\useKV[ClesPuzzleP]{NbLignes}-2}{\stepcounter{PfCPuzzlePcpt}\setcounter{PfCPuzzlePavcpt}{\PfCPuzzlePCptLettre[\thePfCPuzzlePcpt]}{\Huge\Alph{PfCPuzzlePavcpt}}}&}{\Block[draw]{\useKV[ClesPuzzleP]{NbLignes}-2}{\stepcounter{PfCPuzzlePcpt}\setcounter{PfCPuzzlePavcpt}{\PfCPuzzlePCptLettre[\thePfCPuzzlePcpt]}{\Huge\Alph{PfCPuzzlePavcpt}}}&&}
+          }\\%
+          \xintFor* ##1 in {\xintSeq{2}{\useKV[ClesPuzzleP]{NbLignes}}}\do{%
+            \xintFor* ##2 in {\xintSeq{1}{\fpeval{\useKV[ClesPuzzleP]{Etages}*2}}}\do{%
+              \xintifForLast{\\}{&}
+            }%
+          }%
+          \xintFor* ##1 in {\xintSeq{1}{\fpeval{\useKV[ClesPuzzleP]{Etages}-1}}}\do{%
+            \xintFor* ##2 in {\xintSeq{1}{##1}}\do{%
+              \xintifForFirst{}{&}
+            }\xintFor* ##2 in {\xintSeq{1}{\fpeval{\useKV[ClesPuzzleP]{Etages}-##1}}}\do{%
+              &\Block[draw]{\useKV[ClesPuzzleP]{NbLignes}-2}{}&
+            }%
+            \\
+            \xintFor* ##3 in {\xintSeq{2}{\useKV[ClesPuzzleP]{NbLignes}}}\do{%
+              \xintFor* ##4 in {\xintSeq{1}{\fpeval{\useKV[ClesPuzzleP]{Etages}*2}}}\do{%
+                \xintifForLast{\\}{&}
+              }%
+            }%
+          }%
+        \end{NiceTabular}
+      \end{center}
+    }%
+  }%
+}%
+
+%%%
 % Calisson
-%
+%%%
 \setKVdefault[Calisson]{Taille=3,Solution=false,Rayon=5cm,Couleur=red}%
 
 \def\UpdatetoksCalissong#1\nil{\addtotok\tokcalissonlistetracesg{,"#1"}}%
@@ -2595,8 +3251,13 @@
   \setsepchar[*]{,*/}%
   \ignoreemptyitems
   \readlist*\ListePfCEngrenages{#2}%
-  \foreachitem\compteur\in\ListePfCEngrenages{\expandafter\UpdatetoksEngrenages\compteur\nil}%
-  \BuildEngrenages{\the\tokPfCEngrenages}%
+  \setsepchar{,}
+  \xdef\PfCFooEngrenages{}
+  % \foreachitem\compteur\in\ListePfCEngrenages{\expandafter\UpdatetoksEngrenages\compteur\nil}%
+  \foreachitem\compteur\in\ListePfCEngrenages{%
+    \xdef\PfCFooEngrenages{\PfCFooEngrenages \ListePfCEngrenages[\compteurcnt,1],\ListePfCEngrenages[\compteurcnt,2],}%
+  }%
+  \BuildEngrenages{\PfCFooEngrenages}%
 }%
 
 \NewDocumentCommand\BuildEngrenages{m}{%
@@ -9212,7 +9873,7 @@
     \StrLen{\ListeMotsEmpiles[\compteurcnt,2]}[\LongueurMot]%
     \xintifboolexpr{\ListeMotsEmpilesMax<\fpeval{\ListeMotsEmpiles[\compteurcnt,1]+\LongueurMot}}{\xdef\ListeMotsEmpilesMax{\fpeval{\ListeMotsEmpiles[\compteurcnt,1]+\LongueurMot}}}{}%
   }%
-  \begin{NiceTabular}{c|*{\fpeval{\ListeMotsEmpilesMax}}{m{0.5em}}}%
+  \begin{NiceTabular}{c|*{\fpeval{\ListeMotsEmpilesMax}}{m{10pt}}}%
     \Block{1-\fpeval{\useKV[ClesMotEmpile]{Colonne}+2}}{}\xintFor* ##1 in {\xintSeq {1}{\fpeval{\useKV[ClesMotEmpile]{Colonne}}}}\do{&}&$\downarrow$\xintFor* ##1 in {\xintSeq {1}{\fpeval{\ListeMotsEmpilesMax-\useKV[ClesMotEmpile]{Colonne}-1}}}\do{&}\\
     \xintFor* ##1 in {\xintSeq {1}{\fpeval{\ListeMotsEmpileslen}}}\do{%
       \rule[-1.2ex]{0pt}{3.8ex}\stepcounter{CompteurMotEmpile}\Alph{CompteurMotEmpile}&\Block{1-\fpeval{\ListeMotsEmpiles[##1,1]}}{}\xintFor* ##2 in {\xintSeq {1}{\fpeval{\ListeMotsEmpiles[##1,1]}}}\do{%
@@ -9660,24 +10321,44 @@
   }%
 }%
 
-%%% Dessin Gradue %%%
-\setKVdefault[DessinGradue]{Lignes=10,Debut=-5,Fin=5,Pas=10,Solution=false,EcartVertical=1.5,LignesIdentiques,Longueur=10,Echelle=1,Droites=false,DemiDroites=false}
+%%%
+% Dessin Gradue
+%%%
+\setKVdefault[DessinGradue]{Lignes=10,Debut=-5,Fin=5,Pas=10,Solution=false,EcartVertical=1.5,LignesIdentiques,Longueur=10,Echelle=1,Droites=false,DemiDroites=false,OrigineVariable=false,Code=false}
+\defKV[DessinGradue]{Traces=\setKV[DessinGradue]{Code}}%
 
-\def\TraceDessinGradue#1#2#3#4#5#6{%
+\def\TraceDessinGradueComplet#1#2#3{%
   \ifluatex
   \mplibforcehmode
   \begin{mplibcode}
+    % Paramètres
+    LongueurLigne=\useKV[DessinGradue]{Longueur};
+    EcartVertical=\useKV[DessinGradue]{EcartVertical};
+    Pas:=\useKV[DessinGradue]{Pas};
+    NbLignes=\useKV[DessinGradue]{Lignes};
+    Echelle=\useKV[DessinGradue]{Echelle};
+    Debut:=\useKV[DessinGradue]{Debut};
+    Fin:=\useKV[DessinGradue]{Fin};
+    
+    boolean Solution,Droites,DemiDroites,LignesIdentiques,OrigineVariable,Code;
+    Solution=\useKV[DessinGradue]{Solution};
+    LignesIdentiques:=\useKV[DessinGradue]{LignesIdentiques};
+    OrigineVariable:=\useKV[DessinGradue]{OrigineVariable};
+    Droites=\useKV[DessinGradue]{Droites};
+    DemiDroites=\useKV[DessinGradue]{DemiDroites};
+    Code=\useKV[DessinGradue]{Code};
+
     pair La,Lb,Lab[];
     pair A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,A',B',C',D',E',F',G',H',I',J',K',L',M',N',O',P',Q',R',S',T',U',V',W',X',Y',Z',A'',B'',C'',D'',E'',F'',G'',H'',I'',J'',K'',L'',M'',N'',O'',P'',Q'',R'',S'',T'',U'',V'',W'',X'',Y'',Z'';
+    
     La=(0,0);
     Lb-La=u*(\useKV[DessinGradue]{Longueur},0);
-    boolean Solution;
-    Solution=\useKV[DessinGradue]{Solution};
-    for k=0 upto #4:
-    Lab[k]=(k/#4)[La,Lb];
-    endfor;
-    picture EnsembleLignes,Lignes;
-    Lignes=image(
+
+    % On définit une fonction pour tracer les lignes en fonction du pas "Partage"
+    vardef TraceLignes(expr Partage)=
+    save RecupLigne;
+    picture RecupLigne;
+    RecupLigne=image(
     if \useKV[DessinGradue]{Droites}:
     drawarrow 1.05[Lb,La]--1.05[La,Lb];
     elseif \useKV[DessinGradue]{DemiDroites}:
@@ -9685,27 +10366,19 @@
     else:
     trace segment(La,Lb);
     fi;
-    for k=0 upto #4:
-    trace (Lab[k]+u*(0,-0.1))--(Lab[k]+u*(0,0.1));
+    for kl=0 upto Partage:
+    Lab[kl]:=(kl/Partage)[La,Lb];
+    trace (Lab[kl]+u*(0,-0.1))--(Lab[kl]+u*(0,0.1));
     endfor;
-    labeloffset:=labeloffset*1.5;
-    label.top(TEX("\num{"&decimal(#2)&"}"),La);
-    label.top(TEX("\num{"&decimal(#3)&"}"),Lb);
-    labeloffset:=labeloffset/1.5;
     );
-    EnsembleLignes=image(
-    if Solution:
-    drawoptions(withcolor 0.5white);
-    fi;
-    for k=0 upto #1-1:
-    trace Lignes shifted(k*u*(0,-\useKV[DessinGradue]{EcartVertical}));
-    label(TEX("(\num{"&decimal(k+1)&"})"),La+u*(-1.5,-k*\useKV[DessinGradue]{EcartVertical}));
-    endfor;
-    drawoptions();
-    if Solution:
+    RecupLigne
+    enddef;
+
+    % On définit une fonction pour nommer les points nécessaires.
+    vardef DefinirPoints(text t)=
+    numeric nblignes,nbpas;
     n:=0;
-    numeric nblignes,nbpas;
-    for p_=#5:
+    for p_=t:
     n:=n+1;
     if (n mod 3)=1:
     nblignes:=p_;
@@ -9712,55 +10385,137 @@
     elseif (n mod 3)=2:
     nbpas:=p_;
     elseif (n mod 3)=0:
-    p_=(nbpas/#4)[La,Lb] shifted(u*(0,(nblignes-1)*(-\useKV[DessinGradue]{EcartVertical})));
+    p_=(nbpas/TotalPas[nblignes])[La,Lb] shifted(u*(0,(nblignes-1)*(-EcartVertical)));
     fi;
     endfor;
-    for p_=#6:
+    enddef;
+
+    % On détermine le nombre de lignes et les origines particulières
+    pair OrigA[],OrigB[];
+    if LignesIdentiques:
+    for k=1 upto NbLignes:
+    TotalPas[k]:=Pas;
+    OrigA[k]=(Debut,0);
+    OrigB[k]=(Fin,TotalPas[k]);
+    endfor;
+    else:
+    if OrigineVariable:
+    n:=0;
+    for p_=#1:
+    n:=n+1;
+    OrigA[n]:=p_;
+    TotalPas[n]:=Pas;
+    endfor;
+    NbLignes:=n/2;
+    else:
+    n:=0;
+    for p_=#1:
+    n:=n+1;
+    TotalPas[n]=bluepart(p_);
+    OrigA[n]=(redpart(p_),0);
+    OrigB[n]=(greenpart(p_),TotalPas[n]);
+    endfor;
+    NbLignes:=n;
+    fi;
+    fi;
+
+    picture EnsembleLignes;
+
+    DefinirPoints(#2);
+    
+    EnsembleLignes=image(
+    if Solution:
+    drawoptions(withcolor 0.5white);
+    fi;
+    % On trace les lignes et on labelise le numéro de la ligne.
+    for k=0 upto NbLignes-1:
+    trace TraceLignes(TotalPas[k+1]) shifted(k*u*(0,-EcartVertical));
+    if Droites:
+    label.lft(TEX("(\num{"&decimal(k+1)&"})"),1.05[Lb,La] shifted(k*u*(0,-EcartVertical)));
+    else:
+    label.lft(TEX("(\num{"&decimal(k+1)&"})"),La shifted(k*u*(0,-EcartVertical)));
+    fi;
+    endfor;
+    % On labelise les origines
+    labeloffset:=labeloffset*1.5;
+    for k=0 upto NbLignes-1:
+    if OrigineVariable:
+    label.top(TEX("\num{"&decimal(xpart(OrigA[2*k+1]))&"}"),(ypart(OrigA[2*k+1])/Pas)[La,Lb]+u*(0,-k*EcartVertical));
+    label.top(TEX("\num{"&decimal(xpart(OrigA[2*(k+1)]))&"}"),(ypart(OrigA[2*(k+1)])/Pas)[La,Lb]+u*(0,-k*EcartVertical));
+    else:
+    label.top(TEX("\num{"&decimal(xpart(OrigA[k+1]))&"}"),La+u*(0,-k*EcartVertical));
+    label.top(TEX("\num{"&decimal(xpart(OrigB[k+1]))&"}"),Lb+u*(0,-k*EcartVertical));
+    fi;
+    endfor;
+    drawoptions();
+    labeloffset:=labeloffset/1.5;
+
+    % On trace la solution
+    if Solution:
+    for p_=#3:
     trace p_ withpen pencircle scaled 1.5;
     endfor;
     fi;
+    % On ajoute des tracés si nécessaire
+    if Code:
+    \useKV[DessinGradue]{Traces};
+    fi;
     );
     trace EnsembleLignes scaled \useKV[DessinGradue]{Echelle};
   \end{mplibcode}
   \else
-  \begin{mpost}[mpsettings={numeric LongueurLigne; LongueurLigne=\useKV[DessinGradue]{Longueur};numeric EcartVertical; EcartVertical=\useKV[DessinGradue]{EcartVertical}; numeric Echelle; Echelle=\useKV[DessinGradue]{Echelle}; boolean Solution,Droites,DemiDroites; Solution=\useKV[DessinGradue]{Solution};Droites=\useKV[DessinGradue]{Droites};DemiDroites=\useKV[DessinGradue]{DemiDroites};}]
+  \begin{mpost}[mpsettings={%
+    LongueurLigne=\useKV[DessinGradue]{Longueur};
+    EcartVertical=\useKV[DessinGradue]{EcartVertical};
+    Pas:=\useKV[DessinGradue]{Pas};
+    NbLignes=\useKV[DessinGradue]{Lignes};
+    Echelle=\useKV[DessinGradue]{Echelle};
+    Debut:=\useKV[DessinGradue]{Debut};
+    Fin:=\useKV[DessinGradue]{Fin};
+    boolean Solution,Droites,DemiDroites,LignesIdentiques,OrigineVariable,Code;
+    Solution=\useKV[DessinGradue]{Solution};
+    LignesIdentiques:=\useKV[DessinGradue]{LignesIdentiques};
+    OrigineVariable:=\useKV[DessinGradue]{OrigineVariable};
+    Droites=\useKV[DessinGradue]{Droites};
+    DemiDroites=\useKV[DessinGradue]{DemiDroites};
+    Code=\useKV[DessinGradue]{Code};
+    vardef EffectuerLesTraces=
+    if Code:
+    \useKV[DessinGradue]{Traces};
+    fi;
+    enddef;
+    }]
     pair La,Lb,Lab[];
     pair A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,A',B',C',D',E',F',G',H',I',J',K',L',M',N',O',P',Q',R',S',T',U',V',W',X',Y',Z',A'',B'',C'',D'',E'',F'',G'',H'',I'',J'',K'',L'',M'',N'',O'',P'',Q'',R'',S'',T'',U'',V'',W'',X'',Y'',Z'';
+    
     La=(0,0);
-    Lb-La=u*(LongueurLigne,0);
-    for k=0 upto #4:
-    Lab[k]=(k/#4)[La,Lb];
-    endfor;
-    picture EnsembleLignes,Lignes;
-    Lignes=image(
-    if Droites:
+    Lb-La=u*(\useKV[DessinGradue]{Longueur},0);
+
+    % On définit une fonction pour tracer les lignes en fonction du pas "Partage"
+    vardef TraceLignes(expr Partage)=
+    save RecupLigne;
+    picture RecupLigne;
+    RecupLigne=image(
+    if \useKV[DessinGradue]{Droites}:
     drawarrow 1.05[Lb,La]--1.05[La,Lb];
-    elseif DemiDroites:
+    elseif \useKV[DessinGradue]{DemiDroites}:
     drawarrow La--1.05[La,Lb];
     else:
     trace segment(La,Lb);
     fi;
-    for k=0 upto #4:
-    trace (Lab[k]+u*(0,-0.1))--(Lab[k]+u*(0,0.1));
+    for kl=0 upto Partage:
+    Lab[kl]:=(kl/Partage)[La,Lb];
+    trace (Lab[kl]+u*(0,-0.1))--(Lab[kl]+u*(0,0.1));
     endfor;
-    labeloffset:=labeloffset*1.5;
-    label.top(LATEX("\num{"&decimal(#2)&"}"),La);
-    label.top(LATEX("\num{"&decimal(#3)&"}"),Lb);
-    labeloffset:=labeloffset/1.5;
     );
-    EnsembleLignes=image(
-    if Solution:
-    drawoptions(withcolor 0.5white);
-    fi;
-    for k=0 upto #1-1:
-    trace Lignes shifted(k*u*(0,-EcartVertical));
-    label(LATEX("(\num{"&decimal(k+1)&"})"),La+u*(-1.5,-k*EcartVertical));
-    endfor;
-    drawoptions();
-    if Solution:
+    RecupLigne
+    enddef;
+
+    % On définit une fonction pour nommer les points nécessaires.
+    vardef DefinirPoints(text t)=
+    numeric nblignes,nbpas;
     n:=0;
-    numeric nblignes,nbpas;
-    for p_=#5:
+    for p_=t:
     n:=n+1;
     if (n mod 3)=1:
     nblignes:=p_;
@@ -9767,177 +10522,119 @@
     elseif (n mod 3)=2:
     nbpas:=p_;
     elseif (n mod 3)=0:
-    p_=(nbpas/#4)[La,Lb] shifted(u*(0,(nblignes-1)*(-EcartVertical)));
+    p_=(nbpas/TotalPas[nblignes])[La,Lb] shifted(u*(0,(nblignes-1)*(-EcartVertical)));
     fi;
     endfor;
-    for p_=#6:
-    trace p_ withpen pencircle scaled 1.5;
+    enddef;
+
+    % On détermine le nombre de lignes et les origines particulières
+    pair OrigA[],OrigB[];
+    if LignesIdentiques:
+    for k=1 upto NbLignes:
+    TotalPas[k]:=Pas;
+    OrigA[k]=(Debut,0);
+    OrigB[k]=(Fin,TotalPas[k]);
     endfor;
-    fi;
-    );
-    trace EnsembleLignes scaled Echelle;
-  \end{mpost}
-  \fi
-}
-
-\def\TraceDessinGradueMul#1#2#3{%
-  \ifluatex
-  \mplibforcehmode
-  \begin{mplibcode}
-    pair La,Lb,Lab[];
-    La=(0,0);
-    pair A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,A',B',C',D',E',F',G',H',I',J',K',L',M',N',O',P',Q',R',S',T',U',V',W',X',Y',Z',A'',B'',C'',D'',E'',F'',G'',H'',I'',J'',K'',L'',M'',N'',O'',P'',Q'',R'',S'',T'',U'',V'',W'',X'',Y'',Z'';
-    Lb-La=u*(\useKV[DessinGradue]{Longueur},0);
-    EcartVertical=\useKV[DessinGradue]{EcartVertical};
-    boolean Solution;
-    Solution=\useKV[DessinGradue]{Solution};
-    picture EnsembleLignes,Lignes;
-    EnsembleLignes=image(
-    if Solution:
-    drawoptions(withcolor 0.5white);
-    fi;
+    else:
+    if OrigineVariable:
     n:=0;
-    m:=0;
     for p_=#1:
     n:=n+1;
-    if \useKV[DessinGradue]{Droites}:
-    drawarrow (1.05[Lb,La]--1.05[La,Lb]) shifted((n-1)*u*(0,-EcartVertical));
-    elseif \useKV[DessinGradue]{DemiDroites}:
-    drawarrow (La--1.05[La,Lb]) shifted((n-1)*u*(0,-EcartVertical));
+    OrigA[n]:=p_;
+    TotalPas[n]:=Pas;
+    endfor;
+    NbLignes:=n/2;
     else:
-    trace segment(La,Lb) shifted((n-1)*u*(0,-EcartVertical));
-    fi;
-    label(TEX("(\num{"&decimal(n)&"})"),La+u*(-1.5,-(n-1)*EcartVertical));
-    for k=0 upto bluepart(p_):
-    m:=bluepart(p_);
-    retienspas[n]:=m;
-    Lab[k]:=(k/m)[La,Lb];
-    trace ((Lab[k]+u*(0,-0.1))--(Lab[k]+u*(0,0.1))) shifted((n-1)*u*(0,-EcartVertical));
-    endfor;
-    labeloffset:=labeloffset*1.5;
-    label.top(TEX("\num{"&decimal(redpart(p_))&"}"),La shifted((n-1)*u*(0,-EcartVertical)));
-    label.top(TEX("\num{"&decimal(greenpart(p_))&"}"),Lb shifted((n-1)*u*(0,-EcartVertical)));
-    labeloffset:=labeloffset/1.5;
-    endfor;
-    drawoptions();
-    if Solution:
     n:=0;
-    numeric nblignes,nbpas;
-    for p_=#2:
+    for p_=#1:
     n:=n+1;
-    if (n mod 3)=1:
-    nblignes:=p_;
-    elseif (n mod 3)=2:
-    nbpas:=p_;
-    elseif (n mod 3)=0:
-    p_=(nbpas/retienspas[nblignes])[La,Lb] shifted(u*(0,(nblignes-1)*(-\useKV[DessinGradue]{EcartVertical})));
-    fi;
+    TotalPas[n]=bluepart(p_);
+    OrigA[n]=(redpart(p_),0);
+    OrigB[n]=(greenpart(p_),TotalPas[n]);
     endfor;
-    %Differents traces
-    for p_=#3:
-    trace p_ withpen pencircle scaled 1.5;
-    endfor;
+    NbLignes:=n;
     fi;
-    );
-    trace EnsembleLignes scaled \useKV[DessinGradue]{Echelle};
-  \end{mplibcode}
-  \else
-  \begin{mpost}[mpsettings={numeric LongueurLigne; LongueurLigne=\useKV[DessinGradue]{Longueur};numeric EcartVertical; EcartVertical=\useKV[DessinGradue]{EcartVertical}; numeric Echelle; Echelle=\useKV[DessinGradue]{Echelle}; boolean Solution,Droites,DemiDroites; Solution=\useKV[DessinGradue]{Solution}; Droites=\useKV[DessinGradue]{Droites}; DemiDroites=\useKV[DessinGradue]{DemiDroites};}]
-    pair La,Lb,Lab[];
-    La=(0,0);
-    pair A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,A',B',C',D',E',F',G',H',I',J',K',L',M',N',O',P',Q',R',S',T',U',V',W',X',Y',Z',A'',B'',C'',D'',E'',F'',G'',H'',I'',J'',K'',L'',M'',N'',O'',P'',Q'',R'',S'',T'',U'',V'',W'',X'',Y'',Z'';
-    Lb-La=u*(LongueurLigne,0);
-    picture EnsembleLignes,Lignes;
+    fi;
+
+    picture EnsembleLignes;
+
+    DefinirPoints(#2);
+    
     EnsembleLignes=image(
     if Solution:
     drawoptions(withcolor 0.5white);
     fi;
-    n:=0;
-    m:=0;
-    for p_=#1:
-    n:=n+1;
+    % On trace les lignes et on labelise le numéro de la ligne.
+    for k=0 upto NbLignes-1:
+    trace TraceLignes(TotalPas[k+1]) shifted(k*u*(0,-EcartVertical));
     if Droites:
-    drawarrow (1.05[Lb,La]--1.05[La,Lb]) shifted((n-1)*u*(0,-EcartVertical));
-    elseif DemiDroites:
-    drawarrow (La--1.05[La,Lb]) shifted((n-1)*u*(0,-EcartVertical));
+    label.lft(LATEX("(\num{"&decimal(k+1)&"})"),1.05[Lb,La] shifted(k*u*(0,-EcartVertical)));
     else:
-    trace segment(La,Lb) shifted((n-1)*u*(0,-EcartVertical));
+    label.lft(LATEX("(\num{"&decimal(k+1)&"})"),La shifted(k*u*(0,-EcartVertical)));
     fi;
-    label(LATEX("(\num{"&decimal(n)&"})"),La+u*(-1.5,-(n-1)*EcartVertical));
-    for k=0 upto bluepart(p_):
-    m:=bluepart(p_);
-    retienspas[n]:=m;
-    Lab[k]:=(k/m)[La,Lb];
-    trace ((Lab[k]+u*(0,-0.1))--(Lab[k]+u*(0,0.1))) shifted((n-1)*u*(0,-EcartVertical));
     endfor;
+    % On labelise les origines
     labeloffset:=labeloffset*1.5;
-    label.top(LATEX("\num{"&decimal(redpart(p_))&"}"),La shifted((n-1)*u*(0,-EcartVertical)));
-    label.top(LATEX("\num{"&decimal(greenpart(p_))&"}"),Lb shifted((n-1)*u*(0,-EcartVertical)));
-    labeloffset:=labeloffset/1.5;
+    for k=0 upto NbLignes-1:
+    if OrigineVariable:
+    label.top(LATEX("\num{"&decimal(xpart(OrigA[2*k+1]))&"}"),(ypart(OrigA[2*k+1])/Pas)[La,Lb]+u*(0,-k*EcartVertical));
+    label.top(LATEX("\num{"&decimal(xpart(OrigA[2*(k+1)]))&"}"),(ypart(OrigA[2*(k+1)])/Pas)[La,Lb]+u*(0,-k*EcartVertical));
+    else:
+    label.top(LATEX("\num{"&decimal(xpart(OrigA[k+1]))&"}"),La+u*(0,-k*EcartVertical));
+    label.top(LATEX("\num{"&decimal(xpart(OrigB[k+1]))&"}"),Lb+u*(0,-k*EcartVertical));
+    fi;
     endfor;
     drawoptions();
+    labeloffset:=labeloffset/1.5;
+    
+    % On trace la solution
     if Solution:
-    n:=0;
-    numeric nblignes,nbpas;
-    for p_=#2:
-    n:=n+1;
-    if (n mod 3)=1:
-    nblignes:=p_;
-    elseif (n mod 3)=2:
-    nbpas:=p_;
-    elseif (n mod 3)=0:
-    p_=(nbpas/retienspas[nblignes])[La,Lb] shifted(u*(0,(nblignes-1)*(-EcartVertical)));
-    fi;
-    endfor;
-    %Differents traces
     for p_=#3:
     trace p_ withpen pencircle scaled 1.5;
     endfor;
     fi;
+    % On ajoute des tracés si nécessaire
+    if Code:
+    EffectuerLesTraces;
+    fi;
     );
-    trace EnsembleLignes scaled Echelle;
+    trace EnsembleLignes scaled \useKV[DessinGradue]{Echelle};
   \end{mpost}
   \fi
-}
+}%
 
-\def\UpdateLignes#1/#2/#3\nil{\addtotok\toklisteptsgrad{#1,#3,#2,}}
-\def\UpdateTraces#1\nil{\addtotok\toklistetracesgrad{#1,}}
-\def\UpdateDefLignes#1/#2/#3\nil{\addtotok\toklistedefligne{(#1,#2,#3),}}
-\def\UpdateDefDroites#1/#2/#3/#4\nil{\addtotok\toklistedefligne{(#1,#2,#3),#4,}}
+\def\UpdateLignes#1/#2/#3\nil{\addtotok\toklisteptsgrad{#1,#3,#2,}}%
+\def\UpdateTraces#1\nil{\addtotok\toklistetracesgrad{#1,}}%
+\def\UpdateDefLignes#1/#2/#3\nil{\addtotok\toklistedefligne{(#1,#2,#3),}}%
 
 \newcommand\DessinGradue[4][]{%
   \useKVdefault[DessinGradue]%
   \setKV[DessinGradue]{#1}%
+  \newtoks\toklisteptsgrad%
+  \newtoks\toklistetracesgrad%
+  % On retiens les données pour la solution
+  \setsepchar[*]{,*/}%
+  \readlist\ListePG{#3}%
+  \setsepchar[*]{§*/}%
+  \readlist\ListeTraces{#4}%
+  \foreachitem\compteur\in\ListePG{\expandafter\UpdateLignes\compteur\nil}%
+  \foreachitem\compteur\in\ListeTraces{\expandafter\UpdateTraces\compteur\nil}%
   \ifboolKV[DessinGradue]{LignesIdentiques}{%
-    \newtoks\toklisteptsgrad%
-    \newtoks\toklistetracesgrad%
-    \ifboolKV[DessinGradue]{Solution}{%
-      \setsepchar[*]{,*/}%
-      \readlist\ListePG{#3}%
-      \setsepchar[*]{§*/}%
-      \readlist\ListeTraces{#4}%
-      \foreachitem\compteur\in\ListePG{\expandafter\UpdateLignes\compteur\nil}%
-      \foreachitem\compteur\in\ListeTraces{\expandafter\UpdateTraces\compteur\nil}%
-    }{}%
-    \TraceDessinGradue{\useKV[DessinGradue]{Lignes}}{\useKV[DessinGradue]{Debut}}{\useKV[DessinGradue]{Fin}}{\useKV[DessinGradue]{Pas}}{\the\toklisteptsgrad}{\the\toklistetracesgrad}%
+    \TraceDessinGradueComplet{}{\the\toklisteptsgrad}{\the\toklistetracesgrad}%
   }{%
     \setsepchar[*]{,*/}%
     \readlist\ListeDefLigne{#2}%
     \xdef\toklistedefligne{}%
-    \foreachitem\compteur\in\ListeDefLigne{%
-      \xdef\toklistedefligne{\toklistedefligne (\ListeDefLigne[\compteurcnt,1],\ListeDefLigne[\compteurcnt,2],\ListeDefLigne[\compteurcnt,3]),}%
+    \ifboolKV[DessinGradue]{OrigineVariable}{%
+      \foreachitem\compteur\in\ListeDefLigne{%
+        \xdef\toklistedefligne{\toklistedefligne (\ListeDefLigne[\compteurcnt,1],\ListeDefLigne[\compteurcnt,2]),(\ListeDefLigne[\compteurcnt,3],\ListeDefLigne[\compteurcnt,4]),}%
+      }%
+    }{%
+      \foreachitem\compteur\in\ListeDefLigne{%
+        \xdef\toklistedefligne{\toklistedefligne (\ListeDefLigne[\compteurcnt,1],\ListeDefLigne[\compteurcnt,2],\ListeDefLigne[\compteurcnt,3]),}%
+      }%
     }%
-    \newtoks\toklisteptsgrad%
-    \newtoks\toklistetracesgrad%
-    \ifboolKV[DessinGradue]{Solution}{%
-      \setsepchar[*]{,*/}%
-      \readlist\ListePG{#3}%
-      \setsepchar[*]{§*/}%
-      \readlist\ListeTraces{#4}%
-      \foreachitem\compteur\in\ListePG{\expandafter\UpdateLignes\compteur\nil}%
-      \foreachitem\compteur\in\ListeTraces{\expandafter\UpdateTraces\compteur\nil}%
-    }{}%
-    \TraceDessinGradueMul{\toklistedefligne}{\the\toklisteptsgrad}{\the\toklistetracesgrad}%
+    \TraceDessinGradueComplet{\toklistedefligne}{\the\toklisteptsgrad}{\the\toklistetracesgrad}%
   }%
 }%
 
@@ -10291,16 +10988,17 @@
   \mplibforcehmode%
   \begin{mplibcode}%
     input PfCCalculatrice;
+    LargeurEcran:=\useKV[ClesCalculatrice]{Largeur};
     LCD(#1)(#2)(#3);
   \end{mplibcode}
   \else
-  \begin{mpost}[mpsettings={input PfCCalculatrice;}]
+  \begin{mpost}[mpsettings={input PfCCalculatrice;LargeurEcran:=\useKV[ClesCalculatrice]{Largeur};}]
     LCD(#1)(#2)(#3);    
   \end{mpost}
   \fi
 }
 
-\setKVdefault[ClesCalculatrice]{Ecran=false,NbLignes=0,BL=0.775}
+\setKVdefault[ClesCalculatrice]{Ecran=false,NbLignes=0,BL=0.775,Largeur=120}
 
 \newcommand\Calculatrice[2][]{%
   \setstackgap{L}{\useKV[ClesCalculatrice]{BL}\baselineskip}%
@@ -20664,11 +21362,10 @@
   \fi
 }
 
-
 %%%
 % Fonction
 %%%
-\setKVdefault[ClesFonction]{Nom=f,Variable=x,Calcul=x,Tableau=false,Largeur=5mm,Ecriture=false,Definition=false,Points=false,Tangentes=false,PasX=1,PasY=1,UniteX=1,UniteY=1,Prolonge=false,Trace=false,Catmull=false,Epaisseur=1,Couleur=black,PointsCourbe=true,Codes=false}
+\setKVdefault[ClesFonction]{Nom=f,Variable=x,Calcul=x,Tableau=false,Largeur=5mm,Ecriture=false,Definition=false,Points=false,Tangentes=false,PasX=1,PasY=1,UniteX=1,UniteY=1,Prolonge=false,Trace=false,Catmull=false,Epaisseur=1,Couleur=black,CouleurTrace=black,PointsCourbe=true,Codes=false,Origine={(0,0)},Vide=false}
 \defKV[ClesFonction]{Traces=\setKV[ClesFonction]{Codes}}%
 
 \newtoks\toklistePtsFn%pour la discipline
@@ -20676,95 +21373,106 @@
 \def\UpdatePtsFn#1/#2/#3/#4\nil{\addtotok\toklistePtsFn{#1,(#2,#3),#4,}}%
 \def\UpdatePtsFN#1/#2/#3/#4\nil{\addtotok\toklistePtsFn{(#2,#3),}}%
 
-\def\MPCourbePoints#1#2#3#4#5#6{%
-  % #1 la liste des points
-  % #2: pas en x
-  % #3: pas en y
-  % #4: unit\'e en x
-  % #5: unit\'e en y
-  % #6 : prolongement avant et apr\`es les premier et dernier points ?
+\NewDocumentCommand\Fonction{o m}{%
+  \useKVdefault[ClesFonction]%
+  \setKV[ClesFonction]{#1}%
+  \ifboolKV[ClesFonction]{Trace}{%
+    \useKVdefault[TraceG]%
+    \setKV[TraceG]{#1}%
+    \MPTraceFonction[#1]{\useKV[ClesFonction]{Calcul}}%
+  }{%
+    \ifboolKV[ClesFonction]{Points}{%
+      \toklistePtsFn{}%
+      \setsepchar[*]{§*/}%\ignoreemptyitems%
+      \readlist*\ListePoints{#2}%
+      \ifboolKV[ClesFonction]{Catmull}{%
+        \xdef\PfCFooListePoints{(\ListePoints[1,2],\ListePoints[1,3]),}%
+        \foreachitem\compteur\in\ListePoints{%
+          \xdef\PfCFooListePoints{\PfCFooListePoints (\ListePoints[\compteurcnt,2],\ListePoints[\compteurcnt,3]),}%
+        }%
+        \xdef\PfCFooListePoints{\PfCFooListePoints (\ListePoints[\ListePointslen,2],\ListePoints[\ListePointslen,3]),}%
+        \MPCatmull{\PfCFooListePoints}{\useKV[ClesFonction]{PasX}}{\useKV[ClesFonction]{PasY}}{\useKV[ClesFonction]{UniteX}}{\useKV[ClesFonction]{UniteY}}%
+      }{%
+        \xdef\PfCFooListePoints{}
+        \ifboolKV[ClesFonction]{Tangentes}{%
+          \foreachitem\compteur\in\ListePoints{%
+            % \expandafter\UpdatePtsFn\compteur\nil%
+            \xdef\PfCFooListePoints{\PfCFooListePoints \ListePoints[\compteurcnt,1],(\ListePoints[\compteurcnt,2],\ListePoints[\compteurcnt,3]),\ListePoints[\compteurcnt,4],}%
+          }%
+        }{%
+          \foreachitem\compteur\in\ListePoints{%
+            % \expandafter\UpdatePtsFN\compteur\nil%
+            \xdef\PfCFooListePoints{\PfCFooListePoints (\ListePoints[\compteurcnt,2],\ListePoints[\compteurcnt,3]),}%
+          }%
+        }%
+        \MPCourbeNew{\PfCFooListePoints}%\the\toklistePtsFn}%
+      }%
+    }{%
+      \setsepchar{,}\ignoreemptyitems%
+      \readlist*\ListeFonction{#2}%
+      \StrSubstitute{\useKV[ClesFonction]{Calcul}}{\useKV[ClesFonction]{Variable}}{\i}[\temp]%
+      \StrSubstitute{\useKV[ClesFonction]{Calcul}}{**}{^}[\tempa]%
+      \StrSubstitute{\tempa}{*}{}[\tempab]%
+      \ifboolKV[ClesFonction]{Ecriture}{%
+        \ensuremath{\useKV[ClesFonction]{Nom}(\useKV[ClesFonction]{Variable})=\tempab}%
+      }{}%
+      \ifboolKV[ClesFonction]{Definition}{%
+        \ensuremath{\useKV[ClesFonction]{Nom}:\useKV[ClesFonction]{Variable}\mapsto\tempab}%
+      }{}%
+      \ifboolKV[ClesFonction]{Tableau}{%
+        \buildtabfonction%
+      }{}%
+      \reademptyitems%
+    }%
+  }%
+}%
+
+\def\MPCourbeNew#1{%#2#3#4#5#6{%
   \ifluatex
   \mplibforcehmode
   \begin{mplibcode}
-    x.u:=#2;
-    y.u:=#3;
-    X.u:=#4;
-    Y.u:=#5;
+    x.u:=\useKV[ClesFonction]{PasX};
+    y.u:=\useKV[ClesFonction]{PasY};
+    X.u:=\useKV[ClesFonction]{UniteX};
+    Y.u:=\useKV[ClesFonction]{UniteY};
+    Epaisseur:=\useKV[ClesFonction]{Epaisseur};
+    
+    boolean Prolonge,Tangentes,PointsCourbe,Codes;
+    Prolonge=\useKV[ClesFonction]{Prolonge};
+    Tangentes=\useKV[ClesFonction]{Tangentes};
+    PointsCourbe=\useKV[ClesFonction]{PointsCourbe};
+    Codes=\useKV[ClesFonction]{Codes};
+
+    color CouleurTrace;
+    CouleurTrace=\useKV[ClesFonction]{CouleurTrace};
+
+    def enplace=
+    xscaled X.u yscaled Y.u
+    enddef;
+
+    vardef placepoint(expr q,r)=
+    (q,r)*cm enplace
+    enddef;
+    
     numeric dirav[],dirap[];
     pair Fn[],Gn[];
     n=0;
+    if Tangentes:
     for p_=#1:
-    Gn[n]=p_;
-    Fn[n]=cm*(X.u*xpart(p_),Y.u*ypart(p_));
-    n:=n+1;
-    endfor;
-    N:=(n-1);
-    MinX=999;
-    MaxX=-999;
-    MinY=999;
-    MaxY=-999;
-    for k=0 upto N:
-    if xpart(Gn[k])<MinX:
-    MinX:=xpart(Gn[k]);
+    if (n mod 3)=0:
+    dirav[n div 3]=p_;
     fi;
-    if xpart(Gn[k])>MaxX:
-    MaxX:=xpart(Gn[k]);
+    if (n mod 3)=1:
+    Gn[n div 3]=p_;
+    Fn[n div 3]=cm*(X.u*xpart(p_),Y.u*ypart(p_));
     fi;
-    if ypart(Gn[k])<MinY:
-    MinY:=ypart(Gn[k]);
+    if (n mod 3)=2:
+    dirap[n div 3]=p_;
     fi;
-    if ypart(Gn[k])>MaxY:
-    MaxY:=ypart(Gn[k]);
-    fi;
+    n:=n+1;
     endfor;
-    if #6=0:
-    for k=MinY-1 step y.u until MaxY+1:
-    draw cm*((MinX-1)*X.u,k*Y.u)--cm*((MaxX+1)*X.u,k*Y.u) withcolor 0.75white;
-    endfor;
-    for k=MinX-1 step x.u until MaxX+1:
-    draw cm*(k*X.u,(MinY-1)*Y.u)--cm*(k*X.u,(MaxY+1)*Y.u) withcolor 0.75white;
-    endfor;
+    N:=(n-1) div 3;
     else:
-    for k=MinY-1 step y.u until MaxY+1:
-    draw cm*((MinX)*X.u,k*Y.u)--cm*((MaxX)*X.u,k*Y.u) withcolor 0.75white;
-    endfor;
-    for k=MinX step x.u until MaxX:
-    draw cm*(k*X.u,(MinY-1)*Y.u)--cm*(k*X.u,(MaxY+1)*Y.u) withcolor 0.75white;
-    endfor;
-    fi;
-    if #6=0:
-    for k=0 upto N:
-    fill cercles(Fn[k],0.5mm);
-    endfor;
-    else:
-    for k=1 upto N-1:
-    fill cercles(Fn[k],0.5mm);
-    endfor;
-    fi;
-    if #6=0:
-    drawarrow (0,(MinY-1)*Y.u*cm)--(0,(MaxY+1)*Y.u*cm);
-    drawarrow ((MinX-1)*X.u*cm,0)--((MaxX+1)*X.u*cm,0);
-    else:
-    drawarrow (0,(MinY-1)*Y.u*cm)--(0,(MaxY+1)*Y.u*cm);
-    drawarrow ((MinX)*X.u*cm,0)--((MaxX)*X.u*cm,0);
-    fi;
-    label.llft(btex O etex,(0,0));
-    dotlabel.bot(btex 1 etex,cm*X.u*(1,0));
-    dotlabel.lft(btex 1 etex,cm*Y.u*(0,1));
-    draw Fn[0]
-    for k=1 upto N:
-    ..Fn[k]
-    endfor withpen pencircle scaled \useKV[ClesFonction]{Epaisseur};
-  \end{mplibcode}
-  \else
-  \begin{mpost}[mpsettings={numeric Epaisseur; Epaisseur=\useKV[ClesFonction]{Epaisseur};}]
-    x.u:=#2;
-    y.u:=#3;
-    X.u:=#4;
-    Y.u:=#5;
-    numeric dirav[],dirap[];
-    pair Fn[],Gn[];
-    n=0;
     for p_=#1:
     Gn[n]=p_;
     Fn[n]=cm*(X.u*xpart(p_),Y.u*ypart(p_));
@@ -20771,6 +21479,7 @@
     n:=n+1;
     endfor;
     N:=(n-1);
+    fi;
     MinX=999;
     MaxX=-999;
     MinY=999;
@@ -20789,140 +21498,102 @@
     MaxY:=ypart(Gn[k]);
     fi;
     endfor;
-    if #6=0:
-    for k=MinY-1 step y.u until MaxY+1:
-    draw cm*((MinX-1)*X.u,k*Y.u)--cm*((MaxX+1)*X.u,k*Y.u) withcolor 0.75white;
-    endfor;
-    for k=MinX-1 step x.u until MaxX+1:
-    draw cm*(k*X.u,(MinY-1)*Y.u)--cm*(k*X.u,(MaxY+1)*Y.u) withcolor 0.75white;
-    endfor;
-    else:
-    for k=MinY-1 step y.u until MaxY+1:
-    draw cm*((MinX)*X.u,k*Y.u)--cm*((MaxX)*X.u,k*Y.u) withcolor 0.75white;
-    endfor;
-    for k=MinX step x.u until MaxX:
-    draw cm*(k*X.u,(MinY-1)*Y.u)--cm*(k*X.u,(MaxY+1)*Y.u) withcolor 0.75white;
-    endfor;
+    if MinY<0:
+    if MinY<>ceiling(MinY):
+    MinY:=ceiling(MinY)-1;
     fi;
-    if #6=0:
-    for k=0 upto N:
-    fill cercles(Fn[k],0.5mm);
-    endfor;
-    else:
-    for k=1 upto N-1:
-    fill cercles(Fn[k],0.5mm);
-    endfor;
     fi;
-    if #6=0:
-    drawarrow (0,(MinY-1)*Y.u*cm)--(0,(MaxY+1)*Y.u*cm);
-    drawarrow ((MinX-1)*X.u*cm,0)--((MaxX+1)*X.u*cm,0);
-    else:
-    drawarrow (0,(MinY-1)*Y.u*cm)--(0,(MaxY+1)*Y.u*cm);
-    drawarrow ((MinX)*X.u*cm,0)--((MaxX)*X.u*cm,0);
+    if MinX<0:
+    if MinX<>ceiling(MinX):
+    MinX:=ceiling(MinX)-1;
     fi;
-    label.llft(btex O etex,(0,0));
-    dotlabel.bot(btex 1 etex,cm*X.u*(1,0));
-    dotlabel.lft(btex 1 etex,cm*Y.u*(0,1));
-    draw Fn[0]
-    for k=1 upto N:
-    ..Fn[k]
-    endfor withpen pencircle scaled Epaisseur;
-  \end{mpost}
-  \fi
-}
-
-\def\MPCourbe#1#2#3#4#5#6{%
-  \ifluatex
-  \mplibforcehmode
-  \begin{mplibcode}
-    x.u:=#2;
-    y.u:=#3;
-    X.u:=#4;
-    Y.u:=#5;
-    numeric dirav[],dirap[];
-    pair Fn[],Gn[];
-    n=0;
-    for p_=#1:
-    if (n mod 3)=0:
-    dirav[n div 3]=p_;
     fi;
-    if (n mod 3)=1:
-    Gn[n div 3]=p_;
-    Fn[n div 3]=cm*(X.u*xpart(p_),Y.u*ypart(p_));
+    if MaxY<>ceiling(MaxY):
+    MaxY:=ceiling(MaxY);
     fi;
-    if (n mod 3)=2:
-    dirap[n div 3]=p_;
+    if MaxX<>ceiling(MaxX):
+    MaxX:=ceiling(MaxX);
     fi;
-    n:=n+1;
-    endfor;
-    N:=(n-1) div 3;
-    MinX=999;
-    MaxX=-999;
-    MinY=999;
-    MaxY=-999;
-    for k=0 upto N:
-    if xpart(Gn[k])<MinX:
-    MinX:=xpart(Gn[k]);
+    if MaxX<1:
+    MaxX:=1;
     fi;
-    if xpart(Gn[k])>MaxX:
-    MaxX:=xpart(Gn[k]);
+    if MaxY<1:
+    MaxY:=1;
     fi;
-    if ypart(Gn[k])<MinY:
-    MinY:=ypart(Gn[k]);
-    fi;
-    if ypart(Gn[k])>MaxY:
-    MaxY:=ypart(Gn[k]);
-    fi;
-    endfor;
-        if #6=0:
+    if Prolonge:
     for k=MinY-1 step y.u until MaxY+1:
-    draw cm*((MinX-1)*X.u,k*Y.u)--cm*((MaxX+1)*X.u,k*Y.u) withcolor 0.75white;
+    draw cm*((MinX)*X.u,k*Y.u)--cm*((MaxX)*X.u,k*Y.u) withcolor 0.75white;
     endfor;
-    for k=MinX-1 step x.u until MaxX+1:
+    for k=MinX step x.u until MaxX:
     draw cm*(k*X.u,(MinY-1)*Y.u)--cm*(k*X.u,(MaxY+1)*Y.u) withcolor 0.75white;
     endfor;
     else:
     for k=MinY-1 step y.u until MaxY+1:
-    draw cm*((MinX)*X.u,k*Y.u)--cm*((MaxX)*X.u,k*Y.u) withcolor 0.75white;
+    draw cm*((MinX-1)*X.u,k*Y.u)--cm*((MaxX+1)*X.u,k*Y.u) withcolor 0.75white;
     endfor;
-    for k=MinX step x.u until MaxX:
+    for k=MinX-1 step x.u until MaxX+1:
     draw cm*(k*X.u,(MinY-1)*Y.u)--cm*(k*X.u,(MaxY+1)*Y.u) withcolor 0.75white;
     endfor;
     fi;
-    if #6=0:
-    for k=0 upto N:
-    fill cercles(Fn[k],0.5mm);
-    endfor;
-    else:
-    for k=1 upto N-1:
-    fill cercles(Fn[k],0.5mm);
-    endfor;
-    fi;
-    if #6=0:
+    if Prolonge:    
     drawarrow (0,(MinY-1)*Y.u*cm)--(0,(MaxY+1)*Y.u*cm);
-    drawarrow ((MinX-1)*X.u*cm,0)--((MaxX+1)*X.u*cm,0);
+    drawarrow ((MinX)*X.u*cm,0)--((MaxX)*X.u*cm,0);
     else:
-    drawarrow (0,(MinY-1)*Y.u*cm)--(0,(MaxY+1)*Y.u*cm);
-    drawarrow ((MinX)*X.u*cm,0)--((MaxX)*X.u*cm,0);
+    drawarrow (0,(MinY-1)*Y.u*cm)--(0*cm,(MaxY+1)*Y.u*cm);
+    drawarrow ((MinX-1)*X.u*cm,0*cm)--((MaxX+1)*X.u*cm,0*cm);
     fi;
     label.llft(btex O etex,(0,0));
     dotlabel.bot(btex 1 etex,cm*X.u*(1,0));
     dotlabel.lft(btex 1 etex,cm*Y.u*(0,1));
-    draw Fn[0]{dir dirap[0]}
+    draw if Tangentes:
+    Fn[0]{dir dirap[0]}
     for k=1 upto (N-1):
     ..{dir dirav[k]}Fn[k]{dir dirap[k]}
     endfor
-    ..{dir dirav[N]}Fn[N] withpen pencircle scaled \useKV[ClesFonction]{Epaisseur};
+    ..{dir dirav[N]}Fn[N]
+    else:
+    Fn[0]
+    for k=1 upto N:
+    ..Fn[k]
+    endfor fi withpen pencircle scaled Epaisseur withcolor CouleurTrace;
+    if PointsCourbe:
+    if Prolonge:
+    for k=1 upto N-1:
+    fill cercles(Fn[k],0.5mm);
+    endfor;
+    else:
+    for k=0 upto N:
+    fill cercles(Fn[k],0.5mm);
+    endfor;
+    fi;
+    fi;
+    if Codes:
+    \useKV[ClesFonction]{Traces};
+    fi;
   \end{mplibcode}
   \else
-  \begin{mpost}[mpsettings={numeric Epaisseur; Epaisseur=\useKV[ClesFonction]{Epaisseur};}]
-    x.u:=#2;
-    y.u:=#3;
-    X.u:=#4;
-    Y.u:=#5;
+  \begin{mpost}[mpsettings={%
+      x.u:=\useKV[ClesFonction]{PasX};y.u:=\useKV[ClesFonction]{PasY};
+      X.u:=\useKV[ClesFonction]{UniteX};Y.u:=\useKV[ClesFonction]{UniteY};
+      Epaisseur:=\useKV[ClesFonction]{Epaisseur};
+      boolean Prolonge,Tangentes,PointsCourbe,Codes;
+      Prolonge=\useKV[ClesFonction]{Prolonge};
+      Tangentes=\useKV[ClesFonction]{Tangentes};
+      PointsCourbe=\useKV[ClesFonction]{PointsCourbe};
+      Codes=\useKV[ClesFonction]{Codes};
+      color CouleurTrace;
+      CouleurTrace=\useKV[ClesFonction]{CouleurTrace};
+      }]
+      def enplace=
+      xscaled X.u yscaled Y.u
+      enddef;
+      vardef placepoint(expr q,r)=
+      (q,r)*cm enplace
+      enddef;
     numeric dirav[],dirap[];
     pair Fn[],Gn[];
     n=0;
+    if Tangentes:
     for p_=#1:
     if (n mod 3)=0:
     dirav[n div 3]=p_;
@@ -20937,6 +21608,14 @@
     n:=n+1;
     endfor;
     N:=(n-1) div 3;
+    else:
+    for p_=#1:
+    Gn[n]=p_;
+    Fn[n]=cm*(X.u*xpart(p_),Y.u*ypart(p_));
+    n:=n+1;
+    endfor;
+    N:=(n-1);
+    fi;
     MinX=999;
     MaxX=-999;
     MinY=999;
@@ -20955,45 +21634,75 @@
     MaxY:=ypart(Gn[k]);
     fi;
     endfor;
-    if #6=0:
+    if MinY<0:
+    if MinY<>ceiling(MinY):
+    MinY:=ceiling(MinY)-1;
+    fi;
+    fi;
+    if MinX<0:
+    if MinX<>ceiling(MinX):
+    MinX:=ceiling(MinX)-1;
+    fi;
+    fi;
+    if MaxY<>ceiling(MaxY):
+    MaxY:=ceiling(MaxY);
+    fi;
+    if MaxX<>ceiling(MaxX):
+    MaxX:=ceiling(MaxX);
+    fi;
+    if MaxX<1:
+    MaxX:=1;
+    fi;
+    if MaxY<1:
+    MaxY:=1;
+    fi;
+    if Prolonge:
     for k=MinY-1 step y.u until MaxY+1:
-    draw cm*((MinX-1)*X.u,k*Y.u)--cm*((MaxX+1)*X.u,k*Y.u) withcolor 0.75white;
+    draw cm*((MinX)*X.u,k*Y.u)--cm*((MaxX)*X.u,k*Y.u) withcolor 0.75white;
     endfor;
-    for k=MinX-1 step x.u until MaxX+1:
+    for k=MinX step x.u until MaxX:
     draw cm*(k*X.u,(MinY-1)*Y.u)--cm*(k*X.u,(MaxY+1)*Y.u) withcolor 0.75white;
     endfor;
     else:
     for k=MinY-1 step y.u until MaxY+1:
-    draw cm*((MinX)*X.u,k*Y.u)--cm*((MaxX)*X.u,k*Y.u) withcolor 0.75white;
+    draw cm*((MinX-1)*X.u,k*Y.u)--cm*((MaxX+1)*X.u,k*Y.u) withcolor 0.75white;
     endfor;
-    for k=MinX step x.u until MaxX:
+    for k=MinX-1 step x.u until MaxX+1:
     draw cm*(k*X.u,(MinY-1)*Y.u)--cm*(k*X.u,(MaxY+1)*Y.u) withcolor 0.75white;
     endfor;
     fi;
-    if #6=0:
-    for k=0 upto N:
-    fill cercles(Fn[k],0.5mm);
-    endfor;
-    else:
-    for k=1 upto N-1:
-    fill cercles(Fn[k],0.5mm);
-    endfor;
-    fi;
-    if #6=0:
+    if Prolonge:    
     drawarrow (0,(MinY-1)*Y.u*cm)--(0,(MaxY+1)*Y.u*cm);
-    drawarrow ((MinX-1)*X.u*cm,0)--((MaxX+1)*X.u*cm,0);
+    drawarrow ((MinX)*X.u*cm,0)--((MaxX)*X.u*cm,0);
     else:
-    drawarrow (0,(MinY-1)*Y.u*cm)--(0,(MaxY+1)*Y.u*cm);
-    drawarrow ((MinX)*X.u*cm,0)--((MaxX)*X.u*cm,0);
+    drawarrow (0,(MinY-1)*Y.u*cm)--(0*cm,(MaxY+1)*Y.u*cm);
+    drawarrow ((MinX-1)*X.u*cm,0*cm)--((MaxX+1)*X.u*cm,0*cm);
     fi;
     label.llft(btex O etex,(0,0));
     dotlabel.bot(btex 1 etex,cm*X.u*(1,0));
     dotlabel.lft(btex 1 etex,cm*Y.u*(0,1));
-    draw Fn[0]{dir dirap[0]}
+    draw if Tangentes:
+    Fn[0]{dir dirap[0]}
     for k=1 upto (N-1):
     ..{dir dirav[k]}Fn[k]{dir dirap[k]}
     endfor
-    ..{dir dirav[N]}Fn[N] withpen pencircle scaled Epaisseur;
+    ..{dir dirav[N]}Fn[N]
+    else:
+    Fn[0]
+    for k=1 upto N:
+    ..Fn[k]
+    endfor fi withpen pencircle scaled Epaisseur withcolor CouleurTrace;
+    if PointsCourbe:
+    if Prolonge:
+    for k=1 upto N-1:
+    fill cercles(Fn[k],0.5mm);
+    endfor;
+    else:
+    for k=0 upto N:
+    fill cercles(Fn[k],0.5mm);
+    endfor;
+    fi;
+    fi;
   \end{mpost}
   \fi
 }
@@ -21018,6 +21727,14 @@
     X.u:=#4;
     Y.u:=#5;
 
+    def enplace=
+    xscaled X.u yscaled Y.u
+    enddef;
+
+    vardef placepoint(expr q,r)=
+    (q,r)*cm enplace
+    enddef;
+    
     pair Fn[],Gn[];
     n=0;
     for p_=#1:
@@ -21056,6 +21773,28 @@
     if MinY>-1:
     MinY:=-2;
     fi;
+    if MinY<0:
+    if MinY<>ceiling(MinY):
+    MinY:=ceiling(MinY)-1;
+    fi;
+    fi;
+    if MinX<0:
+    if MinX<>ceiling(MinX):
+    MinX:=ceiling(MinX)-1;
+    fi;
+    fi;
+    if MaxY<>ceiling(MaxY):
+    MaxY:=ceiling(MaxY);
+    fi;
+    if MaxX<>ceiling(MaxX):
+    MaxX:=ceiling(MaxX);
+    fi;
+    if MaxX<1:
+    MaxX:=1;
+    fi;
+    if MaxY<1:
+    MaxY:=1;
+    fi;
     %
     path cadreexterieur;
     cadreexterieur=(((MinX-1)*X.u*cm,(MinY-1)*Y.u*cm)--((MaxX+1)*X.u*cm,(MinY-1)*Y.u*cm)--((MaxX+1)*X.u*cm,(MaxY+1)*Y.u*cm)--((MinX-1)*X.u*cm,(MaxY+1)*Y.u*cm)--cycle);
@@ -21077,6 +21816,7 @@
     for k=debutbalai upto finbalai:
     fill cercles(Fn[k],0.5mm);
     endfor;
+    fi;
     drawarrow (0,(MinY-1)*Y.u*cm)--(0,(MaxY+1)*Y.u*cm);
     drawarrow ((MinX-1)*X.u*cm,0)--((MaxX+1)*X.u*cm,0);
     %
@@ -21084,7 +21824,6 @@
     label.llft(btex O etex,(0,0));
     dotlabel.bot(btex 1 etex,cm*X.u*(1,0));
     dotlabel.lft(btex 1 etex,cm*Y.u*(0,1));
-    fi;
     if Code:
     \useKV[ClesFonction]{Traces};
     fi;
@@ -21091,10 +21830,11 @@
   \end{mplibcode}
   \else
   \begin{mpost}[mpsettings={numeric Epaisseur; Epaisseur=\useKV[ClesFonction]{Epaisseur}; color CouleurCourbe; CouleurCourbe=\useKV[ClesFonction]{Couleur};boolean PointsCourbe;PointsCourbe=\useKV[ClesFonction]{PointsCourbe};}]
-    x.u:=#2;
+        x.u:=#2;
     y.u:=#3;
     X.u:=#4;
     Y.u:=#5;
+
     pair Fn[],Gn[];
     n=0;
     for p_=#1:
@@ -21133,6 +21873,28 @@
     if MinY>-1:
     MinY:=-2;
     fi;
+    if MinY<0:
+    if MinY<>ceiling(MinY):
+    MinY:=ceiling(MinY)-1;
+    fi;
+    fi;
+    if MinX<0:
+    if MinX<>ceiling(MinX):
+    MinX:=ceiling(MinX)-1;
+    fi;
+    fi;
+    if MaxY<>ceiling(MaxY):
+    MaxY:=ceiling(MaxY);
+    fi;
+    if MaxX<>ceiling(MaxX):
+    MaxX:=ceiling(MaxX);
+    fi;
+    if MaxX<1:
+    MaxX:=1;
+    fi;
+    if MaxY<1:
+    MaxY:=1;
+    fi;
     %
     path cadreexterieur;
     cadreexterieur=(((MinX-1)*X.u*cm,(MinY-1)*Y.u*cm)--((MaxX+1)*X.u*cm,(MinY-1)*Y.u*cm)--((MaxX+1)*X.u*cm,(MaxY+1)*Y.u*cm)--((MinX-1)*X.u*cm,(MaxY+1)*Y.u*cm)--cycle);
@@ -21154,6 +21916,7 @@
     for k=debutbalai upto finbalai:
     fill cercles(Fn[k],0.5mm);
     endfor;
+    fi;
     drawarrow (0,(MinY-1)*Y.u*cm)--(0,(MaxY+1)*Y.u*cm);
     drawarrow ((MinX-1)*X.u*cm,0)--((MaxX+1)*X.u*cm,0);
     %
@@ -21161,78 +21924,17 @@
     label.llft(btex O etex,(0,0));
     dotlabel.bot(btex 1 etex,cm*X.u*(1,0));
     dotlabel.lft(btex 1 etex,cm*Y.u*(0,1));
-    fi;
   \end{mpost}
   \fi
 }%
 
-\newcommand\Fonction[2][]{%
-  \useKVdefault[ClesFonction]%
-  \setKV[ClesFonction]{#1}%
-  \ifboolKV[ClesFonction]{Trace}{%
-    \useKVdefault[TraceG]%
-    \setKV[TraceG]{#1}%
-    \MPTraceFonction[#1]{\useKV[ClesFonction]{Calcul}}%
-  }{%
-    \ifboolKV[ClesFonction]{Points}{%
-      \toklistePtsFn{}%
-      \setsepchar[*]{§*/}%\ignoreemptyitems%
-      \readlist*\ListePoints{#2}%
-      \ifboolKV[ClesFonction]{Catmull}{%
-        \xdef\PfCFooListePoints{(\ListePoints[1,2],\ListePoints[1,3]),}
-        \foreachitem\compteur\in\ListePoints{%
-          \xdef\PfCFooListePoints{\PfCFooListePoints (\ListePoints[\compteurcnt,2],\ListePoints[\compteurcnt,3]),}%
-        }%
-        \xdef\PfCFooListePoints{\PfCFooListePoints (\ListePoints[\ListePointslen,2],\ListePoints[\ListePointslen,3]),}%
-        \MPCatmull{\PfCFooListePoints}{\useKV[ClesFonction]{PasX}}{\useKV[ClesFonction]{PasY}}{\useKV[ClesFonction]{UniteX}}{\useKV[ClesFonction]{UniteY}}%
-      }{%
-        \ifboolKV[ClesFonction]{Tangentes}{%
-          \foreachitem\compteur\in\ListePoints{%
-            \expandafter\UpdatePtsFn\compteur\nil%
-          }%
-          \ifboolKV[ClesFonction]{Prolonge}{%
-            \MPCourbe{\the\toklistePtsFn}{\useKV[ClesFonction]{PasX}}{\useKV[ClesFonction]{PasY}}{\useKV[ClesFonction]{UniteX}}{\useKV[ClesFonction]{UniteY}}{1}%
-          }{%
-            \MPCourbe{\the\toklistePtsFn}{\useKV[ClesFonction]{PasX}}{\useKV[ClesFonction]{PasY}}{\useKV[ClesFonction]{UniteX}}{\useKV[ClesFonction]{UniteY}}{0}%
-          }%
-        }{%
-          \foreachitem\compteur\in\ListePoints{%
-            \expandafter\UpdatePtsFN\compteur\nil%
-          }%
-          \ifboolKV[ClesFonction]{Prolonge}{%
-            \MPCourbePoints{\the\toklistePtsFn}{\useKV[ClesFonction]{PasX}}{\useKV[ClesFonction]{PasY}}{\useKV[ClesFonction]{UniteX}}{\useKV[ClesFonction]{UniteY}}{1}%
-          }{%
-            \MPCourbePoints{\the\toklistePtsFn}{\useKV[ClesFonction]{PasX}}{\useKV[ClesFonction]{PasY}}{\useKV[ClesFonction]{UniteX}}{\useKV[ClesFonction]{UniteY}}{0}%
-          }%
-        }%
-      }%
-    }{%
-      \setsepchar{,}\ignoreemptyitems%
-      \readlist*\ListeFonction{#2}%
-      \StrSubstitute{\useKV[ClesFonction]{Calcul}}{\useKV[ClesFonction]{Variable}}{\i}[\temp]%
-      \StrSubstitute{\useKV[ClesFonction]{Calcul}}{**}{^}[\tempa]%
-      \StrSubstitute{\tempa}{*}{}[\tempab]%
-      \ifboolKV[ClesFonction]{Ecriture}{%
-        \ensuremath{\useKV[ClesFonction]{Nom}(\useKV[ClesFonction]{Variable})=\tempab}%
-      }{}%
-      \ifboolKV[ClesFonction]{Definition}{%
-        \ensuremath{\useKV[ClesFonction]{Nom}:\useKV[ClesFonction]{Variable}\mapsto\tempab}%
-      }{}%
-      \ifboolKV[ClesFonction]{Tableau}{%
-        \buildtabfonction%
-      }{}%
-      \reademptyitems%
-    }%
-  }%
-}%
-
 \def\buildtabfonction{%
   \[%
     \begin{array}{|>{\columncolor{gray!15}}c|*{\number\numexpr\ListeFonctionlen}{>{\centering\arraybackslash}p{\useKV[ClesFonction]{Largeur}}|}}%
-      \hline
+      \hline%
       \useKV[ClesFonction]{Variable}\xintFor* ##1 in {\xintSeq {1}{\ListeFonctionlen}}\do{&\num{\ListeFonction[##1]}}\\
-      \hline
-      \useKV[ClesFonction]{Nom}(\useKV[ClesFonction]{Variable})\xintFor* ##1 in {\xintSeq {1}{\ListeFonctionlen}}\do{&  \StrSubstitute{\useKV[ClesFonction]{Calcul}}{\useKV[ClesFonction]{Variable}}{(\ListeFonction[##1])}[\tempab]\num{\fpeval{\tempab}}}
+      \hline%
+      \useKV[ClesFonction]{Nom}(\useKV[ClesFonction]{Variable})\xintFor* ##1 in {\xintSeq {1}{\ListeFonctionlen}}\do{&  \StrSubstitute{\useKV[ClesFonction]{Calcul}}{\useKV[ClesFonction]{Variable}}{(\ListeFonction[##1])}[\tempab]\num{\fpeval{\tempab}}}%
       \\\hline
     \end{array}%
   \]%
@@ -21241,7 +21943,7 @@
 %%%
 % Diff\'erentes représentations graphiques
 %%%
-\setKVdefault[TraceG]{Grille=false,Graduations=false,PasGradX=1,PasGradY=1,PasGrilleX=1,PasGrilleY=1,Xmin=-5.5,Xmax=5.5,Xstep=1,Ymin=-5.5,Ymax=5.5,Ystep=1,Bornea=-5.5,Borneb=5.5,LabelX={},LabelY={},LabelC=0.5,NomCourbe={},Origine={(5.5,5.5)},Fonction=false,Points=false,Invisible=false,CouleurPoint=red,CouleurTrace=black,Epaisseur=1,Relie=false,RelieSegment=false,Marque=dot,Code=false}%
+\setKVdefault[TraceG]{Grille=false,Graduations=false,PasGradX=1,PasGradY=1,PasGrilleX=1,PasGrilleY=1,Xmin=-5.5,Xmax=5.5,Xstep=1,Ymin=-5.5,Ymax=5.5,Ystep=1,Bornea=-5.5,Borneb=5.5,LabelX={},LabelY={},LabelC=0.5,NomCourbe={},Origine={(5.5,5.5)},Fonction=false,Points=false,Invisible=false,CouleurPoint=red,CouleurTrace=black,Epaisseur=1,Relie=false,RelieSegment=false,Marque=dot,Code=false,Vide=false}%
 \defKV[TraceG]{Traces=\setKV[TraceG]{Code}}%
 
 \newcommand\TraceGraphique[2][]{%
@@ -21468,8 +22170,9 @@
     pair Origine;
     Origine=(xmin,ymin)+\useKV[TraceG]{Origine};
 
-    boolean Grille;
+    boolean Grille,Vide;
     Grille=\useKV[TraceG]{Grille};
+    Vide=\useKV[TraceG]{Vide};
 
     boolean Graduations;
     Graduations=\useKV[TraceG]{Graduations};
@@ -21558,6 +22261,8 @@
     drawarrow (u*(xmin,0)--u*(xmax,0)) shifted (u*(0,ypart(Origine)));
     label.llft(btex 0 etex,u*Origine);
     drawoptions();
+    if Vide:
+    else:
     draw courbe1(borneinf,bornesup,100)(#2) withpen (pencircle scaled Epaisseur) withcolor colortrace;
     % labelisation
     numeric t;
@@ -21573,6 +22278,7 @@
     if \useKV[TraceG]{Code}:
     \useKV[TraceG]{Traces}
     fi;
+    fi;
   \end{mplibcode}
   \else
   \mpxcommands{%
@@ -21579,7 +22285,7 @@
     \usepackage{ProfCollege}
     \setKV[TraceG]{#1}
   }
-  \begin{mpost}[mpsettings={borneinf=\useKV[TraceG]{Bornea};bornesup=\useKV[TraceG]{Borneb};xmin=\useKV[TraceG]{Xmin};xmax=\useKV[TraceG]{Xmax};ymin=\useKV[TraceG]{Ymin};ymax=\useKV[TraceG]{Ymax};pasx=\useKV[TraceG]{Xstep};pasy=\useKV[TraceG]{Ystep};xu=1cm/\useKV[TraceG]{Xstep};yu=1cm/\useKV[TraceG]{Ystep};grillex=\useKV[TraceG]{PasGrilleX};grilley=\useKV[TraceG]{PasGrilleY};pos=\useKV[TraceG]{LabelC};Epaisseur=\useKV[TraceG]{Epaisseur}; color colortrace;colortrace=\useKV[TraceG]{CouleurTrace};boolean Grille;Grille=\useKV[TraceG]{Grille};boolean Graduations;Graduations=\useKV[TraceG]{Graduations};
+  \begin{mpost}[mpsettings={borneinf=\useKV[TraceG]{Bornea};bornesup=\useKV[TraceG]{Borneb};xmin=\useKV[TraceG]{Xmin};xmax=\useKV[TraceG]{Xmax};ymin=\useKV[TraceG]{Ymin};ymax=\useKV[TraceG]{Ymax};pasx=\useKV[TraceG]{Xstep};pasy=\useKV[TraceG]{Ystep};xu=1cm/\useKV[TraceG]{Xstep};yu=1cm/\useKV[TraceG]{Ystep};grillex=\useKV[TraceG]{PasGrilleX};grilley=\useKV[TraceG]{PasGrilleY};pos=\useKV[TraceG]{LabelC};Epaisseur=\useKV[TraceG]{Epaisseur}; color colortrace;colortrace=\useKV[TraceG]{CouleurTrace};boolean Grille,Vide;Grille=\useKV[TraceG]{Grille};Vide=\useKV[TraceG]{Vide};boolean Graduations;Graduations=\useKV[TraceG]{Graduations};
     pair Origine;
     Origine=(xmin,ymin)+\useKV[TraceG]{Origine};}]
 
@@ -21657,6 +22363,8 @@
     drawarrow (u*(0,ymin)--u*(0,ymax)) shifted (u*(xpart(Origine),0));
     drawarrow (u*(xmin,0)--u*(xmax,0)) shifted (u*(0,ypart(Origine)));
     drawoptions();
+    if Vide:
+    else:
     draw courbe1(borneinf,bornesup,100)(#2) withpen (pencircle scaled Epaisseur) withcolor colortrace;
 %    % labelisation
     numeric t;
@@ -21669,6 +22377,7 @@
     clip currentpicture to polygone(u*(xmin,ymin),u*(xmax,ymin),u*(xmax,ymax),u*(xmin,ymax));
     label.rt(btex \useKV[TraceG]{LabelX} etex,u*(xmax,ypart(Origine)));
     label.top(btex \useKV[TraceG]{LabelY} etex,u*(xpart(Origine),ymax));
+    fi;
   \end{mpost}
   \fi
 }
@@ -28242,4 +28951,4 @@
     draw recap;%
   \end{mpost}
 }{}%
-\fi%
\ No newline at end of file
+\fi%



More information about the tex-live-commits mailing list.