% Author : C. Pierquet % licence : Released under the LaTeX Project Public License v1.3c % or later, see http://www.latex-project.org/lppl.txtf \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{ProfLycee}[2022/11/30 2.0.6 Aide pour l'utilisation de LaTeX en lycee] % 2.0.6 Quelques modifications sur les codes python (taille police et marges)... % 2.0.5 Correction d'un bug avec les calculs en valeurx exactes avec les suites récurrentes... % 2.0.4 Ajout d'une commande pour présenter un balayage (TVI) + calculs suites récurrentes % 2.0.3Correction d'un bug avec les arbres 3x3 % 2.0.2 Ajout de l'option auto-margin sur piton % 2.0.1 Chargement de piton uniquement si lua... % 2.0.0 Refonte des commandes, des options, et de la documentation !!! % ------------------------------------------------------------------ % 1.3.7 Ajout d'un environnement simplifié pour du code python via piton % 1.3.6 Ajout d'un "générateur" de trinômes (ou mise en forme basique) % 1.3.5 Correction de bugs sur les calculs de probas (loi géométrique) % 1.3.4 Ajout des calculs de probas geométriques et hypergeometriques + petits schémas probas % 1.3.3 Ajout de commandes pour des arbres de probas classiques, en tikz % 1.3.2 Correction d'une commande liée à la conversion bintohex (suppression clé trait) % 1.3.1 Ajout d'une option pour ne pas afficher les bords des cases en pixelart % 1.3.0 Ajout d'une commande pour mettre en forme une conversion depuis la base 10 % 1.2.9 Correction d'une incompatibilité avec simplekv (clés vides...) % 1.2.8 Correction de l'oubli d'une librairie tikz et remise en forme de la documentation % 1.2.7 Calculs de probas pour des lois classiques % 1.2.6 Ajout d'un environnement tikz pour des sudomaths personnalisés % 1.2.5 Ajout d'une commande pour des boites à moustaches, en tikz % 1.2.4 Correction de quelques bugs mineurs, et mise à jour de la doc % 1.2.3 Ajout d'un environnement simplifié pour du code python % 1.2.2 Ajouts de commandes pour des stats à 2 variables % 1.2.1 Amélioration de la gestion du csv pour les pixelart % 1.2 Correction d'un méchant bug avec pixelart, erf... % 1.1.9 Commande pour du pixelart en tikz (avec option csvii pour compatibilité) % 1.1.8 Ajout d'un style mainlevee pour tikz % 1.1.7 Ajout de commandes pour des conversions bin/dec/hex % 1.1.6 Ajout d'une commande pour déterminer les paramètres d'un régression linéaire par moindres carrés % 1.1.5 Ajout de commandes pour "visualiser" le signe de ax+b ou de ax2+bx+c (cf tnsana !) % 1.1.4 Ajout d'une commande cercletrigoPL pour, en \TikZ, créer facilement un cercle trigo avec options % 1.1.3 Ajout d'une commande ensemble pour créer un ensemble à partir d'une liste % 1.1.2 Modifs mineures % 1.1.1 Modification mineure de l'environnement CF, avec prise de charge de la taille du texte ! % 1.1.0 Ajout d'une commande tetraPL pour un tetraèdre dans un environnement TikZ % 1.0.9 Ajout d'une commande pavePL pour un pave droit dans un environnement TikZ % 1.0.8 Ajout d'une commande liencapytale pour créer un cartouche "comme sur capytale" % 1.0.7 Option [build] pour placer les fichiers temporaires dans un répertoire build (désactivée par défaut) % 1.0.6 Option [nominted] pour éviter de charger minted & nettoyage amssymb % 1.0.5 Environnement code python avec minted % 1.0.4 Environnement pour simuler terminal windows & linux % 1.0.3 Environnement pour présenter du pseudocode % 1.0.2 Environnement pour présenter du code python (avec pythontex) % 1.0.1 Modif mineure du chargement de xcolor (compatibilité avec d'autres packages notamment...) % 1.0 Version initiale %------Option(s) \newif\if@nonshellescape \@nonshellescapefalse \DeclareOption{nonshellescape}{\@nonshellescapetrue} \newif\if@build \@buildfalse \DeclareOption{build}{\@buildtrue} \newif\if@csvii \@csviifalse \DeclareOption{csvii}{\@csviitrue} \DeclareOption*{} \ProcessOptions\relax %------Packages utiles \RequirePackage{mathtools} %\RequirePackage{amssymb} \RequirePackage[table,svgnames]{xcolor}%Gestion des couleurs \RequirePackage{tikz} \RequirePackage{tkz-tab} \RequirePackage{pgf,pgffor} \RequirePackage{ifthen} \RequirePackage{xparse} \RequirePackage{xkeyval} %\RequirePackage{xfp} %plus utile \RequirePackage{xstring} \RequirePackage{xintexpr} \RequirePackage{xintbinhex} \RequirePackage{simplekv} \RequirePackage{listofitems} \RequirePackage{tabularray} \RequirePackage{hvlogos} \RequirePackage{siunitx} %test avec v3 \sisetup{% locale=FR,% mode = match, propagate-math-font = true,% reset-math-version = false, reset-text-family = false,% reset-text-series = false, reset-text-shape = false,% text-family-to-math = true, text-series-to-math = true,% output-decimal-marker={,},% % group-minimum-digits=4% }% \RequirePackage{fontawesome5} \if@csvii \RequirePackage[legacy]{csvsimple} \else \RequirePackage{expl3} \RequirePackage[l3]{csvsimple} \fi %librairies tikz \usetikzlibrary{calc} \usetikzlibrary{decorations} \usetikzlibrary{decorations.pathreplacing} \usetikzlibrary{decorations.markings} \usetikzlibrary{arrows,arrows.meta} \usetikzlibrary{babel} \usetikzlibrary{shapes.geometric} \usetikzlibrary{decorations.pathmorphing} %tcolorbox \RequirePackage[most]{tcolorbox} %divers \RequirePackage{iftex} %python \RequirePackage{fancyvrb} \RequirePackage[gobble=auto]{pythontex} \setpythontexlistingenv{pythont} %pour ne pas télescoper lstlistings (?) \if@build \setpythontexoutputdir{./build/pythontex-files-\jobname} %essai de modif pythontex répertoire build \fi %shellescape \if@nonshellescape %on ne charge pas minted et la librairie tcbox \else \if@build %on charge minted avec le répertoire build \RequirePackage[outputdir=build]{minted} \fi %on charge minted via la librairie tcbox \tcbuselibrary{minted} \fi %-----------PRESENTATIONDECODES-------------- \NewTCBListing{PresentationCode}{ O{ForestGreen} m }{% sharp corners=downhill,enhanced,arc=12pt,skin=bicolor,% colback=#1!5!white,colframe=#1!75!black,colbacklower=White,% attach boxed title to top right={yshift=-\tcboxedtitleheight},title=Code \LaTeX,% boxed title style={% colframe=#1!75!black,colback=#1!15!white,% ,sharp corners=downhill,arc=12pt,% },% fonttitle=\color{#1!90!black}\itshape\ttfamily\footnotesize,% listing options={% style=tcblatex,basicstyle=\footnotesize\ttfamily,% keywordstyle=\bfseries\color{Blue},tabsize=2,% },% #2 } %---------------SPLINES---------------------- %------commande utile pour extraire des infos d'une liste \newcommand\extractcoeff[2]{% #1=liste & #2=numero \setsepchar{§}% \readlist*\lcoeffs{#1} \ifnum \lcoeffslen=1 \def\COEFFA{#1} \def\COEFFB{#1} \else \itemtomacro\lcoeffs[#2]\COEFF \IfSubStr{\COEFF}{/}% {\StrCut{\COEFF}{/}{\COEFFA}{\COEFFB}}% {\def\COEFFA{\COEFF}\def\COEFFB{\COEFF}} \fi } %------splines en tikz avec ..controls \defKV[spline]{% Epaisseur=\def\SPLepaisseur{#1},% Couleur=\def\SPLcouleur{#1},% Coeffs=\def\SPLcoeffs{#1},% CouleurPoints=\def\SPLcouleurpoints{#1},% TaillePoints=\def\SPLtaillepoints{#1},% Style=\def\SPLstyle{#1} } \setKVdefault[spline]{% Epaisseur=1.25pt,% Couleur=red,% Coeffs=3,% CouleurPoints=black,% TaillePoints=2pt,% AffPoints=false,% Style={} } \newcommand\SplineTikz[2][]{% \useKVdefault[spline] \setKV[spline]{#1}% on paramètres les nouvelles clés et on les simplifie %on lit la liste des points/nbderivés et on stocke dans \listepoints \setsepchar[.]{§./}% \readlist*\SPLlistepoints{#2}% \def\SPLnbsplines{\inteval{\SPLlistepointslen-1}}% %si uniquement deux points, pas de boucle... \ifnum \SPLlistepointslen=2 %extraction des coeffs de compensation \extractcoeff{\SPLcoeffs}{1}% %extraction des coordonnées \itemtomacro\SPLlistepoints[1,1]\xa \itemtomacro\SPLlistepoints[1,2]\ya \itemtomacro\SPLlistepoints[1,3]\fprimea \itemtomacro\SPLlistepoints[2,1]\xb \itemtomacro\SPLlistepoints[2,2]\yb \itemtomacro\SPLlistepoints[2,3]\fprimeb \draw[line width=\SPLepaisseur,\SPLcouleur,\SPLstyle] (\xa,\ya) ..controls +({atan \fprimea}:{(\xb-\xa)/\COEFFA}) and +({-180 + atan \fprimeb}:{(\xb-\xa)/\COEFFA}).. (\xb,\yb) ;% %sinon on construit bout par bout ! \else \foreach \i in {1,2,...,\SPLnbsplines}{ %extraction des coeffs de compensation \extractcoeff{\SPLcoeffs}{\i} \def\j{\inteval{\i+1}} \itemtomacro\SPLlistepoints[\i,1]\xa \itemtomacro\SPLlistepoints[\i,2]\ya \itemtomacro\SPLlistepoints[\i,3]\fprimea \itemtomacro\SPLlistepoints[\j,1]\xb \itemtomacro\SPLlistepoints[\j,2]\yb \itemtomacro\SPLlistepoints[\j,3]\fprimeb \draw[line width=\SPLepaisseur,\SPLcouleur,\SPLstyle] (\xa,\ya) ..controls +({atan \fprimea}:{(\xb-\xa)/\COEFFA}) and +({-180 + atan \fprimeb}:{(\xb-\xa)/\COEFFB}).. (\xb,\yb) ;% } \fi \ifboolKV[spline]{AffPoints}%on affiche les points de contrôle {% \foreach \i in {1,2,...,\SPLlistepointslen}{% \itemtomacro\SPLlistepoints[\i,1]\xa \itemtomacro\SPLlistepoints[\i,2]\ya \filldraw[\SPLcouleurpoints] (\xa,\ya) circle[radius=\SPLtaillepoints] ;% } } {} } %------tangente(s) en TikZ, avec point/dérivée ou liste points/dérivées \defKV[tgte]{% Epaisseur=\def\TGTepaisseur{#1},% Couleur=\def\TGTcouleur{#1},% xl=\def\TGTXL{#1},% xr=\def\TGTXR{#1},% Style=\def\TGTstyle{#1},% Point=\def\TGTnumpt{#1} } \setKVdefault[tgte]{ Epaisseur=1.25pt,% Couleur=red,% xl=0.5,xr=0.5,% Style={},% Point=1 } \newcommand\TangenteTikz[2][]{% \useKVdefault[tgte]% \setKV[tgte]{#1}% on paramètres les nouvelles clés et on les simplifie \setsepchar[.]{§./}% \readlist*\TGTlistepoints{#2}% \itemtomacro\TGTlistepoints[\TGTnumpt,1]\xa \itemtomacro\TGTlistepoints[\TGTnumpt,2]\ya \itemtomacro\TGTlistepoints[\TGTnumpt,3]\fprimea \def\TGTDEB{\fpeval{\xa-\TGTXL}}\def\TGTFIN{\fpeval{\xa+\TGTXR}}% \draw[line width=\TGTepaisseur,\TGTcouleur,domain=\TGTDEB:\TGTFIN,\TGTstyle] plot (\x,{\fprimea*(\x-\xa)+\ya}) ;% } %----------------FENÊTRE CALCUL FORMEL \newcommand\CFchap{\textasciicircum} \newcounter{CFnum} %def des clés \defKV[paramfenxcas]{% Largeur=\def\CFlarg{#1},% EspaceLg=\def\CFesplg{#1},% PremCol=\def\CFpremcol{#1},% HautPremCol=\def\CFhpremcol{#1},% Taille=\def\CFtaille{#1},% Couleur=\def\CFcouleur{#1},% TailleTitre=\def\CFtailletitre{#1},% CouleurCmd=\def\CFcoulcmd{#1},% CouleurRes=\def\CFcoulres{#1},% PosCmd=\def\CFposcmd{#1},% PosRes=\def\CFposres{#1},% LabelTitre=\def\CFlabeltitre{#1}% } \setKVdefault[paramfenxcas]{% Largeur=16,EspaceLg=2pt,PremCol=0.3,HautPremCol=0.4,% Couleur=darkgray,Menu=true,Titre=false,TailleTitre=\normalsize,Taille=\normalsize,% Sep=true,PosRes=centre,PosCmd=gauche,% CouleurCmd=red,CouleurRes=blue,% LabelTitre={Résultats obtenus avec un logiciel de Calcul Formel}% } \newcommand\CalculFormelParametres[1][]{% \setcounter{CFnum}{0} \useKVdefault[paramfenxcas]% \setKV[paramfenxcas]{#1}% on paramètres les nouvelles clés et on les simplifie } %def des clés \defKV[paramlgxcas]{% HautCmd=\def\CFhle{#1},% HautRes=\def\CFhlr{#1} } \setKVdefault[paramlgxcas]{% HautCmd=0.75,% HautRes=0.75 } \newcommand\CalculFormelLigne[3][]{% \addtocounter{CFnum}{1} \def\CFL{\theCFnum} \def\CFLA{\inteval{\CFL-1}}% \useKVdefault[paramlgxcas]% \setKV[paramlgxcas]{#1}% on paramètres les nouvelles clés et on les simplifie \def\CFLA{\inteval{\CFL-1}}% %DÉCLARATION DES NŒUDS (les "6" coins des lignes commande et résultat) \xintifboolexpr{\CFL == 1}%si c'est la première ligne {\coordinate (A0\CFL) at (0,0);} {\coordinate (A0\CFL) at ($(A2\CFLA) + (0,{-\CFesplg})$);} \coordinate (A1\CFL) at ($(A0\CFL) + (0,{-\CFhle})$); \coordinate (A2\CFL) at ($(A1\CFL) + (0,{-\CFhlr})$); \coordinate (A3\CFL) at ($(A0\CFL) + ({\CFlarg},0)$); \coordinate (A4\CFL) at ($(A1\CFL) + ({\CFlarg},0)$); \coordinate (A5\CFL) at ($(A2\CFL) + ({\CFlarg},0)$); %DÉCLARATION DES NŒUDS INTERMÉDIAIRES (pour les commandes et les résultats) \coordinate (C1\CFL) at ($(A0\CFL) + (0,{-0.5*\CFhle})$); \coordinate (C2\CFL) at ($(A0\CFL) + ({0.5*\CFlarg},{-0.5*\CFhle})$); \coordinate (C3\CFL) at ($(A0\CFL) + ({\CFlarg},{-0.5*\CFhle})$); \coordinate (R1\CFL) at ($(A1\CFL) + (0,{-0.5*\CFhlr})$); \coordinate (R2\CFL) at ($(A1\CFL) + ({0.5*\CFlarg},{-0.5*\CFhlr})$); \coordinate (R3\CFL) at ($(A1\CFL) + ({\CFlarg},{-0.5*\CFhlr})$); %RECTANGLE DE BASE \draw[\CFcouleur] (A0\CFL) rectangle (A5\CFL) ; %LA COMMANDE EN ROUGE \IfStrEq{\CFposcmd}{centre}%si poscmd=center {\draw (C2\CFL) node[\CFcoulcmd,font=\CFtaille] {#2} ;} {} \IfStrEq{\CFposcmd}{gauche}%si poscmd=left {\draw (C1\CFL) node[right,\CFcoulcmd,font=\CFtaille] {#2} ;} {} \IfStrEq{\CFposcmd}{right}%si poscmd=right {\draw (C3\CFL) node[left,\CFcoulcmd,font=\CFtaille] {#2} ;} {} %LA LIGNE DE SÉPARATION \ifboolKV[paramfenxcas]{Sep}%si sep=true {\draw[\CFcouleur] (A1\CFL) -- (A4\CFL);} {} %LE RÉSULTAT \IfStrEq{\CFposres}{centre}%si posrep=center {\draw (R2\CFL) node[\CFcoulres,font=\CFtaille] {#3} ;} {} \IfStrEq{\CFposres}{gauche}%si posrep=left {\draw (R1\CFL) node[right,\CFcoulres,font=\CFtaille] {#3} ;} {} \IfStrEq{\CFposres}{right}%si posrep=right {\draw (R3\CFL) node[left,\CFcoulres,font=\CFtaille] {#3} ;} {} \ifboolKV[paramfenxcas]{Sep}%si sep=true {\draw[\CFcouleur] (A1\CFL) -- (A4\CFL);}% {} %LE PETIT NUMÉRO \draw[\CFcouleur] (A0\CFL) rectangle ++ ({-\CFpremcol},{-\CFhpremcol}) node[\CFcouleur,midway,font=\small\sffamily\bfseries] {\CFL} ; %LE RECTANGLE "MENU" \ifboolKV[paramfenxcas]{Menu}%si menu=true {\draw[\CFcouleur,fill=\CFcouleur!25] (A5\CFL) rectangle ++ (-0.65,0.25) node[black,midway,font=\tiny\sffamily\bfseries] {MENU} ;}% {} %LE BLOC "TITRE" \ifboolKV[paramfenxcas]{Titre}%si titre=true {\draw[\CFcouleur,fill=lightgray!25,rounded corners] ($(A01) + (0,2pt)$) rectangle ++ ($({\CFlarg},2em)$) node[ForestGreen!50!\CFcouleur,midway,font=\CFtailletitre\ttfamily\bfseries] {\CFlabeltitre};} {} } %=========CONSOLEPYTHON=========== OK !! \defKV[envpythonconsole]{% Largeur=\def\CSPYlargeur{#1},% Centre=\testboolKV{#1} {\def\hookcenterpre{\begin{center}}\def\hookcenterpost{\end{center}}} {\def\hookcenterpre{\begin{flushleft}}\def\hookcenterpost{\end{flushleft}}} } \setKVdefault[envpythonconsole]{% Largeur=\linewidth,% Centre=true,% Label=true } \newenvironment{ConsolePythontex}[1][]{% \useKVdefault[envpythonconsole]% \setKV[envpythonconsole]{#1}% on paramètres les nouvelles clés et on les simplifie \VerbatimEnvironment \hookcenterpre \begin{minipage}{\CSPYlargeur} \ifboolKV[envpythonconsole]{Label}%si label {\begin{pyconsole}[][% framesep=3mm,frame=single,fontsize=\footnotesize,framerule=1pt,rulecolor=\color{ForestGreen},label={[\scriptsize Début de la console python]\scriptsize Fin de la console python}]}% {\begin{pyconsole}[][% framesep=3mm,frame=single,fontsize=\footnotesize,framerule=1pt,rulecolor=\color{ForestGreen}]} } { \end{pyconsole} \end{minipage} \hookcenterpost } %=========CODEPYTHONTEX=========== OK!! \defKV[envpythonverb]{% Largeur=\def\CODPYlargeur{#1},% Centre=\testboolKV{#1} {\def\verbcenterpre{\begin{center}}\def\verbcenterpost{\end{center}}} {\def\verbcenterpre{}\def\verbcenterpost{}} } \setKVdefault[envpythonverb]{% Largeur=\linewidth,% Centre=true,% Lignes=true } \tcbset{stylepythontex/.style={% enhanced,boxrule=1.25pt,% sharp corners=downhill,arc=12pt, before skip=12pt,after skip=12pt,% top=10pt,bottom=1mm,rightupper=4pt,%leftupper=25pt, attach boxed title to top right={yshift=-\tcboxedtitleheight}, boxed title style={ size=small,colback=ForestGreen!25,boxrule=1.25pt, colframe=Green,boxsep=1.25pt, sharp corners=downhill, arc=12pt, top=2pt,bottom=1pt,left=6pt,right=6pt }, fonttitle=\color{ForestGreen}\itshape\ttfamily\footnotesize, title={\scriptsize\faPython}\:Code Python\vphantom{p}, watermark text={\faPython},watermark opacity=0.175,watermark zoom=0.50, } } \tcbset{stylepythonnolineos/.style={% stylepythontex,leftupper=10pt, colframe=Green,colback=ForestGreen!5,% fontlower=\small,% before upper = \renewcommand\theFancyVerbLine{\scriptsize\ttfamily\color{Green}\arabic{FancyVerbLine}} } } \tcbset{stylepythonlineos/.style={% stylepythontex,leftupper=25pt, colframe=Green,colback=ForestGreen!5,% fontlower=\small,% before upper = \renewcommand\theFancyVerbLine{\scriptsize\ttfamily\color{Green}\arabic{FancyVerbLine}} } } \newtcolorbox{tcpythontexcode}[1][\linewidth]{% width=#1,stylepythonlineos } \newtcolorbox{tcpythontexcodeno}[1][\linewidth]{% width=#1,stylepythonnolineos } \newenvironment{CodePythontex}[1][]{% \useKVdefault[envpythonverb]% \setKV[envpythonverb]{#1}% on paramètres les nouvelles clés et on les simplifie \VerbatimEnvironment \verbcenterpre \ifboolKV[envpythonverb]{Lignes}%si lignes=true {\begin{tcpythontexcode}[\CODPYlargeur]} {\begin{tcpythontexcodeno}[\CODPYlargeur]} \ifboolKV[envpythonverb]{Lignes}%si lignes=true {\begin{pyverbatim}[][fontsize=\footnotesize,numbers=left,numbersep=10pt,commandchars=\\\{\},mathescape]} {\begin{pyverbatim}[][numbers=none,numbersep=0pt,fontsize=\footnotesize,commandchars=\\\{\},mathescape]} } { \end{pyverbatim} \ifboolKV[envpythonverb]{Lignes}%si lignes=true {\end{tcpythontexcode}} {\end{tcpythontexcodeno}} \verbcenterpost } %=========PYTHONMINTED========= OK !! \tcbset{pytmintedno/.style={% listing engine=minted,minted style=colorful, minted language=python,listing only, minted options={tabsize=4,fontsize=\footnotesize,autogobble}, } } \tcbset{pytminted/.style={% listing engine=minted,minted style=colorful, minted language=python,listing only, minted options={tabsize=4,fontsize=\footnotesize,autogobble,xleftmargin=16pt,linenos,numbersep=10pt}, } } \DeclareTCBListing{CodePythonMinted}{ s O{12cm} O{} }{% étoilée sans numéro, taille puis option... \IfBooleanTF{#1}{pytmintedno}{pytminted}, enhanced,width=#2,#3, colframe=Green,colback=ForestGreen!5,% boxrule=1.25pt, sharp corners=downhill,arc=12pt, before skip=12pt,after skip=12pt,% leftupper=8pt,top=10pt,bottom=4pt,rightupper=4pt,% attach boxed title to top right={yshift=-\tcboxedtitleheight}, boxed title style={ size=small,colback=ForestGreen!25,boxrule=1.25pt, colframe=Green,boxsep=1.25pt, sharp corners=downhill, arc=12pt, top=2pt,bottom=1pt,left=6pt,right=6pt }, fonttitle=\color{ForestGreen}\itshape\ttfamily\footnotesize, title={\scriptsize\faPython}\:Code Python\vphantom{y}, watermark text={\faPython},watermark opacity=0.175,watermark zoom=0.50, before upper = \renewcommand{\theFancyVerbLine}{\scriptsize\ttfamily\color{Green}\arabic{FancyVerbLine}} } %=======STYLE ALGO LST========= OK ! \ifluatex \tcbuselibrary{listings} \lstdefinelanguage{langnat}{% keywords={}, inputencoding=utf8, comment=[l]{}} \lstdefinestyle{PLpython}{% language = python, inputencoding = utf8, basicstyle = \ttfamily\footnotesize, keywordstyle = \color{ForestGreen}, keywordstyle = [2]\color{magenta}, commentstyle = \color{gray}\itshape, stringstyle = \color{red!75}, numberstyle = \scriptsize\ttfamily\color{Green}, aboveskip = 0pt, belowskip = 0pt, tabsize = 4, showstringspaces = false, columns = fullflexible, keepspaces = true, breaklines = true, breakatwhitespace = true } \else \tcbuselibrary{listingsutf8} \lstdefinelanguage{langnat}{% keywords={}, inputencoding=utf8/latin1, comment=[l]{}} \lstdefinestyle{PLpython}{% language = python, inputencoding = utf8/latin1, basicstyle = \ttfamily\footnotesize, keywordstyle = \color{ForestGreen}, keywordstyle = [2]\color{magenta}, commentstyle = \color{gray}\itshape, stringstyle = \color{red!75}, numberstyle = \scriptsize\ttfamily\color{Green}, aboveskip = 0pt, belowskip = 0pt, tabsize = 4, showstringspaces = false, columns = fullflexible, keepspaces = true, breaklines = true, breakatwhitespace = true } \fi %=======PYTHONLISTINGS========= OK !! \tcbset{stylepythonlst/.style={% enhanced,boxrule=1.25pt,% leftupper=10pt, sharp corners=downhill,arc=12pt, before skip=12pt,after skip=12pt,% top=10pt,bottom=1mm,rightupper=4pt,%leftupper=25pt, attach boxed title to top right={yshift=-\tcboxedtitleheight}, boxed title style={ size=small,colback=ForestGreen!25,boxrule=1.25pt, colframe=Green,boxsep=1.25pt, sharp corners=downhill, arc=12pt, top=2pt,bottom=1pt,left=6pt,right=6pt }, colframe=Green,colback=ForestGreen!5,% fonttitle=\color{ForestGreen}\itshape\ttfamily\footnotesize, title={\scriptsize\faPython}\:Code Python\vphantom{p}, watermark text={\faPython},watermark opacity=0.175,watermark zoom=0.50, listing only,listing engine=listings,% } } \tcbset{stylepythonlstnolineos/.style={% stylepythonlst, listing options={style=PLpython,xleftmargin=0pt,numbers=none} } } \tcbset{stylepythonlstlineos/.style={% stylepythonlst, listing options={style=PLpython,xleftmargin=16pt,numbers=left} } } \DeclareTCBListing{CodePythonLst}{ s O{\linewidth} m }{% * off pour numéros de lignes + {largeur} + \IfBooleanTF{#1}{stylepythonlstnolineos}{stylepythonlstlineos}, width=#2,#3 } \NewTCBInputListing{\CodePythonLstFichier}{ s O{\linewidth} m m }{ \IfBooleanTF{#1}{stylepythonlstnolineos}{stylepythonlstlineos}, width=#2,#3, listing file={#4}} %=========PYTHONPITON========== OK !! \defKV[envpiton]{% Largeur=\def\CODPITlargeur{#1},% Alignement=\def\CODPITalign{#1} } \setKVdefault[envpiton]{% Largeur=\linewidth,% Alignement=center,% Lignes=true } \ifluatex \RequirePackage{piton} \NewPitonEnvironment{CodePiton}{ O{} }% {% \useKVdefault[envpiton]% \setKV[envpiton]{#1}% on paramètres les nouvelles clés et on les simplifie \ifboolKV[envpiton]{Lignes}%si lignes=true {\PitonOptions{left-margin=auto,line-numbers}}% {\PitonOptions{}}% \begin{tcolorbox}[stylepythontex,leftupper=8pt,colframe=Green,colback=ForestGreen!5,width=\CODPITlargeur,fontupper=\footnotesize,fontlower=\footnotesize,\CODPITalign] }% {% \end{tcolorbox}% } \fi %=========PSEUDOCODE=========== OK !! %language pseudocode listings \lstdefinestyle{pseudocodePL}{% language=langnat, basicstyle=\footnotesize\ttfamily, numberstyle=\scriptsize\ttfamily\color{gray}, keywordstyle=\bfseries, stringstyle=\color{red!75}, keepspaces=true, tabsize=4,numbersep=10pt, xleftmargin=14pt, numbers=left, morestring=[b]", showstringspaces=false, %showtabs=false, escapeinside={(*}{*)} } \lstdefinestyle{pseudocodenoPL}{% language=langnat, basicstyle=\footnotesize\ttfamily, numberstyle=\scriptsize\ttfamily\color{gray}, keywordstyle=\bfseries, stringstyle=\color{red!75}, keepspaces=true, tabsize=4,numbersep=10pt, numbers=none, showstringspaces=false, morestring=[b]", %showtabs=true, escapeinside={(*}{*)} } %style tcbox pseudocode avec bannière hautdroite \tcbset{stylepseudocodePL/.style={% %fontupper=\small\sffamily,% enhanced,boxrule=1.25pt,sharp corners=downhill,arc=12pt, before skip=12pt,after skip=12pt,leftupper=10pt,top=8pt,bottom=2pt,rightupper=4pt,% attach boxed title to top right={yshift=-\tcboxedtitleheight}, boxed title style={ size=small,colback=gray!25,boxrule=1.25pt, colframe=darkgray,boxsep=1.25pt, sharp corners=downhill, arc=12pt, top=2pt,bottom=1pt,left=6pt,right=6pt }, fonttitle=\color{darkgray}\ttfamily\footnotesize, title={\scriptsize\faFileCode}\:\textit{Pseudo-Code}\vphantom{p}, watermark text={\faCode},watermark opacity=0.175,watermark zoom=0.50, } } \ifluatex \newcommand\algomathttPL[1]{\symtt{#1}} \else \newcommand\algomathttPL[1]{\mathtt{#1}} \fi \DeclareTCBListing{PseudoCode}{ s O{12cm} !O{} }{% étoilée sans numéro, taille puis option... width=#2,#3, stylepseudocodePL, listing only,listing engine=listings, listing options={ style=\IfBooleanTF{#1}{pseudocodenoPL}{pseudocodePL},%version étoilée sans numéro de lignes aboveskip=2pt,belowskip=2pt, columns=fullflexible, literate={é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1% {ú}{{\'u}}1 {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1% {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1% {À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1% {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1% {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1% {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1% {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1% {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1% {ű}{{\H{u}}}1 {Ű}{{\H{U}}}1 {ő}{{\H{o}}}1 {Ő}{{\H{O}}}1% {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1% {€}{{\texteuro}}1 {£}{{\pounds}}1% {=}{\textleftarrow}1 {==}{=}1% {*}{$\algomathttPL{\times}$}{1}% } } %============FakeTerm=========== OK !! %couleurs (inspirées par termsim !) \definecolor{PLmpurple}{RGB}{48,10,36} \definecolor{PLmgray}{RGB}{70,72,67} \definecolor{PLogray}{RGB}{148,147,141} \definecolor{PLoorange}{RGB}{233,101,56} \definecolor{PLterminal}{RGB}{80,78,70} \definecolor{PLlinux}{RGB}{0,39,51} \definecolor{PLwinblue}{HTML}{1883D7} \definecolor{PLosxgray}{HTML}{D8D6D9} %WINDOWS \tcbset{PLfaketermwin/.style={% enhanced,boxrule=1pt,sharp corners,before skip=12pt,after skip=12pt,% colframe=PLwinblue,colback=black,colbacktitle=white,colupper=white,coltitle=black,% titlerule=0.4pt,left=2pt,top=2pt,bottom=2pt,right=2pt,middle=2pt,% fonttitle=\bfseries\small\sffamily } } \setKVdefault[fakeTERMwin]{Titre={Terminal Windows}} \newcommand\PLcommandeswin{% \begin{tikzpicture}[thick,scale=0.66] \draw (0,0)--(1em,0) ; \draw (2em,0) rectangle (3em,1em) ; \draw (4em,1em)--(5em,0) (4em,0)--(5em,1em) ; \end{tikzpicture}% } \newcommand\termwintitre[1][]{% \restoreKV[fakeTERMwin] \setKV[fakeTERMwin]{#1} \begin{tblr}{colsep=0pt,rowsep=0pt,width=\linewidth,colspec={X[l]r}} {\footnotesize\faTerminal}~~\useKV[fakeTERMwin]{Titre} & \PLcommandeswin \\ % \end{tblr} } \DeclareTCBListing{TerminalWin}{ O{\linewidth} m !O{} }{%[taille] puis {Titre=...} puis [option] PLfaketermwin,title={\termwintitre[#2]},% listing only,listing engine=listings,% listing options={style=tcblatex,language={},basicstyle=\footnotesize\ttfamily},% width=#1,#3 } %LINUX \newcommand{\PLUbuntuWhite}{% \begin{tikzpicture}[thick,anchor=base,baseline] \filldraw[PLmgray] (0,0.25em) circle[radius=0.5em] ; \end{tikzpicture}% } \newcommand{\PLUbuntuMin}{% \begin{tikzpicture}[thick,anchor=base,baseline] \filldraw[color=PLogray!50!white] (0,0.25em) circle[radius=0.5em]; \draw[PLterminal](-0.35em,0.25em)--(0.35em,0.25em); \end{tikzpicture}% } \newcommand{\PLUbuntuClose}{% \begin{tikzpicture}[thick,anchor=base,baseline] \filldraw[color=PLoorange!70!white] (0,0.25em) circle[radius=0.5em]; \draw[PLterminal] (-0.32em,-0.07em)--(0.32em,0.57em); \draw[PLterminal] (-0.32em,0.57em)--(0.32em,-0.07em); \end{tikzpicture}% } \newcommand{\PLUbuntuMax}{% \begin{tikzpicture}[thick,anchor=base,baseline] \filldraw[color=PLogray!50!white] (0,0.25em) circle[radius=0.5em]; \draw[PLterminal] (-0.32em,0.5em) rectangle (0.32em,0); \end{tikzpicture}% } \tcbset{PLtermlinux/.style={% enhanced,boxrule=1pt,arc=4pt,before skip=12pt,after skip=12pt,% colframe=PLmgray,colback=PLmpurple,colbacktitle=PLmgray,colupper=white,coltitle=white,% titlerule=0.4pt,left=2pt,top=2pt,bottom=2pt,right=2pt,middle=2pt,% fonttitle=\bfseries\small\sffamily } } \setKVdefault[fakeTERMnux]{Titre={Terminal UNiX}} \newcommand\termnuxtitre[1][]{% \restoreKV[fakeTERMnux] \setKV[fakeTERMnux]{#1} \begin{tblr}{colsep=0pt,rowsep=0pt,width=\linewidth,colspec={lX[c]r}} \PLUbuntuWhite~~\PLUbuntuWhite~~\PLUbuntuWhite & \vphantom{p}\useKV[fakeTERMnux]{Titre} & \PLUbuntuMin~~\PLUbuntuMax~~\PLUbuntuClose \\ \end{tblr} } \DeclareTCBListing{TerminalUnix}{ O{\linewidth} m !O{} }{%[taille] puis {Titre=...} puis [option] PLtermlinux,title={\termnuxtitre[#2]},% listing only,listing engine=listings,% listing options={style=tcblatex,language={},basicstyle=\footnotesize\ttfamily},% width=#1,#3 } %OSX \tcbset{PLfaketermosx/.style={% enhanced,boxrule=1pt,arc=6pt,before skip=12pt,after skip=12pt,% colframe=PLosxgray,colback=lightgray!15,colbacktitle=PLosxgray,colupper=black,coltitle=black,% titlerule=0.4pt,left=2pt,top=2pt,bottom=2pt,right=2pt,middle=2pt,% fonttitle=\bfseries\small\sffamily } } \newcommand{\PLOSXRed}{% \begin{tikzpicture}[thick,anchor=base,baseline] \filldraw[red] (0,0.25em) circle[radius=0.45em] ; \end{tikzpicture}% } \newcommand{\PLOSXOrange}{% \begin{tikzpicture}[thick,anchor=base,baseline] \filldraw[orange] (0,0.25em) circle[radius=0.45em] ; \end{tikzpicture}% } \newcommand{\PLOSXGreen}{% \begin{tikzpicture}[thick,anchor=base,baseline] \filldraw[ForestGreen] (0,0.25em) circle[radius=0.45em] ; \end{tikzpicture}% } \newcommand{\PLOSXLG}{% \begin{tikzpicture}[thick,anchor=base,baseline] \filldraw[PLosxgray] (0,0.25em) circle[radius=0.45em] ; \end{tikzpicture}% } \setKVdefault[fakeTERMosx]{titre={Terminal OSX}} \newcommand\termosxtitre[1][]{% \restoreKV[fakeTERMosx] \setKV[fakeTERMosx]{#1} \begin{tblr}{colsep=0pt,rowsep=0pt,width=\linewidth,colspec={lX[c]r}} \PLOSXRed~\PLOSXOrange~\PLOSXGreen & \vphantom{p}\useKV[fakeTERMosx]{Titre} & \PLOSXLG~\PLOSXLG~\PLOSXLG \\ \end{tblr} } \DeclareTCBListing{TerminalOSX}{ O{\linewidth} m !O{} }{%[taille] puis {Titre=...} puis [option] PLfaketermosx,title={\termosxtitre[#2]},% listing only,listing engine=listings,% listing options={style=tcblatex,language={},basicstyle=\footnotesize\ttfamily},% width=#1,#3 } %============CartoucheCapytale========= OK !! \definecolor{vertcapyt}{rgb}{0.0,0.5,0.0} %\definecolor{vertcapyt}{HTML}{008000} \DeclareTotalTCBox{\CartoucheCapytale}{ s O{} m } {enhanced,size=fbox,on line,arc=3pt,colback=vertcapyt,colframe=vertcapyt,fontupper=\IfBooleanTF{#1}{\ttfamily}{\sffamily}\bfseries,colupper=white}% {#3#2~{\scriptsize\faLink}} %============PaveDroitTikZ============= OK !! \defKV[paramspave]{% Largeur=\xdef\PFPaveLg{#1},% Profondeur=\xdef\PFPavePf{#1},% Hauteur=\xdef\PFPaveHt{#1},% Angle=\xdef\PFPaveAngl{#1},% Fuite=\xdef\PFPaveFuite{#1},% Sommets=\def\PFPaveSommets{#1},% Epaisseur=\xdef\PFPaveThick{#1} } \setKVdefault[paramspave]{% Aff=false,% Plein=false,% Largeur=2,% Profondeur=1,% Hauteur=1.25,% Angle=30,% Fuite=0.5,% Epaisseur=thick,% Sommets=A§B§C§D§E§F§G§H,% Cube=false } \newcommand\PaveTikz[1][]{% \useKVdefault[paramspave]% \setKV[paramspave]{#1}% \ifboolKV[paramspave]{Cube} {\xdef\PFPavePf{\PFPaveLg}% \xdef\PFPaveHt{\PFPaveLg}} {} \setsepchar{§}% \readlist*\PFListeSommets\PFPaveSommets \itemtomacro\PFListeSommets[1]\PaveA \itemtomacro\PFListeSommets[2]\PaveB \itemtomacro\PFListeSommets[3]\PaveC \itemtomacro\PFListeSommets[4]\PaveD \itemtomacro\PFListeSommets[5]\PaveE \itemtomacro\PFListeSommets[6]\PaveF \itemtomacro\PFListeSommets[7]\PaveG \itemtomacro\PFListeSommets[8]\PaveH %les nœuds du pave \coordinate (\PaveA) at (0,0) ; \coordinate (\PaveB) at ({\PFPaveLg},0) ; \coordinate (\PaveC) at ($(\PaveB) + ({\PFPaveAngl}:{\PFPaveFuite*\PFPavePf})$) ; \coordinate (\PaveD) at ($(\PaveA) + ({\PFPaveAngl}:{\PFPaveFuite*\PFPavePf})$) ; \coordinate (\PaveE) at ($(\PaveA) + (0,{\PFPaveHt})$) ; \coordinate (\PaveF) at ($(\PaveB) + (0,{\PFPaveHt})$) ; \coordinate (\PaveG) at ($(\PaveC) + (0,{\PFPaveHt})$) ; \coordinate (\PaveH) at ($(\PaveD) + (0,{\PFPaveHt})$) ; \ifboolKV[paramspave]{Aff} {\draw (\PaveA) node[below left] {\PaveA} ; \draw (\PaveB) node[below right] {\PaveB} ; \draw (\PaveC) node[above right] {\PaveC} ; \ifboolKV[paramspave]{Plein} {} {\draw (\PaveD) node[above left] {\PaveD} ;} \draw (\PaveE) node[below left] {\PaveE} ; \draw (\PaveF) node[below right] {\PaveF} ; \draw (\PaveG) node[above right] {\PaveG} ; \draw (\PaveH) node[above left] {\PaveH} ;} {}%on affiche rien \draw[\PFPaveThick] (\PaveA)--(\PaveB)--(\PaveF)--(\PaveE)--cycle (\PaveB)--(\PaveC)--(\PaveG)--(\PaveF)--cycle (\PaveG)--(\PaveH)--(\PaveE) ; \ifboolKV[paramspave]{Plein} {} {\draw[dashed,\PFPaveThick] (\PaveA)--(\PaveD)--(\PaveC) (\PaveD)--(\PaveH) ;} } %============TétraèdreTikZ============= OK !! \defKV[paramstetra]{% Largeur=\xdef\PFTetraLg{#1},% Profondeur=\xdef\PFTetraPf{#1},% Hauteur=\xdef\PFTetraHt{#1},% Alpha=\xdef\PFTetraAlpha{#1},% Beta=\xdef\PFTetraBeta{#1},% Sommets=\def\PFTetraSommets{#1},% Epaisseur=\xdef\PFTetraThick{#1} } \setKVdefault[paramstetra]{% Aff=false,% Plein=false,% Largeur=4,% Profondeur=1.25,% Hauteur=3,% Alpha=40,% Beta=60,% Epaisseur=thick,% Sommets=A§B§C§D,% } \newcommand\TetraedreTikz[1][]{% \useKVdefault[paramstetra]% \setKV[paramstetra]{#1}% \setsepchar{§}% \readlist*\PFListeSommets\PFTetraSommets \itemtomacro\PFListeSommets[1]\TetraA \itemtomacro\PFListeSommets[2]\TetraB \itemtomacro\PFListeSommets[3]\TetraC \itemtomacro\PFListeSommets[4]\TetraD %les nœuds du tétraèdre \coordinate (\TetraA) at (0,0) ; \coordinate (\TetraB) at ($(\TetraA) + ({-\PFTetraAlpha}:{\PFTetraPf})$) ; \coordinate (\TetraC) at ({\PFTetraLg},0) ; \coordinate (\TetraD) at ($(\TetraA) + ({\PFTetraBeta}:{\PFTetraHt})$) ; \ifboolKV[paramstetra]{Aff} {\draw (\TetraA) node[left] {\TetraA} ; \draw (\TetraB) node[below] {\TetraB} ; \draw (\TetraC) node[right] {\TetraC} ; \draw (\TetraD) node[above] {\TetraD} ;} {}%on affiche rien \draw[\PFTetraThick] (\TetraA)--(\TetraD)--(\TetraC)--(\TetraB)--cycle (\TetraD)--(\TetraB) ; \ifboolKV[paramstetra]{Plein} {} {\draw[dashed,\PFTetraThick] (\TetraA)--(\TetraC) ;} } %============EnsembleList============== OK !! \defKV[kvensemble]{% Sep=\def\PLenssep{#1},% Option=\def\PLensopt{#1} } \setKVdefault[kvensemble]{% Sep={;},% Mathpunct=true,% Option={} } \newcommand\EcritureEnsemble[2][]{% \useKVdefault[kvensemble]% \setKV[kvensemble]{#1}% \ifboolKV[kvensemble]{Mathpunct}% {\left\lbrace \PLensopt{} \mathpunct{} \StrSubstitute{#2}{/}{\mathpunct{}{\PLenssep}\mathpunct{}} \mathpunct{} \right\rbrace}% {\left\lbrace \PLensopt{} \StrSubstitute{#2}{/}{{\PLenssep}} \right\rbrace} } %===============SimplFrac============== OK !! \DeclareDocumentCommand\ConversionFraction{ O{} m }{% argument optionnel [d ou t] puis argument mandataire {calcul ou fraction} \def\calculargument{\xintPRaw{\xintIrr{\xinteval{#2}}}}%on calcule et on transforme en A/B \IfSubStr{\calculargument}{/}%on teste si le symbole / apparaît {%si oui := fraction \StrBefore{\calculargument}{/}[\numerateur]%on extrait le numérateur \StrBehind{\calculargument}{/}[\denominateur]%on extrait le dénominateur \ifblank{#1}{\ensuremath{\frac{\num{\numerateur}}{\num{\denominateur}}}}{}%si l'argument optionnel est vide \IfStrEq{#1}{d}{\ensuremath{\dfrac{\num{\numerateur}}{\num{\denominateur}}}}{}%si l'arg opt est d \IfStrEq{#1}{t}{\ensuremath{\tfrac{\num{\numerateur}}{\num{\denominateur}}}}{}%si l'arg opt est t }{%si non := entier \num{\calculargument}%on affiche l'entier, avec le package siunitx } } %================CabWeb================ OK !! \defKV[webrecurr]{% Fct=\def\PLRecurfct{#1},% Nom=\def\PLRecurnom{#1},% No=\def\PLRecurno{#1},% Nb=\def\PLRecurnb{#1},% Uno=\def\PLRecuruno{#1},% PosLabel=\def\PLRecurposlab{#1},% DecalLabel=\def\PLRecuroffset{#1},% TailleLabel=\def\PLRecurlabelsize{#1} } \setKVdefault[webrecurr]{ No=0,% Nom=u,% Nb=5,% AffTermes=true,% PosLabel=below,% DecalLabel=6pt,% TailleLabel=\small } %\newcommand\recurr[1][]{% \NewDocumentCommand\ToileRecurrence{ O{} O{thick,color=magenta} O{dotted} }{ % +