diff options
author | Karl Berry <karl@freefriends.org> | 2022-08-24 19:35:51 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-08-24 19:35:51 +0000 |
commit | 2f8ba8b7c64228cd5e22bfbe6cfca3155b150af4 (patch) | |
tree | f35b8642b1ee181962b08780977dd3f9ff1bb40d /Master | |
parent | 87e18b2b2bb18c4eb9b9142708a16a7d9f388e34 (diff) |
proflycee (24aug22)
git-svn-id: svn://tug.org/texlive/trunk@64187 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.pdf | bin | 789010 -> 805538 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.tex | 210 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/proflycee/testscript.py | 24 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty | 100 |
4 files changed, 328 insertions, 6 deletions
diff --git a/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.pdf b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.pdf Binary files differindex 9deffa7cd77..8ba659bfe16 100644 --- a/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.pdf +++ b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.pdf diff --git a/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.tex b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.tex index 300a92293f7..ec1fd68cac5 100644 --- a/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.tex +++ b/Master/texmf-dist/doc/latex/proflycee/ProfLycee-doc.tex @@ -38,6 +38,7 @@ \usepackage{listofitems} \usepackage{xintexpr} \usepackage{codehigh} +\usepackage{scontents} \usepackage{hyperref} \urlstyle{same} \hypersetup{pdfborder=0 0 0} @@ -55,8 +56,8 @@ \setlength{\parindent}{0pt} \definecolor{LightGray}{gray}{0.9} -\def\PLversion{1.2.2} -\def\PLdate{15 Août 2022} +\def\PLversion{1.2.3} +\def\PLdate{24 Août 2022} \tcbset{vignettes/.style={% nobeforeafter,box align=base,boxsep=0pt,enhanced,sharp corners=all,rounded corners=southeast,% @@ -906,7 +907,208 @@ Pour \textit{illustrer} un peu les \Cle{clés}, un petit schéma, avec les diffà \newpage -\section{Code \& Console Python} +\section{Code Python \og simple \fg} + +\subsection{Introduction} + +\begin{codeidee} +Le {package} \ctex{listings} permet d'insérer et de formater du code, notamment du code Python. En \textit{partenariat} avec \ctex{tcolorbox}, on peut donc présenter \textit{joliment} du code python ! +\end{codeidee} + +\begin{codeinfo} +Le package \ctex{listings} ne nécessite pas de compilation particulière, au contraire d'autres (comme \ctex{pythontex} ou \ctex{minted}) qui seront présentés à la section suivante. +\end{codeinfo} + +\medskip + +\begin{codeinfo} +Le style utilisé pour formater le code Python n'est pas modifiable. Il donne un rendu proche de celui des packages commes \ctex{pythontex} ou \ctex{minted}. + +\smallskip + +Donc, si plusieurs \textit{méthodes} sont utilisées pour insérer du code Python (via les sections suivantes), le rendu peut être légèrement différent. +\end{codeinfo} + +\subsection{Présentation de code Python grâce à listings} + +\begin{codeidee} +L'environnement \ctex{\textbackslash envcodepython} (chargé par \ctex{ProfLycee} permet de présenter du code python, dans une \ctex{tcolorbox} avec un style particulier. +\end{codeidee} + +\smallskip + +\begin{codetex}[listing only] +\begin{envcodepython}(*)[largeur]{commandes tcbox} +... +\end{envcodepython} +\end{codetex} + +\smallskip + +\begin{codecles} +Plusieurs \Cle{arguments} sont disponibles : + +\begin{itemize} + \item la version \textit{étoilée} qui permet de ne pas afficher les numéros de lignes ; + \item le premier argument (optionnel), concerne la \Cle{largeur} de la \ctex{tcbox} ;\hfill{}défaut \Cle{\textbackslash linewidth} + \item le second argument (mandataire), concerne des \Cle{options} de la \ctex{tcbox} en \textit{langage tcolorbox}, comme l'alignement. +\end{itemize} +\end{codecles} + +\smallskip + +\begin{codeinfo} +Les environnements \ctex{DeclareTCBListing} créés par \ctex{tcolorbox} et \ctex{listings} ne sont pas compatibles avec les options \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{codeinfo} + +\subsection{Insertion via un fichier \og externe \fg} + +\begin{codeidee} +Pour des raison pratiques, il est parfois intéressant d'avoir le code Python dans un fichier externe au ficher \ctex{tex}, ou bien créé directement par le fichier \ctex{tex} (via \ctex{scontents}, notamment, mais non chargé par \ctex{ProfLycee}). + +Dans ce cas, il n'est pas nécessaire d'aligner le code \og à gauche \fg, en utilisant une commande alternative. + +\smallskip + +Si cette méthode est utilisée, il ne faut oublier de charger le package \ctex{scontents}. +\end{codeidee} + +\begin{codetex}[listing only] +\usepackage{scontents} %si script déclaré dans le fichier tex +... +\envcodepythonfichier(*)[largeur]{commandes tcbox}{<script>} +\end{codetex} + +\subsection{Exemples} + +\begin{codetex}[listing only] +\begin{envcodepython}{} %les {}, même vides, sont nécessaires (bug avec # sinon !) +#environnement par défaut +nb = int(input("Saisir un entier Python positif")) +if (nb %7 == 0) : + print(f"{nb} est bien divisible par 7") +#endif + +def f(x) : + return x**2 +\end{envcodepython} +\end{codetex} + +\smallskip + +\begin{codesortie} +\begin{envcodepython}{} +#environnement par défaut +nb = int(input("Saisir un entier Python positif")) +if (nb %7 == 0) : + print(f"{nb} est bien divisible par 7") +#endif + +def f(x) : + return x**2 +\end{envcodepython} +\end{codesortie} + +\smallskip + +\begin{codetex}[listing only] +\begin{envcodepython}*[0.5\linewidth]{flush right} +#largeur de 50%, sans numéro, et aligné à droite +nb = int(input("Saisir un entier Python positif")) +if (nb %7 == 0) : + print(f"{nb} est bien divisible par 7") +#endif + +def f(x) : + return x**2 +\end{envcodepython} +\end{codetex} + +\smallskip + +\begin{codesortie} +\begin{envcodepython}*[0.5\linewidth]{flush right} +#largeur de 50%, sans numéro, et aligné à droite +nb = int(input("Saisir un entier Python positif")) +if (nb %7 == 0) : + print(f"{nb} est bien divisible par 7") +#endif + +def f(x) : + return x**2 +\end{envcodepython} +\end{codesortie} + +\smallskip + +\begin{codetex}[listing only] +\begin{scontents}[overwrite,write-out=testscript.py] +# Calcul de la factorielle en langage Python +def factorielle(x): + if x < 2: + return 1 + else: + return x * factorielle(x-1) + +# rapidité de tracé +import matplotlib.pyplot as plt +import time +def trace_parabole_tableaux(): + depart=time.clock() + X = [] # Initialisation des listes + Y = [] + a = -2 + h = 0.001 + while a<2: + X.append(a) # Ajout des valeurs + Y.append(a*a) # au "bout" de X et Y + a = a+h + # Tracé de l'ensemble du tableau de valeurs + plt.plot(X,Y,".b") + fin=time.clock() + return "Temps : " + str(fin-depart) + " s." +\end{scontents} + +%environnement centré, avec numéros, largeur 9cm +\envcodepythonfichier[9cm]{center}{testscript.py} +\end{codetex} + +\smallskip + +\begin{codesortie} +\begin{scontents}[overwrite,write-out=testscript.py] +# Calcul de la factorielle en langage Python +def factorielle(x): + if x < 2: + return 1 + else: + return x * factorielle(x-1) + +# rapidité de tracé +import matplotlib.pyplot as plt +import time +def trace_parabole_tableaux(): + depart=time.clock() + X = [] # Initialisation des listes + Y = [] + a = -2 + h = 0.001 + while a<2: + X.append(a) # Ajout des valeurs + Y.append(a*a) # au "bout" de X et Y + a = a+h + # Tracé de l'ensemble du tableau de valeurs + plt.plot(X,Y,".b") + fin=time.clock() + return "Temps : " + str(fin-depart) + " s." +\end{scontents} + +\envcodepythonfichier[9cm]{center}{testscript.py} +\end{codesortie} + +\newpage + +\section{Code \& Console Python, version Pythontex ou Minted} \subsection{Introduction} @@ -3747,6 +3949,8 @@ D,-,-,D,-,D,D,F,F,F,F,F,F,D,D,-,-,-,-,D,-,- \section{Historique} +{\small \bverb|v1.2.3|~:~~~~Commandes pour du code python "simple", sans compilation particulière + {\small \bverb|v1.2.2|~:~~~~Commandes pour travailler sur des stats à 2 variables {\small \bverb|v1.2.1|~:~~~~Amélioration de la gestion du csv pour Pixelart diff --git a/Master/texmf-dist/doc/latex/proflycee/testscript.py b/Master/texmf-dist/doc/latex/proflycee/testscript.py new file mode 100644 index 00000000000..76e61647be7 --- /dev/null +++ b/Master/texmf-dist/doc/latex/proflycee/testscript.py @@ -0,0 +1,24 @@ +# Calcul de la factorielle en langage Python +def factorielle(x): + if x < 2: + return 1 + else: + return x * factorielle(x-1) + +# rapidité de tracé +import matplotlib.pyplot as plt +import time +def trace_parabole_tableaux(): + depart=time.clock() + X = [] # Initialisation des listes + Y = [] + a = -2 + h = 0.001 + while a<2: + X.append(a) # Ajout des valeurs + Y.append(a*a) # au "bout" de X et Y + a = a+h + # Tracé de l'ensemble du tableau de valeurs + plt.plot(X,Y,".b") + fin=time.clock() + return "Temps : " + str(fin-depart) + " s." diff --git a/Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty b/Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty index 8da7dca149a..02a08e392f7 100644 --- a/Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty +++ b/Master/texmf-dist/tex/latex/proflycee/ProfLycee.sty @@ -3,7 +3,8 @@ % or later, see http://www.latex-project.org/lppl.txtf \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{ProfLycee}[2022/08/15 - v1.2.2 - Aide pour l'utilisation de LaTeX en lycée] +\ProvidesPackage{ProfLycee}[2022/08/24 v1.2.3 - Aide pour l'utilisation de LaTeX en lycee] +% 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... @@ -54,6 +55,16 @@ \RequirePackage{simplekv} \RequirePackage{listofitems} \RequirePackage{tabularray} +\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} @@ -451,21 +462,103 @@ before upper = \renewcommand{\theFancyVerbLine}{\scriptsize\ttfamily\color{Green}\arabic{FancyVerbLine}} } -%=========PSEUDOCODE=========== OK !! +%=======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 = 4pt, + belowskip = 1pt, + 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 = 4pt, + belowskip = 1pt, + 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{envcodepython}{ s O{\linewidth} m }{% * off pour numéros de lignes + {largeur} + <options tcbox> + \IfBooleanTF{#1}{stylepythonlstnolineos}{stylepythonlstlineos}, + width=#2,#3 +} + +\NewTCBInputListing{\envcodepythonfichier}{ s O{\linewidth} m m }{ + \IfBooleanTF{#1}{stylepythonlstnolineos}{stylepythonlstlineos}, + width=#2,#3, + listing file={#4}} + +%=========PSEUDOCODE=========== OK !! %language pseudocode listings \lstdefinestyle{pseudocodePL}{% language=langnat, @@ -693,7 +786,8 @@ } %============CartoucheCapytale========= OK !! -\definecolor{vertcapyt}{HTML}{008000} +\definecolor{vertcapyt}{rgb}{0.0,0.5,0.0} +%\definecolor{vertcapyt}{HTML}{008000} \DeclareTotalTCBox{\liencapytale}{ 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}} |