From a4684cb113c31d2fd9395b0016c3b200304cf1c3 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 14 Feb 2022 21:25:13 +0000 Subject: proflycee (14feb22) git-svn-id: svn://tug.org/texlive/trunk@62027 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/proflycee/ProfLycee.sty | 361 +++++++++++++++++++++ 1 file changed, 361 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty (limited to 'Master/texmf-dist/tex/latex/proflycee') diff --git a/Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty b/Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty new file mode 100644 index 00000000000..ceaf2ef1911 --- /dev/null +++ b/Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty @@ -0,0 +1,361 @@ +% 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/02/13 - v1.0.2 - Aide pour l'utilisation de LaTeX en lycée] +% 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 + +%------Packages utiles +\RequirePackage[table,svgnames]{xcolor}%Gestion des couleurs +\RequirePackage{tikz} +\RequirePackage{pgf,pgffor} +\RequirePackage{ifthen} +\RequirePackage{xkeyval} +\RequirePackage{xfp} +\RequirePackage{xstring} +\RequirePackage{simplekv} +\RequirePackage{listofitems} +\RequirePackage{xintexpr} +\RequirePackage{fontawesome5} +%librairies tikz +\usetikzlibrary{calc} +\usetikzlibrary{decorations.pathreplacing} +\usetikzlibrary{decorations.markings} +\usetikzlibrary{arrows.meta} +%tcolorbox +\RequirePackage[most]{tcolorbox} +%divers +\RequirePackage{ifluatex} +%python +\RequirePackage{fancyvrb} +\RequirePackage[gobble=auto]{pythontex} +\setpythontexlistingenv{pythont} + +%---------------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]{% + liste=\def\SPLliste{#1},% + width=\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]{% + liste=,% + width=1.25pt,% + couleur=red,% + coeffs=3,% + couleurpoints=black,% + taillepoints=2pt,% + affpoints=false,% + style= +} + +\newcommand\splinetikz[1][]{% + \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\SPLliste + \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]{% + liste=\def\TGTliste{#1},% + width=\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]{ + liste=,% + width=1.25pt,% + couleur=red,% + xl=0.5,xr=0.5,% + style=,% + point=1 +} + +\newcommand\tangentetikz[1][]{% + \useKVdefault[tgte]% + \setKV[tgte]{#1}% on paramètres les nouvelles clés et on les simplifie + \setsepchar[.]{§./}% + \readlist\TGTlistepoints\TGTliste + \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 CLES PARAM FENETRES XCAS +\defKV[paramfenxcas]{% + larg=\def\CFlarg{#1},% + esplg=\def\CFesplg{#1},% + premcol=\def\CFpremcol{#1},% + hpremcol=\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]{% + larg=16,esplg=2pt,premcol=0.3,hpremcol=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\paramCF[1][]{% + \setcounter{CFnum}{0} + \useKVdefault[paramfenxcas]% + \setKV[paramfenxcas]{#1}% on paramètres les nouvelles clés et on les simplifie +} +% ========= DEF DES CLES PARAM LIGNES XCAS ========= +\defKV[paramlgxcas]{% + hc=\def\CFhle{#1},% + hr=\def\CFhlr{#1} +} +\setKVdefault[paramlgxcas]{hc=0.75,hr=0.75} +\newcommand\ligneCF[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] {#2} ;} + {} + \IfStrEq{\CFposcmd}{gauche}%si poscmd=left + {\draw (C1\CFL) node[right,\CFcoulcmd] {#2} ;} + {} + \IfStrEq{\CFposcmd}{right}%si poscmd=right + {\draw (C3\CFL) node[left,\CFcoulcmd] {#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] {#3} ;} + {} + \IfStrEq{\CFposres}{gauche}%si posrep=left + {\draw (R1\CFL) node[right,\CFcoulres] {#3} ;} + {} + \IfStrEq{\CFposres}{right}%si posrep=right + {\draw (R3\CFL) node[left,\CFcoulres] {#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{envconsolepythontex}[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 sep=true + {\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{/}, + 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{envcodepythontex}[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 +} + +\endinput \ No newline at end of file -- cgit v1.2.3