From 51ba34542862fbf7dfac40fd52fd8bed8b2c7dcf Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 4 Apr 2023 20:11:49 +0000 Subject: proflycee (4apr23) git-svn-id: svn://tug.org/texlive/trunk@66759 c570f23f-e606-0410-a88d-b1316a301751 --- .../doc/latex/proflycee/ProfLycee-doc.pdf | Bin 806464 -> 812698 bytes .../doc/latex/proflycee/ProfLycee-doc.tex | 104 ++++++-- .../proflycee/ProfLycee-exemples-pyluatex.pdf | Bin 0 -> 60443 bytes .../proflycee/ProfLycee-exemples-pyluatex.tex | 263 +++++++++++++++++++++ .../texmf-dist/tex/latex/proflycee/ProfLycee.sty | 38 +-- .../tex/latex/proflycee/proflycee-tools-minted.tex | 12 +- .../tex/latex/proflycee/proflycee-tools-piton.tex | 150 +++++++++++- 7 files changed, 508 insertions(+), 59 deletions(-) create mode 100644 Master/texmf-dist/doc/latex/proflycee/ProfLycee-exemples-pyluatex.pdf create mode 100644 Master/texmf-dist/doc/latex/proflycee/ProfLycee-exemples-pyluatex.tex diff --git a/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.pdf b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.pdf index 962b919ad3b..f44e4ef13a4 100644 Binary files a/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.pdf and b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.pdf differ diff --git a/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.tex b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.tex index a1d113a5fee..51bd79b3e7a 100644 --- a/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.tex +++ b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.tex @@ -5,8 +5,8 @@ % arara: lualatex: {shell: yes, synctex: no, interaction: batchmode} if found('log', '(undefined references|Please rerun|Rerun to get)') \documentclass[a4paper,french,11pt]{article} -\def\PLversion{2.5.6} -\def\PLdate{31 Mars 2023} +\def\PLversion{2.5.7} +\def\PLdate{4 Avril 2023} \usepackage{ProfLycee} \useproflyclib{piton,minted,pythontex} %\usepackage{lualatex-math} @@ -568,6 +568,7 @@ Elles sont présentées de manière \textit{succincte}, mais elles sont présent \begin{CodePythonLst}(*)[largeur]{commandes tcbox}...\end{CodePythonLst} %:=librairie piton \begin{CodePiton}[options]...\end{CodePiton} +\begin{PitonConsole}[options Piton]{paramètres tcbox}...\end{PitonConsole} %:=librairie pythontex \begin{CodePythontex}[options]...\end{CodePythontex} \begin{ConsolePythontex}[options]...\end{ConsolePythontex} @@ -2327,14 +2328,17 @@ def trace_parabole_tableaux(): \begin{codeinfo} \cmaj{2.5.0} Cette section nécessite de charger la \textsf{librairie} \clib{piton} dans le préambule. + +\cmaj{2.5.7} Une console Python est disponible, elle nécessite le package \ctex{pyluatex}, qui n'est pas chargé par \ctex{ProfLycee}, du fait de l'obligation de spécifier le \textit{chemin} pour l'exécutable Python ! \end{codeinfo} \begin{codetex}[listing only] +\usepackage[executable=...]{pyluatex} %si utilisation de la console REPL \useproflyclib{piton} \end{codetex} \begin{codeinfo} -\cmaj{2.0.0} La \textsf{librairie} \clib{piton} (qui charge \ctex{piton}, est compatible uniquement avec \hologo{LuaLaTeX} !) permet d'insérer du code Python avec une coloration syntaxique en utilisant la bibliothèque \textsf{Lua LPEG}. +La \textsf{librairie} \clib{piton} (qui charge \ctex{piton}, est compatible uniquement avec \hologo{LuaLaTeX} !) permet d'insérer du code Python avec une coloration syntaxique en utilisant la bibliothèque \textsf{Lua LPEG}. \smallskip @@ -2342,17 +2346,23 @@ En \textit{partenariat} avec \ctex{tcolorbox}, on peut avoir une présentation d \smallskip -\cmaj{2.0.2} Depuis la version \ctex{0.95} de \ctex{piton}, \Cle{left-margin=auto} est disponible et activée dans \ctex{ProfLycee}. +Depuis la version \ctex{0.95} de \ctex{piton}, \Cle{left-margin=auto} est disponible et activée dans \ctex{ProfLycee}. -\cmaj{2.1.2} Depuis la version \ctex{0.99} de \ctex{piton}, \Cle{break-lines} est disponible et activée dans \ctex{ProfLycee}. +Depuis la version \ctex{0.99} de \ctex{piton}, \Cle{break-lines} est disponible et activée dans \ctex{ProfLycee}. -\cmaj{2.1.3} Depuis la version \ctex{1.0} de \ctex{piton}, \Cle{tabs-auto-gobble} est disponible et activée dans \ctex{ProfLycee}. +Depuis la version \ctex{1.0} de \ctex{piton}, \Cle{tabs-auto-gobble} est disponible et activée dans \ctex{ProfLycee}. \end{codeinfo} \begin{codeattention} Le package \ctex{piton} nécessite donc obligatoirement l’emploi de \hologo{LuaLaTeX} ! -\cmaj{2.0.1} Ce package n'est chargé que si la compilation détectée est en \hologo{LuaLaTeX} ! +Ce package n'est chargé que si la compilation détectée est en \hologo{LuaLaTeX} ! + +\smallskip + +\cmaj{2.5.7} L'utilisation de la console \textbf{REPL} nécessite une compilation en \ctex{--shell-escape} ou \ctex{-write18} ! + +\cmaj{2.5.7} Les packages \ctex{pyluatex} et \ctex{pythontex} utilisent des commandes de même nom, donc la présente documentation n'utilisera pas le package \ctex{pyluatex}. Une documentation annexe spécifique est disponible. \end{codeattention} \subsection{Présentation de code Python} @@ -2363,25 +2373,29 @@ Le package \ctex{piton} nécessite donc obligatoirement l’emploi de \hologo{Lu \end{CodePiton} \end{codetex} -%\begin{codeattention} -%Les environnements créés par \ctex{piton} et \ctex{tcolorbox} ne sont -- a priori -- pas compatibles avec les options de type \Cle{gobble} (pour supprimer les tabulations d'environnement), donc il faut bien penser à \og aligner \fg{} le code à gauche, pour éviter des tabulations non esthétiques ! -%\end{codeattention} - \begin{codecles} Plusieurs \Cle{clés} sont disponibles : \begin{itemize} \item la clé booléenne \Cle{Lignes} pour afficher ou non les numéros de lignes ; \hfill{}défaut \Cle{true} - \item \cmaj{2.1.3} la clé booléenne \Cle{Gobble} pour activer les options liées au \textsf{gobble} ; \hfill{}défaut \Cle{true} + \item la clé booléenne \Cle{Gobble} pour activer les options liées au \textsf{gobble} ; \hfill{}défaut \Cle{true} \item la clé \Cle{Largeur} qui correspond à la largeur de la \ctex{tcbox} ; \hfill{}défaut \Cle{\textbackslash linewidth} \item la clé \Cle{TaillePolice} pour la taille des caractères ; \hfill{}défaut \Cle{\textbackslash footnotesize} - \item la clé \Cle{Alignement} qui paramètre l'alignement de la \ctex{tcbox}. \hfill{}défaut \Cle{center} + \item la clé \Cle{Alignement} qui paramètre l'alignement de la \ctex{tcbox} ; \hfill{}défaut \Cle{center} + \item \cmaj{2.5.7} la clé \Cle{Style} (parmi \Cle{Moderne / Classique}) pour changer le style ; \hfill{}défaut \Cle{Moderne} + \item \cmaj{2.5.7} le boolén \Cle{Filigrane} pour afficher, le logo {\small \faPython} en filigrane ; \hfill{}défaut \Cle{false} + \item \cmaj{2.5.7} le boolén \Cle{BarreTitre} (si \Cle{Style=Moderne}) pour afficher le titre ; \hfill{}défaut \Cle{true} + \item \cmaj{2.5.7} le boolén \Cle{Cadre} (si \Cle{Style=Moderne}) pour afficher le cadre. \hfill{}défaut \Cle{true} \end{itemize} \end{codecles} +\begin{codeinfo} +Du fait du paramétrage des boîtes \ctex{tcolorbox}, il se peut que le rendu soit non conforme si elle doit être insérée dans une autre \ctex{tcolorbox}\ldots{} ! +\end{codeinfo} + \begin{codetex}[listing only] \begin{CodePiton} -#environnement piton avec numéros de ligne, pleine largeur +#environnement piton avec numéros de ligne, pleine largeur, style moderne def arctan(x,n=10): if x < 0: return -arctan(-x) #> (appel récursif) @@ -2392,9 +2406,32 @@ def arctan(x,n=10): \end{CodePiton} \end{codetex} -\begin{codesortie} \begin{CodePiton} -#environnement piton avec numéros de ligne, pleine largeur +#environnement piton avec numéros de ligne, pleine largeur, style moderne +def arctan(x,n=10): + if x < 0: + return -arctan(-x) #> (appel récursif) + elif x > 1: + return pi/2 - arctan(1/x) #> (autre appel récursif) + else: + return sum( (-1)**k/(2*k+1)*x**(2*k+1) for k in range(n) ) +\end{CodePiton} + +\begin{codetex}[listing only] +\begin{CodePiton}[Style=Classique] +#environnement piton avec numéros de ligne, pleine largeur, style classique +def arctan(x,n=10): + if x < 0: + return -arctan(-x) #> (appel récursif) + elif x > 1: + return pi/2 - arctan(1/x) #> (autre appel récursif) + else: + return sum( (-1)**k/(2*k+1)*x**(2*k+1) for k in range(n) ) +\end{CodePiton} +\end{codetex} + +\begin{CodePiton}[Style=Classique] +#environnement piton avec numéros de ligne, pleine largeur, style classique def arctan(x,n=10): if x < 0: return -arctan(-x) #> (appel récursif) @@ -2403,7 +2440,6 @@ def arctan(x,n=10): else: return sum( (-1)**k/(2*k+1)*x**(2*k+1) for k in range(n) ) \end{CodePiton} -\end{codesortie} \begin{codetex}[listing only] \begin{CodePiton}[Alignement=flush right,Largeur=13cm] @@ -2418,15 +2454,21 @@ def f(x) : \begin{itemize} %Avec des indentations d'environnement : \item On essaye avec un \texttt{itemize} : - - \begin{CodePiton}[Largeur=9cm] + % + \begin{CodePiton}[Largeur=12cm,Style=Classique,Cadre=false] + def f(x) : + return x**2 + \end{CodePiton} + \item Et avec un autre \texttt{itemize} : + % + \begin{CodePiton}[Largeur=12cm,Style=Classique,Cadre=false,BarreTitre=false] + #avec numéros, de largeur 12cm, centré, classique, sans cadre/titre def f(x) : return x**2 \end{CodePiton} \end{itemize} \end{codetex} -\begin{codesortie} \begin{CodePiton}[Alignement=flush right,Largeur=13cm] #avec numéros, de largeur 13cm, aligné à droite def f(x) : @@ -2441,14 +2483,26 @@ def f(x) : \begin{itemize} \item On essaye avec un \texttt{itemize} : - - \begin{CodePiton}[Largeur=9cm] - #avec numéros, de largeur 9cm, centré + % + \begin{CodePiton}[Largeur=12cm,Style=Classique,Cadre=false] + #avec numéros, de largeur 12cm, centré, classique, sans cadre + def f(x) : + return x**2 + \end{CodePiton} + \item Et avec un autre \texttt{itemize} : + % + \begin{CodePiton}[Largeur=12cm,Style=Classique,BarreTitre=false,Cadre=false] + #avec numéros, de largeur 12cm, centré, classique, sans cadre/titre def f(x) : return x**2 \end{CodePiton} \end{itemize} -\end{codesortie} + +\subsection{Console en partenariat avec Pyluatex} + +\begin{codeinfo} +\cmaj{2.5.7} Une console d'exécution (type REPL) est disponible, et la documentation associée est en marge de la présente documentation. +\end{codeinfo} \pagebreak @@ -6276,6 +6330,8 @@ La grille, créée en \TikZ, est portée par le rectangle de \og coins \fg{} $(0 \part{Historique} +{\small \bverb|v 2.5.7|~:~~~~Ajout de clés pour les codes \textsf{Piton} + Console via \textsf{Pyluatex} (page \pageref{pythonpiton}) + {\small \bverb|v 2.5.6|~:~~~~Ajout d'une clé \Cle{Trigo} pour l'axe $(Ox)$ (page \pageref{reperagetikz}) {\small \bverb|v 2.5.5|~:~~~~Externalisation de la fenêtre XCas (dans la package \textsf{FentreCas}) diff --git a/Master/texmf-dist/doc/latex/proflycee/ProfLycee-exemples-pyluatex.pdf b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-exemples-pyluatex.pdf new file mode 100644 index 00000000000..6f6dc42f2ea Binary files /dev/null and b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-exemples-pyluatex.pdf differ diff --git a/Master/texmf-dist/doc/latex/proflycee/ProfLycee-exemples-pyluatex.tex b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-exemples-pyluatex.tex new file mode 100644 index 00000000000..4831d61a841 --- /dev/null +++ b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-exemples-pyluatex.tex @@ -0,0 +1,263 @@ +% !TeX document-id = {fc3853a9-0c9c-4d02-b763-6dc6c85d34db} +% !TeX TXS-program:compile = txs:///lualatex/[--shell-escape] + +\documentclass[french,a4paper,10pt]{article} +\def\PLver{2.5.7} +\usepackage[margin=1.5cm]{geometry} +\usepackage{ProfLycee} +\useproflyclib{piton} +\usepackage[executable=python.exe]{pyluatex} +\usepackage{babel} +\sisetup{locale=FR,output-decimal-marker={,},group-minimum-digits=4} +\usepackage{codehigh} +%\usepackage[most]{tcolorbox} +%\newtcblisting{ShowCodeTeX}[1][]{colback=white,colframe=red!75!black,listing options={style=tcblatex},#1} + +\begin{document} + +\part*{ProfLycee (\PLver), Piton et Pyluatex} + +\section{Code \og Piton \fg{}, indépendant de Pyluatex} + +\subsection{Préambule basique} + +{\small \begin{codehigh} +\documentclass[french,a4paper,10pt]{article} +\usepackage{ProfLycee} +\useproflyclib{piton} % lua +\end{codehigh}} + +\subsection{Exemples} + +{\small \begin{codehigh} +%Sortie par défaut +\begin{CodePiton} +def valeur_absolue(x): + "Renvoie la valeur absolue de x" + #le petit test qui va bien + if x > 0: + return x + else: + return -x +\end{CodePiton} +\end{codehigh}} + +\begin{CodePiton} +def valeur_absolue(x): + "Renvoie la valeur absolue de x" + #le petit test qui va bien + if x > 0: + return x + else: + return -x +\end{CodePiton} + +{\small \begin{codehigh} +%Sortie avec Style=Classique, Largeur=10cm +\begin{CodePiton}[Style=Classique,Largeur=10cm] +def valeur_absolue(x): + "Renvoie la valeur absolue de x" + #le petit test qui va bien + if x > 0: + return x + else: + return -x +\end{CodePiton} +\end{codehigh}} + +\begin{CodePiton}[Style=Classique,Largeur=10cm] +def valeur_absolue(x): + "Renvoie la valeur absolue de x" + #le petit test qui va bien + if x > 0: + return x + else: + return -x +\end{CodePiton} + +\pagebreak + +{\small \begin{codehigh} +%Sortie avec Style=Classique, Sans Titre, Largeur=10cm, centré +\begin{CodePiton}[Style=Classique,Largeur=10cm,BarreTitre=false,Alignement=center] +def valeur_absolue(x): + "Renvoie la valeur absolue de x" + #le petit test qui va bien + if x > 0: + return x + else: + return -x +\end{CodePiton} +\end{codehigh}} + +\begin{CodePiton}[Style=Classique,Largeur=10cm,BarreTitre=false,Alignement=center] +def valeur_absolue(x): + "Renvoie la valeur absolue de x" + #le petit test qui va bien + if x > 0: + return x + else: + return -x +\end{CodePiton} + +{\small \begin{codehigh} +%Sortie avec Style=Classique, Largeur=0.5\linewidth, aligné à droite, sans Cadre, avec Filigrane +\begin{CodePiton}% + [Style=Classique,Largeur=0.5\linewidth,Cadre=false,Alignement=flush right,Filigrane,Titre={Script}] +def valeur_absolue(x): + "Renvoie la valeur absolue de x" + #le petit test qui va bien + if x > 0: + return x + else: + return -x +\end{CodePiton} +\end{codehigh}} + +\begin{CodePiton}[Style=Classique,Largeur=0.5\linewidth,Cadre=false,Alignement=flush right,Filigrane,Titre={Script}] +def valeur_absolue(x): + "Renvoie la valeur absolue de x" + #le petit test qui va bien + if x > 0: + return x + else: + return -x +\end{CodePiton} + +{\small \begin{codehigh} +%Sortie Moderne, Largeur=11cm, avec Filigrane, aligné à gauche +\begin{CodePiton}[Largeur=11cm,Filigrane,Alignement=flush left] +def valeur_absolue(x): + "Renvoie la valeur absolue de x" + #le petit test qui va bien + if x > 0: + return x + else: + return -x +\end{CodePiton} +\end{codehigh}} + +\begin{CodePiton}[Largeur=11cm,Filigrane,Alignement=flush left] +def valeur_absolue(x): + "Renvoie la valeur absolue de x" + #le petit test qui va bien + if x > 0: + return x + else: + return -x +\end{CodePiton} + +\pagebreak + +\section{Console \og Piton \fg{}, dépendant de Pyluatex} + +\subsection{Préambule, avec le package pyluatex} + +{\small \begin{codehigh} +\documentclass[french,a4paper,10pt]{article} +\usepackage{ProfLycee} +\useproflyclib{piton} +\usepackage[executable=python.exe]{pyluatex} % lua + shell-escape +\end{codehigh}} + +\subsection{Commande} + +{\small \begin{codehigh} +\begin{ConsolePiton}[Options piton]{Options tcbox} +... +... +\end{ConsolePiton} +\end{codehigh}} + +\medskip + +Les clés, à placer entre \texttt{<...>}, sont : + +\begin{itemize} + \item \textbf{\textsf{$\langle$Logo$\rangle$}} pour afficher un petit logo dans les \textit{titres} de la console REPL ; \hfill{}défaut : \textbf{\textsf{$\langle$true$\rangle$}} + \item \textbf{\textsf{$\langle$Largeur$\rangle$}} pour spécifier la largeur de la console REPL ; \hfill{}défaut : \textbf{\textsf{$\langle$\textbackslash{}linewidth$\rangle$}} + \item \textbf{\textsf{$\langle$Alignement$\rangle$}} pour spécifier l'alignement de la console REPL.\hfill{}défaut : \textbf{\textsf{$\langle$flush left$\rangle$}} +\end{itemize} + +\subsection{Exemples} + +{\small \begin{codehigh} +%Déclaration d'une fonction python + librairie random pour utilisation ultérieure +\begin{python} +from random import randint + +def valeur_absolue(x): + "Renvoie la valeur absolue de x" + #le petit test qui va bien + if x > 0: + return x + else: + return -x +\end{python} +\end{codehigh}} + +\begin{python} +from random import randint + +def valeur_absolue(x): + "Renvoie la valeur absolue de x" + #le petit test qui va bien + if x > 0: + return x + else: + return -x +\end{python} + +{\small \begin{codehigh} +\begin{ConsolePiton}{} +1+1 +2**10 +valeur_absolue(-3) +valeur_absolue(0) +valeur_absolue(5) +print(f"La valeur absolue de 5 est {valeur_absolue(5)}") +print(f"La valeur absolue de -4 est {valeur_absolue(-4)}") +\end{ConsolePiton} +\end{codehigh}} + +\begin{ConsolePiton}{} +1+1 +2**10 +valeur_absolue(-3) +valeur_absolue(0) +valeur_absolue(5) +print(f"La valeur absolue de 5 est {valeur_absolue(5)}") +print(f"La valeur absolue de -4 est {valeur_absolue(-4)}") +\end{ConsolePiton} + +\pagebreak + +{\small \begin{codehigh} +\begin{ConsolePiton}{} +1+1 +2**10 +valeur_absolue(-3) +valeur_absolue(0) +valeur_absolue(5) +print(f"La valeur absolue de 5 est {valeur_absolue(5)}") +print(f"La valeur absolue de -4 est {valeur_absolue(-4)}") +liste = [randint(1,20) for i in range(10)] +print(liste) +print(max(liste), min(liste), sum(liste)) +\end{ConsolePiton} +\end{codehigh}} + +\begin{ConsolePiton}{} +1+1 +2**10 +valeur_absolue(-3) +valeur_absolue(0) +valeur_absolue(5) +print(f"La valeur absolue de 5 est {valeur_absolue(5)}") +print(f"La valeur absolue de -4 est {valeur_absolue(-4)}") +liste = [randint(1,20) for i in range(10)] +print(liste) +print(max(liste), min(liste), sum(liste)) +\end{ConsolePiton} + +\end{document} \ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty b/Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty index 7726d26e152..b91ab7816da 100644 --- a/Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty +++ b/Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty @@ -3,7 +3,9 @@ % or later, see http://www.latex-project.org/lppl.txtf \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{ProfLycee}[2023/03/31 2.5.6 Aide pour l'utilisation de LaTeX en lycee] +\ProvidesPackage{ProfLycee}[2023/04/04 2.5.7 Aide pour l'utilisation de LaTeX en lycee] +% 2.5.7 Ajout d'un style classique pour le code python (Piton + ...) + console piton/pyluatex +% Refonte des commandes tcbset pour les codes % 2.5.6 Ajout d'une clé [Trigo] pour \AxexTikz (avec graduations libres) % "Suppression" de la fenêtre XCas de la documentation % 2.5.5 Correction d'un bug avec la fenetre XCas @@ -398,24 +400,24 @@ %%------PYTHONLISTINGS \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 + 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,% + 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,% } } diff --git a/Master/texmf-dist/tex/latex/proflycee/proflycee-tools-minted.tex b/Master/texmf-dist/tex/latex/proflycee/proflycee-tools-minted.tex index 5ba77401bf9..1a305445651 100644 --- a/Master/texmf-dist/tex/latex/proflycee/proflycee-tools-minted.tex +++ b/Master/texmf-dist/tex/latex/proflycee/proflycee-tools-minted.tex @@ -10,16 +10,16 @@ %%------PYTHONMINTED \tcbset{pytmintedno/.style={% - listing engine=minted,minted style=colorful, - minted language=python,listing only, - minted options={tabsize=4,fontsize=\footnotesize,autogobble}, + 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}, + listing engine=minted,minted style=colorful, + minted language=python,listing only, + minted options={tabsize=4,fontsize=\footnotesize,autogobble,xleftmargin=16pt,linenos,numbersep=10pt}, } } diff --git a/Master/texmf-dist/tex/latex/proflycee/proflycee-tools-piton.tex b/Master/texmf-dist/tex/latex/proflycee/proflycee-tools-piton.tex index 2bb7dadcc83..7503f17894d 100644 --- a/Master/texmf-dist/tex/latex/proflycee/proflycee-tools-piton.tex +++ b/Master/texmf-dist/tex/latex/proflycee/proflycee-tools-piton.tex @@ -10,11 +10,15 @@ \RequirePackage{iftex} -%%------PYTHONPITON +%%=============PYTHONPITON + +%==Clés globales \defKV[envpiton]{% Largeur=\def\CODPITlargeur{#1},% Alignement=\def\CODPITalign{#1},% - TaillePolice=\def\CODPITfonte{#1} + TaillePolice=\def\CODPITfonte{#1},% + Style=\def\CODPITstyle{#1},% + Titre=\def\CODPITtitre{#1} } \setKVdefault[envpiton]{% @@ -22,14 +26,20 @@ Alignement=center,% Lignes=true,% Gobble=true,% - TaillePolice=\footnotesize + TaillePolice=\footnotesize,% + Filigrane=false,% + Style=Moderne,% + Cadre=true,% + BarreTitre=true,% + Titre={{\scriptsize\faCode} Code Python} } +%==Style Moderne \tcbset{stylepiton/.style={% enhanced,boxrule=1.25pt,% sharp corners=downhill,arc=12pt, - before skip=12pt,after skip=12pt,% - top=10pt,bottom=1mm,rightupper=4pt,%leftupper=25pt, + before skip=\baselineskip,after skip=\baselineskip,% + top=\baselineskip,bottom=0mm,left=0.6em,right=5mm,% attach boxed title to top right={yshift=-\tcboxedtitleheight}, boxed title style={ size=small,colback=ForestGreen!25,boxrule=1.25pt, @@ -37,31 +47,149 @@ 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 + title={{\scriptsize\faPython}\:Code Python} + } +} + +%==Style Classique +\tcbset{thonnystyle/.style={% + enhanced,boxrule=0.75pt,colframe=DarkGray!25!Black,% + sharp corners,top=0mm,bottom=0mm,left=0.4em,right=5mm,% + before skip=\baselineskip,after skip=\baselineskip,% + colback=white + } +} + +\tcbset{thonnystylelineos/.style={% + thonnystyle,% + underlay={% + \begin{tcbclipinterior} + \filldraw[lightgray!15] (interior.south west) rectangle ([xshift=1.3em]interior.north west) ; + \end{tcbclipinterior}% + } } } +%==Création de la boîte \ifluatex \RequirePackage{piton} \NewPitonEnvironment{CodePiton}{ O{} }% {% + \tcbset{reset} \useKVdefault[envpiton]% \setKV[envpiton]{#1}% on paramètres les nouvelles clés et on les simplifie + %------les styles piton \ifboolKV[envpiton]{Lignes}%si lignes=true - {\PitonOptions{left-margin=auto,all-line-numbers}}% + {\PitonOptions{left-margin=0.75em,all-line-numbers}}%left-margin=auto, {}% \ifboolKV[envpiton]{Gobble}%si gobble=true {\PitonOptions{tabs-auto-gobble}}% {}% - \PitonOptions{break-lines,indent-broken-lines}% - \begin{tcolorbox}[stylepiton,leftupper=8pt,colframe=Green,colback=ForestGreen!5,width=\CODPITlargeur,fontupper=\CODPITfonte,fontlower=\CODPITfonte,\CODPITalign] + \PitonOptions{break-lines,indent-broken-lines}%,numbers-sep=0.65em} + %------les styles tcbox + \IfEq{\CODPITstyle}{Moderne}%style Moderne (défaut) + {% + \tcbset{stylepiton,colframe=Green,colback=ForestGreen!5,width=\CODPITlargeur,fontupper=\CODPITfonte,fontlower=\CODPITfonte,\CODPITalign} + \ifboolKV[envpiton]{Filigrane}%si filigrane + {\tcbset{watermark text={\faPython},watermark opacity=0.175,watermark zoom=0.50}}% + {}% + } + {}% + \IfEq{\CODPITstyle}{Classique}%style Classique + {% + \ifboolKV[envpiton]{Lignes}%si lignes=true + {\tcbset{thonnystylelineos,leftupper=0.4em}}% + {\tcbset{thonnystyle,leftupper=0.4em}}% + \tcbset{width=\CODPITlargeur,colframe=darkgray,fontupper=\CODPITfonte,fontlower=\CODPITfonte,\CODPITalign} + \ifboolKV[envpiton]{Filigrane}%si filigrane + {\tcbset{watermark text={\faPython},watermark opacity=0.175,watermark zoom=0.50}}% + {}% + \ifboolKV[envpiton]{BarreTitre}% + {% + \ifboolKV[envpiton]{Cadre} + {} + {\tcbset{boxrule=0pt,frame hidden}} + \tcbset{lefttitle=0.4em,title={\CODPITtitre},fonttitle=\bfseries\footnotesize\sffamily,colbacktitle=DarkGray!25!Black} + }% + {% + \tcbset{notitle} + \ifboolKV[envpiton]{Cadre} + {} + {\tcbset{boxrule=0pt,frame hidden}} + } + } + {}% + %on crée la boîte + \begin{tcolorbox} }% {% \end{tcolorbox}% } \fi + +%======CONSOLE PYLUATEX (package à charger manuellement !!) +\tcbset{consolepylua/.style={%base de la boîte + enhanced,colback=white,colframe=ForestGreen,sharp corners,boxrule=1pt,% + top=1.5mm,bottom=1.5mm,left=2mm,right=2mm,fontupper=\small,% + before skip=\baselineskip,after skip=\baselineskip,% + } +} + +\tcbset{consolepyluatexlogo/.style={%avec logo python + consolepylua,% + overlay={% + \draw ([yshift=0.5pt]frame.south) node[ForestGreen!50!black,fill=white,font=\scriptsize\ttfamily] {\scalebox{0.8}[0.8]{\faPython} Fin de la Console Python \scalebox{0.8}[0.8]{\faPython}} ; + \draw ([yshift=-0.5pt]frame.north) node[ForestGreen!50!black,fill=white,font=\scriptsize\ttfamily] {\scalebox{0.8}[0.8]{\faPython} Début de la Console Python \scalebox{0.8}[0.8]{\faPython}} ; + } + } +} + +\tcbset{consolepyluatex/.style={%sans logo python + consolepylua,% + overlay={% + \draw ([yshift=0.5pt]frame.south) node[ForestGreen!50!black,fill=white,font=\scriptsize\ttfamily] {Fin de la Console Python} ; + \draw ([yshift=-0.5pt]frame.north) node[ForestGreen!50!black,fill=white,font=\scriptsize\ttfamily] {Début de la Console Python} ; + } + } +} + +\defKV[consolepyluatex]{% + Largeur=\def\ConsPyluaLarg{#1},% + Alignement=\def\ConsPyluaAlign{#1} +} +\setKVdefault[consolepyluatex]{% + Logo=true,% + Largeur=\linewidth,% + Alignement=flush left +} + +\NewDocumentEnvironment{ConsolePiton}{ O{} D<>{} m }% +%1=options piton +%2=clés +%3=options tcbox +{ + \restoreKV[consolepyluatex]% revenir au valeurs par défaut + \setKV[consolepyluatex]{#2}% lit les arguments optionnels + \PitonOptions{#1} + \PyLTVerbatimEnv + \ifboolKV[consolepyluatex]{Logo} + {\tcbset{consolepyluatexlogo,width=\ConsPyluaLarg,\ConsPyluaAlign,#3}} + {\tcbset{consolepyluatex,width=\ConsPyluaLarg,\ConsPyluaAlign,#3}} + \begin{tcolorbox} + \begin{pythonrepl} +} +{ + \directlua{ + tex.print("\\begin{Piton}") + tex.print(pyluatex.get_last_output()) + tex.print("\\end{Piton}") + tex.print("") +} + \end{pythonrepl} +\end{tcolorbox} +} + \endinput \ No newline at end of file -- cgit v1.2.3