\usepackage[warnings-off={mathtools-colon,mathtools-overbracket},math-style=french]{unicode-math}
\setmainfont{Lato}[Scale=0.92]
\setmathfont{LeteSansMath}[math-style=french,Scale=0.92]
\setmathfont{FiraMath}[range=\times]
\def\myfontScratch{\sffamily}

\newfontfamily\myfontCursive{QTBrushStroke}

\usepackage{fancyhdr}
\fancyhead{}
\fancyfoot{}
\cfoot{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\usepackage{imakeidx}
\makeindex
\makeindex[columns=3,name=cle,title=Index des clés]

\usepackage{lipsum}
%\usepackage{doc}
%
\makeatletter
\let\mygobble\@gobble
%
\renewcommand*\l@section[2]{%
  \ifnum \c@tocdepth >\z@
    \addpenalty\@secpenalty
    \addvspace{1.0em \@plus\p@}%
    \setlength\@tempdima{2em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil
      \nobreak\hb@xt@\@pnumwidth{\hss #2%
                                 \kern-\p@\kern\p@}\par
    \endgroup
    \fi
}
%Si on veut pousser la numérotation des chapitres vers la droite.
%\renewcommand*\numberline[1]{%
%  \hb@xt@\@tempdima{\hfil#1 }%
%}
\makeatother

\usepackage[explicit]{titlesec}


\titleformat{\section}
{\bfseries\Large} % Format for the section title
{}                          % Label
{0pt}                       % Separation between label and title
{%
  \begin{tikzpicture}[remember picture,overlay]
    %\coordinate[xshift=1.5cm] (Asec) at (current page.north west);
    %\coordinate (Aseca) at ($(current page.south west)!0.5!(Asec)$);
    \coordinate[yshift=-1.5cm] (Asec) at (current page.north east);
    \coordinate (Aseca) at ($(current page.north west)!0.5!(Asec)$);
    \fill[opacity=0.25,SteelBlue] (current page.north west) rectangle (Asec);
    \node[] at (Aseca) {#1};
  \end{tikzpicture}
}
[\vspace{-2ex}] % Separation between title and body

%
\usepackage{mflogo}

\usepackage[margin=2cm,nohead,includefoot]{geometry}

\newlength{\PfCLargeurTableau}

\newlength{\appui}
\setlength{\appui}{-20pt}

\newlength{\lnttxt}
\newcommand\dispo[3]{
\setlength{\lnttxt}{\linewidth}
\setbox#1=\hbox{#2}
\addtolength{\lnttxt}{-\wd#1}
\addtolength{\lnttxt}{\appui}
\begin{minipage}{\wd#1}
#2
\end{minipage}
\hfill
\begin{minipage}{\lnttxt}
#3
\end{minipage}
}

\tcbset{%
  tikzcle/.style={%
    before skip=1em,%
    enhanced jigsaw,%
    breakable,%
    colback=Cornsilk,%
    colframe=black,%
  }%
}%

\tcbset{%
  tikzclebeamer/.style={%
    before skip=1em,%
    enhanced,%
    breakable,%
    colback=Cornsilk,%
    colframe=black,%
    underlay unbroken and first={%
      \node[%
      name=A,
      ] at (frame.west){\includegraphics[scale=0.25]{AttentionBeamer-2}};
      %% 
      \node[%
      name=B,
      ] at (frame.east){\includegraphics[scale=0.25]{AttentionBeamer-1}};
      %% 
    }
  }
}
\tcbset{%
  tikzexemple/.style={%
    before skip=1em,
    enhanced,
    breakable,
    colback=LightSteelBlue,
    colframe=black,
  }
}

\title{%
  \begin{minipage}{0.75\linewidth}
    \begin{tcolorbox}[colframe=myyellow,colback=myyellow!45]
      \begin{center}
          \begin{tabular}{c}
    \lstinline!ProfCollegeLua!\\
    \\
    Une aide pour utiliser \LaTeX{} au collège
  \end{tabular}
      \end{center}
    \end{tcolorbox}
  \end{minipage}
}
\author{
  \begin{tabular}{c}
    Christophe {\sc Poulain}\\
    {\ttfamily chr poulain -- at -- gmail . com}
  \end{tabular}
}
\date{Version \PfCfileversion\space -- \PfCfiledate}

\usepackage{graphicx}
\graphicspath{{figures/}}

\usepackage{lscape}

\usepackage{listings}

\lstset{%
  classoffset = 0,%
    language     = [LaTeX]TeX,%
    basicstyle   = \ttfamily,%
    breaklines = true,%
    commentstyle =\color{gray},%
    columns=fullflexible,%
    keepspaces,
    frame=tb,%
    %texcsstyle=*\color{blue},%pour colorer la contre-oblique
    morekeywords={\\Distri,\\NDistri,\\Pythagore,\\NPythagore,\\SommeAngles,\\Resultat,\\Thales,\\Trigo,\\NTrigo,\\RedactionTrigo,\\Stat,\\EffectifTotal,\\Etendue,\\Moyenne,\\Mediane,\\QuartileUn,\\QuartileTrois,\\ResolEquation,\\NResolEquation,\\FlechesPH,\\FlechesPB,\\FlechesPD,\\FlechesPG,\\FlechePCG,\\FlechePCD,\\FlechePCH,\\FlechePCB,\\FlecheCoef,\\FlecheCoefDebut,\\FlecheLineaireH,\\FlecheLineaireB,\\FlecheLineaireD,\\FlecheLineaireG,\\FonctionAffine,\\Fonction,\\Proba,\\Reperage,\\Pourcentage,\\ProprieteDroites,\\ResultatPytha,\\NomTriangle,\\NomSommetA,\\NomSommetB,\\NomSommetC,\\NomA,\\NomB,\\NomC,\\NomAngleDroit,\\RedactionSomme,\\RedactionPythagore,\\RedactionCalculsPythagore,\\RedactionReciPythagore,\\RedactionCalculsReciPythagore,\\RedactionCalculsPythagore,\\RedactionConclusionReciPythagore,\\RedactionThales,\\NomPointA,\\NomPointB,\\NomPointC,\\NomPointM,\\NomPointN,\\ResultatTrigo,\\ResultatThalesx,\\ResultatThalesy,\\ResultatThalesz,\\Puissances,\\Relie,\\QCM,\\QCMPfC,\\QFlash,\\Fraction,\\Tableau,\\Simplification,\\Decomposition,\\Formule,\\Propor,\\ResultatPourcentage,\\ResultatAngle,\\Ratio,\\FlecheRatio,\\FlecheInvRatio,\\pointilles,\\Lignespointilles,\\Calculatrice,\\Tables,\\Radar,\\Jauge,\\Labyrinthe,\\Lg,\\Aire,\\Vol,\\MasseVol,\\Vitesse,\\Masse,\\Capa,\\Octet,\\Conso,\\Temps,\\Temp,\\BoiteFlash,\\Rangement,\\Demain,\\MultiCol,\\Cartes,\\Dominos,\\Papiers,\\Prix,\\LabyNombre,\\DessinGradue,\\Colorilude,\\ColoriludeEnonce,\\ColoriludeListeCouleur,\\Quisuisje,\\QuisuisjeEnonce,\\QuisuisjeTableau,\\QuisuisjeCodePerso,\\Autonomie,\\BonSortie,\\PyramideNombre,\\ProgCalcul,\\MotsEmpiles,\\Mosaique,\\DessineMosaique,\\MotsCodes,\\MotsCodesTableau,\\Ecriture,\\FractionDecimale,\\Triomino,\\Rapido,\\BoiteRapido,\\Cartographie,\\Addition,\\MultiAddition,\\Soustraction,\\Multiplication,\\Division,\\DivisionD,\\AdditionColore,\\SoustractionColore,\\MultiplicationColore,\\DefiTable,\\DefiTableTexte,\\FicheMemo,\\ModeleBarre,\\MotsCroises,\\Enquete,\\ListePersonnages,\\ListeObjets,\\ListeLieux,\\ListeQuestions,\\AffichageQuestions,\\AffichageTableau,\\CourseNombre,\\Frise,\\ChoixAlea,\\VariableAlea,\\RepresenterEntier,\\Billard,\\PQuatre,\\RoseMul,\\Yohaku,\\PixelArt,\\KenKen,\\Kakuro,\\Shikaku,\\CalculsCroises,\\Mentalo,\\NombreAstral,\\CompteBon,\\Engrenages,\\CodageRLE,\\VueCubes,\\Tortue,\\CNReponse,\\Solide,\\BarresCalculs,\\EnigmeAire,\\Calisson,\\Tectonic,\\PuzzlePyramide,\\MessageCache,\\RondeInfernale,\\Futoshiki,\\Garam,\\SquarO,\\Grades,\\MidPoint,\\Kakurasu,\\DecompositionDecimale,\\PfCCardsEcartH,\\PfCCardsEcartV,\\Factorisation,\\AddFraction,\\SousFraction,\\MulFraction,\\DivFraction,\\PfCTexteJai,\\PfCTexteJesuis,\\PfCTexteQuia,\\Trio,\\TrioCourt,\\DefiRangement,\\Nonogramme,\\Pavage,\\GlisseNombre,\\Dobble,\\Erathostene,\\Patron,\\BoiteCartes,\\NumberHive,\\Automatismes,\\PyraVoca,\\LectureGraphique,\\PfCChoixImage,\\PfCChoixAntecedent,\\Cible,\\PuzzleMul,\\Horloge,\\ReperageZoom,\\Grimuku,\\TableauMultiplicatif,\\DefiCalculatrice,\\CryptarithmeAdd,\\CryptarithmeMAdd,\\CryptarithmeSous,\\CryptarithmeMul,\\CryptarithmeDiv,\\MulJaponaise,\\Fubuki,\\MelangeLettres,\\CibleQuatreOperations,\\MulJalousie,\\FractionAireCarre,\\Horaire,\\FractionNombre,\\Serpent,\\Maya,\\Babylone,\\Chinoise,\\VisualPattern,\\Bonbon,\\DessinAlgo,\\Jeton,\\Lego,\\Critere,\\Eratosthene,\\PointsSuspension,\\Convertir,\\PfCSymbolTimes,\\PfCSymbolDiv,\\NeComptePasPoints,\\PfCNbSolutionH,\\PfCNbSolutionV,\\PfCNbSolutionDD,\\PfCNbSolutionDM,\\LogoRecyclage,\\TicketCaisse,\\AssemblageSolides,\\ArbreChiffre,\\VisualisationMulDecimaux,\\ArbreCalcul,\\ProbaFrequence,\\SchemaProba,\\ListeACompleter,\\CalculDetaille,\\Cheque,\\Rullo,\\OpCroisees,\\ScratchEnLigne,\\BandeNumerique,\\Balance,\\PatternJeton,\\LigneBrisee,\\DecompositionFraction,\\AireSimple,\\PfCPanneaux,\\PBlancs,\\SystemeImage,\\MulEthiopie,\\Monnaie,\\Iteration,\\BoiteADix,\\RecherchePGCD,\\AppliGlisseNombre,\\TheoremeMilieu,\\AfficheDenominateurCommun,\\DivisionCourte,\\Billet,\\GratteCiel,\\Quatrido,\\QuatridoReponse,\\GestionScore,\\LogoJOParis,\\VerreMesureur,\\SachetTuile,\\SachetTuileRegroupe,\\SachetTuileDegroupe,\\TuileLibre,\\TableLacunaire,\\ModeleCumulatif,\\GuideAne},%\\cellcolor,\\multido,\\ang,
    alsoletter={5\\},%
    keywordstyle=\color{blue},%
    emph=[1]{ProfCollegeLua,siunitx,mathtools,amssymb,multicol,xcolor,xlop,xfp,modulus,simplekv,ifthen,xstring,xinttools,xintexpr,gmp,tikz,hhline,environ,datatool,iftex,microtype,fontawesome5,frame,Mind,Bulle,bclogo,alphalph,pdflscape,gridpapers,scratch3,sesamanuel,enumitem,tcolorbox,verbatim,luamplib,listofitems,multido,suffix,longtable,stackengine,cancel,pifont,nicematrix,fmtcount,ifoddpage,luacas,Geometrie,Tableur,Scratch,Allumettes,Facebook,Twitter,Snapchat,Instagram,Mastodon,Mappy,inlinegraphicx},%
    emphstyle=[1]{\color{DodgerBlue}},%
    emph=[3]{beamer},%
    emphstyle=[3]{\color{Crimson}},%
    classoffset=1,%
    keywords={Ecran,Decimaux,PuissancesSeules,Entiers,Prefixes,Millions,Milliards,Partie,CouleurG,CouleurM,Couleurm,Couleuru,Couleurd,Incline,Classes,Micro,Nano,NbLignes,Virgule,Nombres,Puissances,Metre,Carre,CarreA,Are,Cube,CubeA,Octet,Capacite,Colonnes,Litre,Gramme,Fleches,FlechesH,FlechesB,Solution,LargeurG,LargeurD,Ecart,Stretch,Alterne,Reponses,Largeur,Titre,Nom,Alph,AlphT,Couleur,VF,Depart,NomV,NomF,Noms,Simple,Kahout,Intrus,Numeration,Decimal,Mental,Expression,Daily,Mesure,Heure,Numerique,Seul,Pause,Hauteur,Evaluation,Aire,Surface,Perimetre,Volume,Solide,Ancre,Angle,Soustraction,Perso,Reciproque,ReciColonnes,Faible,Egalite,Exact,Entier,Racine,Precision,Unite,Figure,FigureSeule,ValeurA,ValeurB,ValeurC,EnchaineA,EnchaineB,EnchaineC,AvantRacine,Detail,Isocele,Droites,Segment,Propor,IntroCalculs,Figurecroisee,FigurecroiseeSeule,ChoixCalcul,CouleurNum,CouleurDen,Cosinus,Sinus,Tangente,Num,CitePropriete,Brouillon,Remediation,AffichageNom,DemiDroite,Unitex,Unitey,Unitez,Pasx,Pasy,Pasz,ValeurOrigine,ValeurUnitex,ValeurUnitey,Plan,Trace,ListeSegment,AffichageCoord,AffichageGrad,AffichageAbs,LectureCoord,Espace,EchelleEspace,Sphere,AnglePhi,Tableau,TableauVertical,TableauVerticalVide,Dot,Dots,Potence,Exposant,Longue,All,AllNombre,Arbre,ArbreComplet,ArbreVide,ArbreDessine,ArbreDessineVide,Entoure,CouleurTronc,CouleurFeuillage,CouleurFruits,Diviseurs,DiviseursT,Disque,Rectangle,Regulier,Eprouvette,Fleur,Reponse,Rayon,Cotes,Hachures,Triangle,Parts,Longueur,Multiple,Contraire,Details,Vertical,GrandeurA,GrandeurB,Math,CouleurTab,Appliquer,Decimal,Fractionnaire,Concret,Augmenter,AideTableau,Reduire,MotReduction,Formule,Calculer,Qualitatif,Donnee,TableauVide,Effectif,Frequence,PrecisionF,Angle,SemiAngle,Batons,Lecture,LectureFine,AideLecture,DonneesSup,AngleRotationAbscisse,AffichageDonnees,AffichageAngle,ListeCouleurs,ListeCouleursB,AbscisseRotation,LectureInverse,EcartHachures,EpaisseurHachures,EpaisseurBatons,CouleurDefaut,LegendesVides,Bicolore,Graphique,EffectifTotal,SET,Etendue,Mediane,Moyenne,MoyenneA,ValeurExacte,Total,Origine,ECC,Histogramme,UniteAire,DepartHisto,Liste,Sondage,EffVide,ColVide,CasesVides,AngVide,ECCVide,FreqVide,TotalVide,Coupure,Echelle,LongueurEchelle,Grille,Affichage,Arbre,Branche,Angle,Definition,Ecriture,Image,Ligne,ProgCalcul,Variable,Antecedent,Retrouve,Redaction,VoirCoef,ACoef,Calcul,Etape,NomExpression,Fin,CouleurFH,CouleurFB,AideMul,AideAdda,AideAddb,Reduction,CouleurReduction,CouleurAide,Somme,Difference,RAZ,Oppose,Remarquable,Echange,Tuile,Vide,Simplification,Lettre,LettreSol,Verification,Nombre,Egalite,Decomposition,CouleurSous,Ecart,FlecheDiv,Pose,Terme,CouleurTerme,Composition,CouleurCompo,Symbole,CouleurSymbole,Bloc,Produit,Facteurs,Pointilles,CTrace,Epaisseur,CFond,Equivalence,Laurent,TexteTotal,TextePart,CouleurUn,CouleurDeux,CouleurTrois,FigureCours,Debut,Seul,Addition,Reference,Pas,Disciplines,MoyenneClasse,TexteOrigine,TexteReference,CouleurBarre,CouleurFond,Graduation,CouleurGraduation,Niveau,LimiteR,LimiteV,CouleurF,Passages,EcartH,EcartV,Logo,SensImpose,Lignes,Decroissant,Strict,Fraction,LargeurUn,Bandeau,Cellule,Colonne,PasL,PasC,Landscape,Trame,TrameVisible,RayonArc,Jointes,Theme,ThemeJaiQuiA,NomTitre,Loop,Trivial,JaiQuia,Marge,ThemeSol,BackgroundAv,BackgroundAr,ImageAv,ImageAr,Ratio,Superieur,Cinq,Seyes,Isometrique,IsometriquePointe,GrillePointe,Millimetre,PageEntiere,ZoneTexte,Numerotation,Impression,Naturel,Points,Catmull,Splines,Lagrange,PasX,PasY,UniteX,UniteY,Tangentes,Prolonge,Xmax,Xmin,Ymax,Ymin,Xstep,Ystep,Grille,LabelX,LabelY,LabelC,NomCourbe,CouleurTrace,Bornea,Borneb,PasGrilleX,PasGrilleY,PasGradX,PasGradY,Graduations,Representation,Invisible,Relie,RelieSegment,CouleurPoint,XDepart,YDepart,XArrivee,YArrivee,Murs,LignesIdentiques,EcartVertical,Coef,Legende,TitreAtoi,TexteCorrection,AfficheMarge,MemeEnonce,Etages,Inverse,Direct,SansCalcul,Enonce,Nom,CouleurCadre,ThemePerso,Application,Label,Type,LargeurT,Tradition,Majuscule,E,Zero,SansZero,Complete,CodePerso,Auteur,Heure,EchelleLogo,Publie,Texte,Piece,Numero,EchelleCarte,AfficheEchelle,Europe,Asie,Amsud,Amcentre,Amnord,Caraibes,Afrique,Pays,Villes,VillesI,Projection,TypeProjection,CouleurPays,CouleurVirgule,CouleurVirguleSol,CouleurFond,Thermometre,Mercure,CouleurMercure,Kelvin,Farenheit,Barre,EcartBarre,Croises,Escalier,Cours,Exercice,NbQ,Ordre,Dossier,Maitre,CoefQ,CoefR,CoefJ,Nom,CAN,Sup,Compact,Vrai,Multiplication,Aide,Autre,Relatif,Puissance,FacteurMin,FacteurMax,CaseVide,Produits,ProduitVide,Petales,Polygone,Taille,TLargeur,THauteur,Case,Pair,Impair,Premier,Relatif,Bordure,CouleurResultat,CouleurZone,CodeAfter,Lettres,ListeNombres,Marque,CouleurSolution,Creation,Graine,AllPerso,SansMots,Questions,ValeurMin,ValeurMax,NombreCalculs,Plaques,Original,Relatifs,EntreeSortie,Entree,Sortie,CouleurChemin,Face,TroisCouleurs,Profondeur,CouleurCube,CouleurFleche,Trou,Grilles,TortueD,TortueF,HauteurG,Axes,Cases,CartonReponse,CoinHD,CoinBG,TypeTrace,Resultats,RayonCylindre,HauteurCylindre,Traces,ListeSommets,Sommets,Aretes,Anglex,DecalageSommet,SommetsPyramide,Reguliere,RayonCone,HauteurCone,RayonSphere,Section,CoefSection,PointsSection,CouleurSection,Distance,Phi,Theta,ObjetSection,Litteral,Decimaux,Modele,PointsCourbe,Plateau,OrigineVariable,Cle,ListeOperations,Etapes,StyleTexte,Colore,Parentheses,ResultatSeul,SansMul,ParenthesesFin,Resultat,Globe,CouleurE,Repere,Cible,VideRepere,Deno,Motif,Complete,ArrierePlan,Quadrilatere,Escher,Position,Reseau,Basei,Basej,Cote,CouleurNombre,CouleurGN,CadreGN,CouleurCadre,Einstein,Vampire,CouleurP,CouleurNP,Separation,AccoladesH,AccoladesB,Pave,Arete,Double,Jetons,UniteHexa,Negatif,Fractions,Priorites,ListeHachures,DebutAngle,LesSommes,LesProduits,LesNombres,NbPoints,ThemeJeu,Flechettes,AffichageUnites,MarquePrimaire,Cadre,Aiguilles,Secondes,Reperes,CouleurS,Operations,SchemaEnonce,ListeTouches,ListeLettres,Indices,CouleurBloc,DessinSeul,Vierge,Condense,Base,Hard,Format,HauteurTheme,AffichageSolution,Restreint,DivE,Style,PasGrillex,PasGrilley,ListeParts,Quadrillage,HautQuad,LargQuad,UniteAire,Consignes,Diametre,Diviseur,ListePerso,Largeura,Largeurb,Unique,RemarqueAll,Div,Remarque,OpReciproques,ReponsesCalculs,Retour,Ombre,ModeleBarre,DebutColonnes,DebutLignes,Vol,Capa,Masse,Sans,Melange,CDot,Div,NbSolution,Papier,Carton,Espaces,Enseigne,Especes,Rendu,HeureAchat,DateAchat,SansRendu,Service,Separations,HauteurD,HauteurCylindre,HauteurPyramideA,HauteurPyramideB,HauteurConeA,HauteurConeB,Chiffre,Dixiemes,EclateX,EclateY,EclateZ,ACompleter,Correction,LargeurC,Expressions,Substitue,Maillage,Lancers,Legendes,Repartition,RepartitionC,RepartitionN,Roue,SansRemise,CouleurLigne,CouleurColonne,RepartitionLigne,RepartitionColonne,ListeColonne,ListeLigne,Different,Casino,Geant,Deforme,Borne,Coefx,Coefy,ToutesOperations,Poisson,AngleArete,CouleurPoisson,ElementsVisibles,StyleTrace,LegendesH,LegendesV,Totaux,DoubleEntree,Fluo,Under,Evidence,Date,Aleatoire,Sigle,Banque,Lieu,Lire,Destinataire,Ajust,Couleurs,PapierMilli,PapierSeyes,PapierCinqCinq,Elements,Invisibles,Multi,NonTraces,Sup,Inf,Masse,Association,BatonsVides,SansRangement,CouleurAire,CouleurUniteAire,SansLegende,CouleurX,CouleurY,CouleurZ,CouleurGrille,Gradue,PE,PolyRec,PolyTriEqui,PasQuad,SI,SIl,Horizontal,Visualisation,Inconnues,Images,EchellePourcent,Debord,Repetitions,Completer,Moustache,CouleurComplement,PasMailleLong,PasMailleLat,Decal,SommetsPrisme,HauteurPrisme,SansCadre,Alias,Constellation,Couronne,ListeIndices,MarqueSommets,UnePart,Template,Orientation,Ameliore,CouleurPositif,CouleurNegatif,Sommes,Produits,TexteInitial,Pleines,NomSegment},%
    keywordstyle=\color{OliveDrab},%
    classoffset=0,%
    literate=*{[}{{\textcolor{orange}{[}}}{1}%
    {]}{{\textcolor{orange}{]}}}{1}%
    {\{}{\textcolor{amber}{\{}}{1}%
    {\}}{\textcolor{amber}{\}}}{1}%
    {\&}{\textcolor{red}{\&}}{1}%
    {\\[}{{\textcolor{purple}{\textbackslash[}}}{2}%
    {\\]}{{\textcolor{purple}{\textbackslash]}}}{2}%
    {$}{{\textcolor{purple}{\$}}}{1}%$
    {_}{{\textcolor{purple}{\_}}}{1}%
    {^}{{\textcolor{purple}{\^{}}}}{1}%,
}

\usepackage{textcomp}%pour les < de listings

\usepackage{hhline}

\usepackage{pifont}
\usepackage{fontawesome5}

\definecolor{mygray}{RGB}{245,245,245}%pour le background de listing
\definecolor{drab}{rgb}{0.59, 0.44, 0.09}
\definecolor{amber}{rgb}{1.0, 0.75, 0.0}
\definecolor{chocolate}{rgb}{0.82, 0.41, 0.12}
\colorlet{amber}{chocolate}

\definecolor{SLCP}{HTML}{00B51A}%
\colorlet{Evidence}{SLCP}%

\newtcblisting{Code}{%
  top=0mm,bottom=0mm,left=2mm,right=2mm,%
  colback=white,%
  colframe=white!75!black,%
  listing side text,%
  listing options={%
    frame=,%
   backgroundcolor=,%
  },%
  righthand width=0.4\linewidth
}%

\newtcblisting{Codes}[3][]{%
  top=0mm,bottom=0mm,left=2mm,right=2mm,middle=0mm,%
  colback=white,%
  colframe=white!75!black,%
  every listing line={#3},%
  listing options={%
    frame=,%
    backgroundcolor=,%
  },%
  righthand width=#2\linewidth,%
  #1%
}%

\newtcblisting{Exemple}[2][]{%
  listing only,
  top=0mm,bottom=0mm,left=2mm,right=2mm,middle=0mm,%
  colback=LightSteelBlue!15,%
  colframe=black,%
  every listing line={#2},%
  listing options={%
    frame=,%
    backgroundcolor=,%
  },%
 #1 
}%

\newtcblisting{Codev}{%
    top=0mm,bottom=0mm,left=2mm,right=2mm,middle=0mm,%
  colback=white,%
  colframe=white!75!black,%
  listing options={%
    frame=,
    backgroundcolor=,
  }%
}

\newtcblisting{Codeh}{%
  colback=white,%
  colframe=white!75!black,%
  listing only,
  listing options={%
    frame=,
    backgroundcolor=,
  }%
}

\newtcblisting{CodeH}{%
  top=0mm,bottom=0mm,left=2mm,right=2mm,
  colback=white,%
  colframe=white!75!black,%
  listing only,
  listing options={%
    language=metapost,
    emph={trace,remplis,chemin,polygone,segment,droite,demidroite,coupdecompas,cercles,Codeangle,Codelongueur,codeperp,appelation,rotation,marque_s},
    emphstyle=\color{purple},
    numbers=left,
    numberstyle=\tiny,
    frame=,
    backgroundcolor=,
  }%
}

\newtcblisting{CodeHH}{%
  colback=white,%
  colframe=white!75!black,%
  listing only,
  listing options={%
    frame=,
    backgroundcolor=,
  }%
}

\usepackage{menukeys}
\newcommand\metamk[1]{\textlangle#1{\sffamily\textrangle}}

\newcommand\Cle[1]{%
  {\bfseries\sffamily\textlangle #1{\sffamily\textrangle}}%
}%

\newcommand\CleD[1]{%
  {\bfseries\sffamily\textlangle #1{\sffamily\textrangle}}$^{\text{\faIcon{sync-alt}}}$%
}%

\newcommand\CleS[1]{%
  {\bfseries\sffamily\textlangle #1{\sffamily\textrangle}}%
}%

\newcommand\CleDS[1]{%
  {\bfseries\sffamily\textlangle #1{\sffamily\textrangle}}$^{\text{\faIcon{sync-alt}}}$%
}%

\newcommand\Defaut[1]{%
\hfill valeur par défaut : {\sffamily #1}\par%
}%
\newcommand\Defauts[1]{%
\hfill valeurs par défaut : {\sffamily #1}\par%
}%

\newcommand\DefautR[1]{%
(valeur par défaut : {\sffamily #1}) %
}%
\newcommand\DefautsR[1]{%
(valeurs par défaut : {\sffamily #1}) %
}%

%\usepackage{parskip}

\newenvironment{Description}
               {\list{}{\labelwidth0pt \leftmargin0pt \itemindent-\leftmargin
                        \let\makelabel\Descriptionlabel}}
               {\endlist}
\newcommand*\Descriptionlabel[1]{\hspace\labelsep \textbullet~%\includegraphics{Trombone-mps.pdf}
  \normalfont\bfseries #1}

\newenvironment{SousDescription}
               {\list{}{\small\labelwidth0pt \leftmargin0\linewidth \itemindent0pt%0.075
                        \let\makelabel\SousDescriptionlabel}}
               {\endlist}
\newcommand*\SousDescriptionlabel[1]{\hspace\labelsep \textbullet~%\includegraphics{Trombone-mps.pdf}%
  \normalfont\bfseries #1%
}%

\newenvironment{SousDescriptionR}
{\list{}{\labelwidth0pt \leftmargin0.075\linewidth \itemindent0pt
    \let\makelabel\SousDescriptionlabelR}}
{\endlist\medskip}

\newcommand*\SousDescriptionlabelR{\hspace\labelsep$\star$}

\newenvironment{SSDescription}
{\list{}{\labelwidth0pt \leftmargin0.15\linewidth \itemindent0pt
    \let\makelabel\SousDescriptionlabel}}
{\endlist}

\newenvironment{SSDescriptionR}
{\list{}{\labelwidth0pt \leftmargin0.15\linewidth \itemindent0pt
    \let\makelabel\SousDescriptionlabelR}}
{\endlist}

\parindent0pt

\usepackage{hologo}

\usepackage{pdflscape}
\usepackage{pdfpages}

% https://tex.stackexchange.com/questions/558709/tcolorbox-footnotes-at-end-of-each-page
\makeatletter
% restore footnote internals to those in normal page, not minipage
\def\tcb@restore@footnote{%
  \def\@mpfn{footnote}%
  \def\thempfn{\arabic{footnote}}%
  \let\@footnotetext\tcb@footnote@collect
}

% collect footnote text
\long\def\tcb@footnote@collect#1{%
  % expand \@thefnmark before appending before app to \tcb@footnote@acc
  \expandafter\gappto\expandafter\tcb@footnote@acc\expandafter{%
    \expandafter\footnotetext\expandafter[\@thefnmark]{#1}%
  }%
}

\def\tcb@footnote@use{%
  \tcb@footnote@acc
  \global\let\tcb@footnote@acc\@empty
}
\global\let\tcb@footnote@acc\@empty

\tcbset{
  % restore for every box
  every box/.style={%
    before title pre=\tcb@restore@footnote,
    before upper pre=\tcb@restore@footnote,
    before lower pre=\tcb@restore@footnote
  },
  % use for layer 1 boxes only
  every box on layer 1/.append style={
    after app=\tcb@footnote@use
  }
}
\makeatother

\NewDocumentEnvironment{Key}{mO{valeur}m+b}{%
  \begin{description}%
  \item[La clé \Cle{#1}]\hfill#2{} par défaut : {\sffamily #3}\par%
    #4%
}{\end{description}}%

\NewDocumentEnvironment{Keyl}{m O{valeur} m +b}{%
  \begin{description}
  \item[La clé #1]\hfill#2{} par défaut : {\sffamily #3}\par
    #4
  \end{description}
}{}

\NewDocumentEnvironment{KEYS}{m O{valeurs} m +b}{%
  \begin{description}
  \item[Les clés \Cle{#1}]\hfill#2{} par défaut : {\sffamily #3}\par
    #4
  \end{description}
}{}

\NewDocumentEnvironment{KEYSl}{m O{valeurs} m +b}{%
  \begin{description}
  \item[Les clés #1]\hfill#2{} par défaut : {\sffamily #3}\par
    #4
  \end{description}
}{}

\NewDocumentEnvironment{KeyS}{m O{valeur} m +b}{%
  \begin{description}
  \item[La clé \CleS{#1}]\hfill#2{} par défaut : {\sffamily #3}\par
    #4
  \end{description}
}{}

\NewDocumentEnvironment{KeyD}{m O{valeur} m +b}{%
  \begin{description}
  \item[La clé \CleD{#1}]\hfill#2{} par défaut : {\sffamily #3}\par
    #4
  \end{description}
}{}

\NewDocumentEnvironment{KeyDS}{m O{valeur} m +b}{%
  \begin{description}
  \item[La clé \CleDS{#1}]\hfill#2{} par défaut : {\sffamily #3}\par
    #4
  \end{description}
}{}


\newtcolorbox{Commande}[2][]{%
  enhanced,
  top=0mm,
  bottomtitle=0mm,
  arc=0pt,
  outer arc=0pt,
  colframe=LightSteelBlue,
  colback=white,
  bicolor,
  colbacklower=LightSteelBlue!15,
  coltitle=black,
  title={\bfseries La commande #2},
  #1%
}%

\newtcolorbox{Lenviron}[2][]{%
  enhanced,
  top=0mm,
  bottomtitle=0mm,
  arc=0pt,
  outer arc=0pt,
  colframe=Cornsilk,
  colback=white,
  bicolor,
  colbacklower=Cornsilk!15,
  coltitle=black,
  title={\bfseries L'environnement #2},
  #1%
}%

\NewEnviron{LenvironR}[1]{%
  \textbullet{} L'environnement {\bfseries #1} %
   \BODY\par
}

\newtcolorbox{PART}[1][]{%
  enhanced,
  top=0mm,
  bottomtitle=0mm,
  arc=0pt,
  outer arc=0pt,
  colframe=LightSteelBlue,
  colback=white,
  bicolor,
  colbacklower=LightSteelBlue!15,
  coltitle=black,
  title=\centering Partie,
  #1%
}%

\newcommand\TIKZ{Ti\textit{k}Z}

\tcbset{%
  tikzRemarque/.style={%
    before skip=1em,
    enhanced,
    breakable,
    colback=Crimson!15,
    colframe=Crimson!50,
    underlay unbroken and first={%
      \node[%
      name=A,
      ] at (frame.west){\reflectbox{\includegraphics[scale=0.25]{Attention-1}}};
      %% 
      \node[%
      name=B,
      ] at (frame.east){\includegraphics[scale=0.25]{Attention-1}};
      %% 
    }
  }
}

%https://tex.stackexchange.com/questions/181082/how-to-reproduce-this-box-in-tcolorbox#
\newcommand\PfCmylibold{%
  \tikz[baseline=-0.5ex]{%
    \tikzset{lib/.style={%
        rectangle split,%
        rectangle split parts=2,%
        rectangle split horizontal,%
        rectangle split part fill={green!75!blue!50!white,green!10!white},%
        rectangle split draw splits=false,%
        rounded corners=2pt,%
        rectangle split part align={right,right},%
        draw=green!50!black,%
        minimum height=16pt}%
    }%
    \node[lib] (var){%
      \nodepart[text=green!25!black]{two}\tiny\PfCfileversion};%
    \node[text=white,font=\sffamily\bfseries\tiny,rotate=90] at ([xshift=6pt]var.west) {MAJ};%
  }%
}%

\NewDocumentCommand\PfCmylib{O{green!75!blue!50!white,green!10!white}O{MAJ}}{%
  \tikz[baseline=-0.5ex]{%
    \tikzset{lib/.style={%
        rectangle split,%
        rectangle split parts=2,%
        rectangle split horizontal,%
        rectangle split part fill={#1},%
        rectangle split draw splits=false,%
        rounded corners=2pt,%
        rectangle split part align={right,right},%
        draw=green!50!black,%
        minimum height=16pt}%
    }%
    \node[lib] (var){%
      \nodepart[text=green!25!black]{two}\tiny\PfCfileversion};%
    \node[text=white,font=\sffamily\bfseries\tiny,rotate=90] at ([xshift=6pt]var.west) {#2};%
  }%
}%

\NewDocumentCommand\PfCmylibSpecial{O{green!75!blue!50!white,green!10!white}O{MAJ}}{%
  \tikz[baseline=-0.5ex]{%
    \tikzset{lib/.style={%
        rectangle split,%
        rectangle split parts=2,%
        rectangle split horizontal,%
        rectangle split part fill={#1},%
        rectangle split draw splits=false,%
        rounded corners=2pt,%
        rectangle split part align={right,right},%
        draw=green!50!black,%
        minimum height=16pt}%
    }%
    \node[lib] (var){%
      \nodepart[text=green!25!black]{two}\footnotesize#2};%
    \node[text=white,font=\sffamily\bfseries] at ([xshift=5pt]var.west) {!};%
  }%
}%

\newcommand\PfCMAJ[1]{%
%  \StrCompare{#1}{\PfCfileversion}[\PfCRetourMAJ]%
%  \xintifboolexpr{\PfCRetourMAJ==0}{\marginnote{\PfCmylib}}{}%
}%

\NewDocumentCommand\PfCChoixBeamer{}{%
  \marginnote{\PfCmylibSpecial[red!75!blue!50!white,red!10!white][Beamer]}%
}%

\newcommand\DoubleFlecheDifference[3][]{%
  % #1 : option
  % #2 : expression 1
  % #3 : expression 2
\setKV[ClesDistributivite]{#1}%
\begin{align*}
  \useKV[ClesDistributivite]{NomExpression}&=\NDistri[#1,RAZ,Etape=1]{#2}-\NDistri[#1,Etape=1]{#3}\\
  \useKV[ClesDistributivite]{NomExpression}&=\NDistri[Etape=2]{#2}-(\NDistri[Etape=2]{#3})\\
  \useKV[ClesDistributivite]{NomExpression}&=\NDistri[Etape=3]{#2}-(\NDistri[Etape=3]{#3})\\
  \useKV[ClesDistributivite]{NomExpression}&=\ifboolKV[ClesDistributivite]{Oppose}{\NDistri[Etape=4]{#2}-(\NDistri[Etape=4]{#3})\\}{\NDistri[Somme,Etape=4]{#2}-(\NDistri[Difference,Etape=4]{#3})\\}%
  \ifboolKV[ClesDistributivite]{Oppose}{\useKV[ClesDistributivite]{NomExpression}&=\NDistri[RAZ,Somme,Etape=4]{#2}+\NDistri[Oppose,Difference,Etape=4]{#3}\\}{}
  \useKV[ClesDistributivite]{NomExpression}&=\Resultat
\end{align*}
}

%https://tex.stackexchange.com/questions/28465/multiple-footnotes-at-one-point
\let\oldFootnote\footnote
\newcommand\nextToken\relax

\renewcommand\footnote[1]{%
  \oldFootnote{#1}\futurelet\nextToken\isFootnote}

\newcommand\isFootnote{%
  \ifx\footnote\nextToken\textsuperscript{,}\fi}
%fin tex.stackexchange

%\newcounter{NumFig}

\definecolor{myyellow}{RGB}{242,226,149}
\definecolor{wolf}{RGB}{253,183,27}

\usepackage{setspace}
\usepackage{enumitem}

\usepackage{dirtree}

\usepackage[english,french]{babel}
\usepackage[colorlinks=true,linkcolor=purple,luatex]{hyperref}
\usepackage{url}
\usepackage{bookmark}
\usepackage{marginnote}

\tcbset{%
  tikzfiche/.style={%
    before skip=1em,
    enhanced,
    breakable,
    colback=white,
    colframe=gray!50,
    overlay unbroken and first={%
      \node[%
      name=A,
      fill=white,
      anchor=west,
      xshift=10pt,
      ] at (frame.north west){\bfseries\sffamily Exercice};
    }%
  }%
}%

\newenvironment{exercice}[1][]{%
  \tcolorbox[%
  tikzfiche
  ]
}{\endtcolorbox%
}