texlive[64794] Master/texmf-dist: piton (23oct22)

commits+karl at tug.org commits+karl at tug.org
Sun Oct 23 22:38:58 CEST 2022


Revision: 64794
          http://tug.org/svn/texlive?view=revision&revision=64794
Author:   karl
Date:     2022-10-23 22:38:58 +0200 (Sun, 23 Oct 2022)
Log Message:
-----------
piton (23oct22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.pdf
    trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex
    trunk/Master/texmf-dist/doc/lualatex/piton/piton.pdf
    trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx
    trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty

Modified: trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex	2022-10-23 20:38:45 UTC (rev 64793)
+++ trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex	2022-10-23 20:38:58 UTC (rev 64794)
@@ -1,9 +1,12 @@
 % -*- coding: utf-8 ; -*-
 \documentclass[dvipsnames]{article}
+
+\usepackage{fontspec}
+
 \usepackage[french]{babel}
 \frenchsetup{og = « , fg = »}
 
-\usepackage[escape-inside=$$]{piton}
+\usepackage[footnotehyper,escape-inside=$$]{piton}
 
 \usepackage{xcolor}
 
@@ -17,7 +20,6 @@
 \usepackage{booktabs}
 
 \usepackage{caption}
-\captionsetup{labelfont = bf}
 
 % We use \MakeShortVerb of shortvrb and not \DefineShortVerb of fancyvrb
 % because we don't want the contents of short verbatim colored in gray
@@ -24,6 +26,7 @@
 \usepackage{shortvrb}
 \MakeShortVerb{\|}
 
+\usepackage{varwidth}
 
 \skip\footins = 2\bigskipamount
 
@@ -39,8 +42,6 @@
 \def\interitem{\vspace{7mm plus 2 mm minus 3mm}}          
 
 
-\usepackage{footnote}
-
 \usepackage[hyperfootnotes = false]{hyperref}
 
 \hypersetup
@@ -80,7 +81,7 @@
 
 \section{Présentation}
 
-L'extension \pkg{piton} utilise la librarie Lua nommée LPEG\footnote{LPEG est une librairie de capture de motifs
+L'extension \pkg{piton} utilise la librairie Lua nommée LPEG\footnote{LPEG est une librairie de capture de motifs
   (\emph{pattern-matching} en anglais) pour Lua, écrite en C, fondée sur les PEG (\emph{parsing expression
     grammars}): \url{http://www.inf.puc-rio.br/~roberto/lpeg/}} pour «parser» le code Python et le composer avec un
 coloriage syntaxique. Comme elle utilise du code Lua, elle fonctionne uniquement avec |lualatex| (et ne va pas
@@ -96,21 +97,20 @@
 from math import pi
 
 def arctan(x,n=10):
-    """Compute the value of arctan(x)
-       n is the number of terms if the sum"""
+    '''Compute the value of arctan(x)
+       n is the number of terms if the sum'''
     if x < 0:
-         return -arctan(-x) # recursive call
+        return -arctan(-x) # appel récursif
     elif x > 1: 
-         return pi/2 - arctan(1/x) 
-         ## (on a utilisé le fait que $\arctan(x)+\arctan(1/x)=\frac{\pi}{2}$ pour $x>0$)\footnote{Cet échappement vers LaTeX a été obtenu en débutant par \ttfamily\#\#.}
-    else 
-         s = 0
-         for k in range(n):
-              s += (-1)**k/(2*k+1)*x**(2*k+1)
-         return s 
+        return pi/2 - arctan(1/x) 
+        ## (on a utilisé le fait que $\arctan(x)+\arctan(1/x)=\pi/2$ pour $x>0$)\footnote{Cet échappement vers LaTeX a été obtenu en débutant par \ttfamily\#\#.} 
+    else: 
+        s = 0
+        for k in range(n):
+            s += (-1)**k/(2*k+1)*x**(2*k+1)
+        return s 
 \end{Piton}
 
-
 \bigskip
 
 L'extension LaTeX \pkg{piton} est entièrement contenue dans le fichier |piton.sty|. Ce
@@ -120,9 +120,18 @@
 
 \section{Utilisation de l'extension}
 
-Pour utiliser l'extension \pkg{piton}, l'utilisateur final a seulement à charger l'extension dans son document avec
-la commande classique |\usepackage| et se souvenir que la compilation doit être faite avec LuaLaTeX. 
+L'extension \pkg{piton} se charge simplement avec la commande |\usepackage| : |\usepackage{piton}|.
 
+On a néanmoins deux remarques à formuler :
+\begin{itemize}
+\item l'extension \pkg{piton} utilise l'extension \pkg{xcolor} (néanmoins \pkg{piton} charge pas \pkg{xcolor} : si
+\pkg{xcolor} n'est pas chargée avant le |\begin{document}|, une erreur fatale sera levée) ;
+
+\item l'extension \pkg{piton} n'est utilisable qu'avec LuaLaTeX : si un autre moteur de compilation (comme |latex|,
+|pdflatex| ou |xelatex|) est utilisé, une erreur fatale sera levée.
+\end{itemize}
+
+
 \medskip
 L'extension \pkg{piton} fournit trois outils pour composer du code Python: la commande |\piton|, l'environnement
 |{Piton}| et la commande |\PitonInputFile|.
@@ -133,7 +142,9 @@
 \verb|\verb|) et, de ce fait, cette fonction ne peut pas être utilisée à l'intérieur d'un argument d'une autre
 fonction (on peut néanmoins l'utiliser à l'intérieur d'un environnement).
 
-\item L'environnement |{Piton}| doit être utilisé pour composer des codes de plusieurs lignes. 
+\item L'environnement |{Piton}| doit être utilisé pour composer des codes de plusieurs lignes. Pour les besoins de
+personnalisation, il est possible de définir de nouveaux environnements similaires à |{Piton}| en utilisant la
+commande |\NewPitonEnvironment| : cf. partie \ref{NewPitonEnvironment} p.~\pageref{NewPitonEnvironment}. 
 
 \item La commande |\PitonInputFile| doit être utilisée pour insérer et composer un fichier extérieur.
 \end{itemize}
@@ -140,7 +151,8 @@
 
 \bigskip
 Il est possible de composer des commentaires en LaTeX en commençant par |##| (c'est un échappement vers LaTeX). Les
-caractères |##| eux-mêmes ne seront pas imprimés et les espaces qui les suivent sont supprimés.
+caractères |##| eux-mêmes ne seront pas imprimés et les espaces qui les suivent sont supprimés. Ces commentaires
+seront simplement appelés «commentaires LaTeX» dans ce document.
 
 
 \section{Personnalisation}
@@ -148,7 +160,7 @@
 \subsection{La commande \textbackslash PitonOptions}
 
 La commande |\PitonOptions| prend en argument une liste de couples \textsl{clé=valeur}. La portée des réglages
-effectués par cette commande est le groupe TeX courant. 
+effectués par cette commande est le groupe TeX courant.\footnote{On rappelle que tout environnement LaTeX est, en particulier, un groupe.}
 
 \begin{itemize}
 \item La clé |gobble| peut comme valeur un entier positif $n$ : les $n$ premiers caractères de chaque ligne sont
@@ -166,20 +178,23 @@
 
 \item Avec la clé |all-line-numbers|, \emph{toutes} les lignes sont numérotées, y compris les lignes vides.
 
-\item \colorbox{yellow!50}{\textbf{Nouveau 0.7}}\enskip Avec la clé |resume|, le compteur de lignes n'est pas remis à 
-zéro comme il l'est normalement au début d'un environnement |{Piton}| ou bien au début d'un listing produit par 
+\item Avec la clé |resume|, le compteur de lignes n'est pas remis à zéro comme il l'est normalement au début d'un
+environnement |{Piton}| ou bien au début d'un listing produit par |\PitonInputFile|.
+
+\item La clé |splittable| autorise un saut de page dans les environnements |{Piton}| et les listings produits par
 |\PitonInputFile|.
 
-\item \colorbox{yellow!50}{\textbf{Nouveau 0.7}}\enskip La clé |splittable| autorise un saut de page 
-dans les environnements |{Piton}| et les listings produits par |\PitonInputFile|.
+\item La clé |background-color| fixe la couleur de fond des environnements |{Piton}| et des listings produits par
+|\PitonInputFile| (ce fond a une largeur égale à la valeur courante de |\linewidth|). Même avec une couleur de
+fond, les sauts de page sont possibles, à partir du moment où la clé |splittable| est utilisée.\footnote{Un
+  environnement |{Piton}| est sécable même dans un environnement de \pkg{tcolorbox}, à partir du moment où la clé
+  |breakable| de \pkg{tcolorbox} est utilisée. On précise cela parce que, en revanche, un environnement de
+  \pkg{tcolorbox} inclus dans un autre environnement de \pkg{tcolorbox} n'est pas sécable, même quand les deux
+  utilisent la clé |breakable|.}
 
-\item \colorbox{yellow!50}{\textbf{Nouveau 0.7}}\enskip La clé |background-color| fixe la couleur de fond des
-environnements |{Piton}| et des listings produits par |\PitonInputFile| (ce fond a une largeur égale à la valeur
-courante de |\linewidth|). Même avec une couleur de fond, les sauts de page sont possibles, à partir du moment où
-la clé |splittable| est utilisée.\footnote{Un environnement |{Piton}| est sécable même dans un environnement de
-  \pkg{tcolorbox}, à patir du moment où la clé |breakable| de \pkg{tcolorbox} est utilisée. On précise cela parce
-  que, en revanche, un environnement de \pkg{tcolorbox} inclus dans un autre environnement de \pkg{tcolorbox} n'est
-  pas sécable, même quand les deux utilisent la clé |breakable|.}
+\item \colorbox{yellow!50}{\textbf{Nouveau 0.8}}\enskip La clé |left-margin| fixe une marge sur la gauche. Cette
+clé peut être utile, en particulier, en conjonction avec l'une des clés |line-numbers| et |all-line-numbers| si on
+ne souhaite pas que les numéros de ligne soient dans une position en débordement sur la gauche.
 \end{itemize}
 
 \bigskip
@@ -192,18 +207,18 @@
     from math import pi
 
     def arctan(x,n=10):
-        """Compute the value of arctan(x)
-           n is the number of terms if the sum"""
+        '''Compute the value of arctan(x)
+           n is the number of terms if the sum'''
         if x < 0:
-             return -arctan(-x) # recursive call
+            return -arctan(-x) # appel récursif
         elif x > 1: 
-             return pi/2 - arctan(1/x) 
-             ## (on a utilisé le fait que $\arctan(x)+\arctan(1/x)=\frac{\pi}{2}$ pour $x>0$)
-        else 
-             s = 0
-             for k in range(n):
-                  s += (-1)**k/(2*k+1)*x**(2*k+1)
-             return s 
+            return pi/2 - arctan(1/x) 
+            ## (on a utilisé le fait que $\arctan(x)+\arctan(1/x)=\pi/2$ pour $x>0$)
+        else: 
+            s = 0
+            for k in range(n):
+                s += (-1)**k/(2*k+1)*x**(2*k+1)
+            return s 
 \end{Piton}
 \end{Verbatim}
 \endgroup
@@ -214,18 +229,18 @@
     from math import pi
 
     def arctan(x,n=10):
-        """Compute the value of arctan(x)
-           n is the number of terms if the sum"""
+        '''Compute the value of arctan(x)
+           n is the number of terms if the sum'''
         if x < 0:
-             return -arctan(-x) # recursive call
+            return -arctan(-x) # appel récursif
         elif x > 1: 
-             return pi/2 - arctan(1/x) 
-             ## (on a utilisé le fait que $\arctan(x)+\arctan(1/x)=\frac{\pi}{2}$ pour $x>0$)
-        else 
-             s = 0
-             for k in range(n):
-                  s += (-1)**k/(2*k+1)*x**(2*k+1)
-             return s 
+            return pi/2 - arctan(1/x) 
+            ## (on a utilisé le fait que $\arctan(x)+\arctan(1/x)=\pi/2$ pour $x>0$)
+        else: 
+            s = 0
+            for k in range(n):
+                s += (-1)**k/(2*k+1)*x**(2*k+1)
+            return s 
 \end{Piton}
 \endgroup
 
@@ -268,13 +283,16 @@
 \bigskip
 \emph{Attention} : L'échappement vers LaTeX permis par les caractères de |escape-inside| n'est pas actif dans les
 chaînes de caractères ni dans les commentaires (pour avoir un commentaire entièrement en échappement vers LaTeX,
-il suffit de le faire débuter par |##|).
+c'est-à-dire ce qui est 
+appelé dans ce document «commentaire LateX», il suffit de le faire débuter par |##|).
 
 \subsection{Les styles}
 
+\label{styles}
+
 L'extension \pkg{piton} fournit la commande |\SetPitonStyle| pour personnaliser les différents styles utilisés pour
 formater les éléments syntaxiques des listings Python. Ces personnalisations ont une portée qui correspond au
-groupe TeX courant.
+groupe TeX courant.\footnote{On rappelle que tout environnement LaTeX est, en particulier, un groupe.}
 
 \bigskip
 La commande |\SetPitonStyle| prend en argument une liste de couples \textsl{clé=valeur}. Les clés sont les noms des
@@ -281,10 +299,9 @@
 styles et les valeurs sont les instructions LaTeX de formatage correspondantes.
 
 \bigskip
-Ces instructions LaTeX doivent être des instructions de formatage du type de |\color{...}|, |\bseries|,
-|\slshape|, etc. (les commandes de ce type sont parfois qualifiées de \emph{semi-globales}). Il est aussi possible
-de mettre, \emph{à la fin de la liste d'instructions}, une commande LaTeX prenant exactement un
-argument.
+Ces instructions LaTeX doivent être des instructions de formatage du type de |\bfseries|, |\slshape|,
+|\color{...}|, etc. (les commandes de ce type sont parfois qualifiées de \emph{semi-globales}). Il est aussi
+possible de mettre, \emph{à la fin de la liste d'instructions}, une commande LaTeX prenant exactement un argument.
 
 \bigskip
 Voici un exemple qui change le style utilisé pour le nom d'une fonction Python, au moment de sa définition
@@ -296,7 +313,8 @@
 \end{Verbatim}
 
 Dans cet exemple, |\colorbox{yellow!50}| doit être considéré comme le nom d'une fonction LaTeX qui prend exactement
-un argument, puisque, habituellement, elle est utilisée avec la syntaxe |\colorbox{yellow!50}{text}|.
+un argument, puisque, habituellement, elle est utilisée avec la syntaxe 
+|\colorbox{yellow!50}{|\texttt{\slshape text}|}|. 
 
 \medskip
 \begingroup
@@ -306,13 +324,15 @@
 \endgroup
 
 
+\bigskip
+Les différents styles sont décrits dans la table \ref{Semantic}. Les réglages initiaux effectués par \pkg{piton}
+dans |piton.sty| sont inspirés par le style \pkg{manni} de Pygments.\footnote{Voir
+  \url{https://pygments.org/styles/}. À remarquer que, par défaut, Pygments propose pour le style \pkg{manni} un
+  fond coloré dont la couleur est la couleur HTML |#F0F3F3|.}
 
-\medskip
-Les différents styles sont décrits dans la table \ref{Semantic}.
-
 \begin{table}[htb]
 \centering
-\caption{Usage des différents styles}
+\caption{Les styles proposés par \pkg{piton}}
 \label{Semantic}
 \begin{tabularx}{0.9\textwidth}{@{}>{\ttfamily}l>{\raggedright\arraybackslash}X@{}}
 \toprule
@@ -335,8 +355,8 @@
 Name.Class & le nom des classes au moment de leur définition \\
 Exception & le nom des exceptions prédéfinies (eg: SyntaxError) \\
 Comment & les commentaires commençant par \texttt{\#} \\
-Comment.LaTeX & les commentaires commençant par \texttt{\#\#} qui sont composés en LaTeX par \pkg{piton}
-                (\texttt{\#\#} est une séquence d'échappement vers LaTeX) \\
+Comment.LaTeX & les commentaires commençant par \texttt{\#\#} qui sont composés en LaTeX par \pkg{piton} (et
+                appelés simplement «commentaires LaTeX» dans ce document) \\
 Keyword.Constant & |True|, |False| et |None| \\
 Keyword & les mots-clés suivants :
           \ttfamily assert, break, case, continue, del,
@@ -352,9 +372,11 @@
 
 \subsection{Définition de nouveaux environnements}
 
+\label{NewPitonEnvironment}
+
 Comme l'environnement |{Piton}| a besoin d'absorber son contenu d'une manière spéciale (à peu près comme du texte
 verbatim), il n'est pas possible de définir de nouveaux environnements directement au-dessus de l'environnement
-|{Piton}|.
+|{Piton}| avec les commandes classiques |\newenvironment| et |\NewDocumentEnvironment|.
 
 C'est pourquoi \pkg{piton} propose une commande |\NewPitonEnvironment|. Cette commande a la même syntaxe que la
 commande classique |\NewDocumentEnvironment|.
@@ -363,9 +385,16 @@
 Par exemple, avec l'instruction suivante, un nouvel environnement |{Python}| sera défini avec le même comportement
 que l'environnement |{Piton}|:
 
-\verb|\NewPitonEnvironment{Python}{}{}{}|
+{\color{gray}\verb|\NewPitonEnvironment{Python}{}{}{}|}
 
+
 \bigskip
+Si on souhaite un environnement |{Python}| qui prenne en argument optionnel entre crochets les clés de
+|\PitonOptions|, on peut écrire :
+
+{\color{gray}\verb|\NewPitonEnvironment{Python}{O{}}{\PitonOptions{#1}}{}|}
+
+\bigskip
 Si on souhaite un environnement |{Python}| qui compose le code inclus dans une boîte de \pkg{tcolorbox}, on peut
 écrire:
 
@@ -376,4 +405,382 @@
 \end{verbatim}
 
 
+\section{Fonctionnalités avancées}
+
+\bigskip
+\subsection{Notes de pied de page dans les environnements de piton}
+
+\label{footnote}
+
+Si vous voulez mettre des notes de pied de page dans un environnement de \pkg{piton} (ou bien dans un listing
+produit par |\PitonInputFile|, bien que cela paraisse moins pertinent dans ce cas-là) vous pouvez utiliser une
+paire |\footnotemark|--|\footnotetext|. 
+
+\smallskip
+Il est aussi possible d'extraire les notes de pieds de page avec l'extension \pkg{footnote} ou bien l'extension
+\pkg{footnotehyper}.
+
+\smallskip
+Si \pkg{piton} est chargée avec l'option |footnote| (avec |\usepackage[footnote]{piton}|) l'extension
+\pkg{footnote} est chargée (si elle ne l'est pas déjà) et elle est utilisée pour extraire les notes de pied de
+page.
+
+\smallskip
+Si \pkg{piton} est chargée avec l'option |footnotehyper|, l'extension \pkg{footnotehyper} est chargée (si
+elle ne l'est pas déjà) et elle est utilisée pour extraire les notes de pied de page.
+
+\smallskip
+Attention : Les extensions \pkg{footnote} et \pkg{footnotehyper} sont incompatibles.
+L'extension \pkg{footnotehyper} est le successeur de l'extension \pkg{footnote}
+et devrait être utilisée préférentiellement. L'extension \pkg{footnote} a quelques défauts ;
+en particulier, elle doit être chargée après l'extension \pkg{xcolor} et elle n'est pas parfaitement
+compatible avec \pkg{hyperref}.
+
+\medskip
+Dans ce document, l'extension \pkg{piton} a été chargée avec l'option |footnotehyper| et c'est pourquoi des notes
+peuvent être mises dans les environnements |{Piton}|: cf. première page de ce document.
+
+
+
+\section{Exemples}
+
+\PitonOptions{splittable}
+
+
+\subsection{Numérotation des lignes}
+
+Par défaut, les numéros de ligne sont composés par \pkg{piton} en débordement à gauche (en utilisant en interne la commande |\llap| de LaTeX).
+
+Si on ne veut pas de débordement, il faut réserver une place à gauche pour les numéros de lignes avec la clé |left-margin|.
+
+
+\begingroup
+\fvset{commandchars=\~\&\@,formatcom=\small\color{gray}}
+\begin{Verbatim}
+~emphase&\PitonOptions{background-color=gray!10, left-margin = 5mm, line-numbers}@
+\begin{Piton}
+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{Piton}
+\end{Verbatim}
+\endgroup
+
+
+
+\begingroup
+\PitonOptions{background-color=gray!10,left-margin = 5mm, line-numbers}
+\begin{Piton}
+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{Piton}
+\endgroup
+
+
+
+
+\subsection{Formatage des commentaires LaTeX}
+
+
+On peut modifier le style |Comment.LaTeX| (avec |\SetPitonStyle|) pour faire afficher les commentaires 
+LaTeX (qui débutent par |##|) en butée à droite.
+
+\begingroup
+\fvset{commandchars=\~\&\@,formatcom=\small\color{gray}}
+\begin{Verbatim}
+\PitonOptions{background-color=gray!10}
+~emphase&\SetPitonStyle{Comment.LaTeX = \hfill \normalfont\color{gray}}@
+\begin{Piton}
+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{Piton}
+\end{Verbatim}
+\endgroup
+
+\begingroup
+\PitonOptions{background-color=gray!10}
+\SetPitonStyle{Comment.LaTeX = \hfill \normalfont\color{gray}}
+\begin{Piton}
+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{Piton}
+\endgroup
+
+
+\vspace{1cm}
+On peut aussi faire afficher les commentaires dans une deuxième colonne à droite si on limite la largeur du code
+proprement dit avec un environnement |{minipage}| de LaTeX.
+
+
+\begingroup
+\fvset{commandchars=\~\&\@,formatcom=\small\color{gray}}
+\begin{Verbatim}
+\PitonOptions{background-color=gray!10}
+~emphase&\NewDocumentCommand{\MyLaTeXCommand}{m}{\hfill \normalfont\itshape\rlap{\quad #1}}@
+~emphase&\SetPitonStyle{Comment.LaTeX = \MyLaTeXCommand}@
+~emphase&\begin{minipage}{12cm}@
+\begin{Piton}
+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: 
+        s = 0
+        for k in range(n):
+             s += (-1)**k/(2*k+1)*x**(2*k+1)
+        return s 
+\end{Piton}
+~emphase&\end{minipage}@
+\end{Verbatim}
+\endgroup
+
+
+
+\begingroup
+\PitonOptions{background-color=gray!10}
+\NewDocumentCommand{\MyLaTeXCommand}{m}{\hfill \normalfont\itshape\rlap{\quad #1}}
+\SetPitonStyle{Comment.LaTeX = \MyLaTeXCommand}
+\begin{minipage}{12cm}
+\begin{Piton}
+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: 
+        s = 0
+        for k in range(n):
+             s += (-1)**k/(2*k+1)*x**(2*k+1)
+        return s 
+\end{Piton}
+\end{minipage}
+\endgroup
+
+
+
+\subsection{Notes dans les listings}
+
+Pour pouvoir extraire les notes (introduites par |\footnote|), l'extension |piton| doit être chargée, soit avec la
+clé |footnote|, soit avec la clé |footnotehyper|, comme expliqué à la section \ref{footnote} p.~\pageref{footnote}.
+Dans le présent document, l'extension \pkg{piton} a été chargée par la clé |footnotehyper|.
+
+Bien entendu, une commande |\footnote| ne peut apparaître que dans un commentaire LaTeX (qui débute par |##|). Un
+tel commentaire peut se limiter à cette unique commande |\footnote|, comme dans l'exemple suivant.
+
+\begingroup
+\fvset{commandchars=\~\&\@,formatcom=\small\color{gray}}
+\begin{Verbatim}
+\PitonOptions{background-color=gray!10}
+\begin{Piton}
+def arctan(x,n=10):
+    if x < 0:
+        return -arctan(-x)~emphase&##\footnote{Un premier appel récursif.}]@
+    elif x > 1: 
+        return pi/2 - arctan(1/x)~emphase&##\footnote{Un deuxième appel récursif.}@
+    else: 
+        return sum( (-1)**k/(2*k+1)*x**(2*k+1) for k in range(n) ) 
+\end{Piton}
+\end{Verbatim}
+\endgroup
+
+\begingroup
+\PitonOptions{background-color=gray!10}
+\begin{Piton}
+def arctan(x,n=10):
+    if x < 0:
+        return -arctan(-x)##\footnote{Un premier appel récursif.}
+    elif x > 1: 
+        return pi/2 - arctan(1/x)##\footnote{Un deuxième appel récursif.}
+    else: 
+        return sum( (-1)**k/(2*k+1)*x**(2*k+1) for k in range(n) ) 
+\end{Piton}
+\endgroup
+
+
+\vspace{1cm}
+
+Si on utilise l'environnement |{Piton}| dans un environnement |{minipage}| de LaTeX, les notes sont, bien entendu,
+composées au bas de l'environnement |{minipage}|. Rappelons qu'une telle |{minipage}| ne peut être coupée par un
+saut de page. 
+
+
+\begingroup
+\fvset{commandchars=\~\&\@,formatcom=\small\color{gray}}
+\begin{Verbatim}
+\PitonOptions{background-color=gray!10}
+\emphase\begin{minipage}{\linewidth}
+\begin{Piton}
+def arctan(x,n=10):
+    if x < 0:
+        return -arctan(-x)~emphase&##\footnote{Un premier appel récursif.}@
+    elif x > 1: 
+        return pi/2 - arctan(1/x)~emphase&##\footnote{Un deuxième appel récursif.}@
+    else: 
+        return sum( (-1)**k/(2*k+1)*x**(2*k+1) for k in range(n) ) 
+\end{Piton}
+\end{minipage}
+\end{Verbatim}
+\endgroup
+
+\begingroup
+\PitonOptions{background-color=gray!10}
+\begin{minipage}{\linewidth}
+\begin{Piton}
+def arctan(x,n=10):
+    if x < 0:
+        return -arctan(-x)##\footnote{Un premier appel récursif.}
+    elif x > 1: 
+        return pi/2 - arctan(1/x)##\footnote{Un deuxième appel récursif.}
+    else: 
+        return sum( (-1)**k/(2*k+1)*x**(2*k+1) for k in range(n) ) 
+\end{Piton}
+\end{minipage}
+\endgroup
+
+
+\vspace{1cm}
+Si on encapsule l'environnement |{Piton}| dans un environnement |{minipage}| pour, typiquement, limiter la largeur
+d'un fond coloré, il faut encadrer l'ensemble dans un environnement |{savenotes}| (de \pkg{footnote} ou
+\pkg{footnotehyper}) si on veut avoir les notes reportées en pied de page.
+
+\begingroup
+\fvset{commandchars=\~\&\@,formatcom=\small\color{gray}}
+\begin{Verbatim}
+\PitonOptions{background-color=gray!10}
+~emphase&\begin{savenotes}@
+\begin{minipage}{13cm}
+\begin{Piton}
+def arctan(x,n=10):
+    if x < 0:
+        return -arctan(-x)~emphase&##\footnote{Un premier appel récursif.}@
+    elif x > 1: 
+        return pi/2 - arctan(1/x)~emphase&##\footnote{Un deuxième appel récursif.}@
+    else: 
+        return sum( (-1)**k/(2*k+1)*x**(2*k+1) for k in range(n) ) 
+\end{Piton}
+\end{minipage}
+~emphase&\end{savenotes}@
+\end{Verbatim}
+\endgroup
+
+
+
+\begin{savenotes}
+\PitonOptions{background-color=gray!10}
+\begin{minipage}{13cm}
+\begin{Piton}
+def arctan(x,n=10):
+    if x < 0:
+        return -arctan(-x)##\footnote{Un premier appel récursif.}
+    elif x > 1: 
+        return pi/2 - arctan(1/x)##\footnote{Un deuxième appel récursif.}
+    else: 
+        return sum( (-1)**k/(2*k+1)*x**(2*k+1) for k in range(n) ) 
+\end{Piton}
+\end{minipage}
+\end{savenotes}
+
+\subsection{Un exemple de réglage des styles}
+
+Les styles graphiques ont été présentés à la partie \ref{styles}, p.~\pageref{styles}.
+
+\smallskip
+On présente ici un réglage de ces styles adapté pour les documents en noir et blanc. On l'utilise avec la fonte
+\emph{DejaVu Sans Mono}\footnote{Voir: \url{https://dejavu-fonts.github.io}} spécifiée avec la commande
+  |\setmonofont| de \pkg{fontspec}.
+
+
+\begin{Verbatim}
+\setmonofont[Scale=0.85]{DejaVu Sans Mono}
+
+\SetPitonStyle
+  {
+    Number = ,
+    String = \itshape , 
+    String.Doc = \color{gray} \itshape ,
+    Operator = , 
+    Operator.Word = \bfseries ,
+    Name.Builtin = ,
+    Name.Function = \bfseries \colorbox{gray!20} ,
+    Comment = \color{gray} ,
+    Comment.LaTeX = \color{gray},
+    Keyword = \bfseries ,
+    Name.Namespace = ,
+    Name.Class = , 
+    Name.Type = ,
+    InitialValues = \color{gray}
+  }
+\end{Verbatim}
+
+
+
+\setmonofont[Scale=0.85]{DejaVu Sans Mono}
+
+\SetPitonStyle
+  {
+    Number = ,
+    String = \itshape , 
+    String.Doc = \color{gray} \itshape ,
+    Operator = , 
+    Operator.Word = \bfseries ,
+    Name.Builtin = ,
+    Name.Function = \bfseries \colorbox{gray!20} ,
+    Comment = \color{gray} ,
+    Comment.LaTeX = \color{gray},
+    Keyword = \bfseries ,
+    Name.Namespace = ,
+    Name.Class = , 
+    Name.Type = ,
+    InitialValues = \color{gray}
+  }
+
+
+\bigskip
+
+\begin{Piton}
+from math import pi
+
+def arctan(x,n=10):
+    '''Compute the value of arctan(x)
+       n is the number of terms if the sum'''
+    if x < 0:
+        return -arctan(-x) # appel récursif
+    elif x > 1: 
+        return pi/2 - arctan(1/x) 
+        ## (on a utilisé le fait que $\arctan(x)+\arctan(1/x)=\pi/2$ pour $x>0$)
+    else: 
+        s = 0
+        for k in range(n):
+            s += (-1)**k/(2*k+1)*x**(2*k+1)
+        return s 
+\end{Piton}
+
+
+
+\section*{Autre documentation}
+
+Le document |piton.pdf| (fourni avec l'extension \pkg{piton}) contient une traduction anglaise de la
+documentation ici présente, ainsi que le code source commenté et un historique des versions. 
+
+
 \end{document}
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/lualatex/piton/piton.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx
===================================================================
--- trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx	2022-10-23 20:38:45 UTC (rev 64793)
+++ trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx	2022-10-23 20:38:58 UTC (rev 64794)
@@ -1,5 +1,4 @@
-% \iffalse -*- coding: utf-8 ; -*- \fi
-% \iffalse meta-comment
+% \iffalse -*- coding: utf-8 ; -*- \fi \iffalse meta-comment
 %
 % Copyright (C) 2022 by F. Pantigny
 % -----------------------------------
@@ -16,8 +15,8 @@
 %
 % \fi
 % \iffalse
-\def\myfileversion{0.7}
-\def\myfiledate{2022/10/08}
+\def\myfileversion{0.8}
+\def\myfiledate{2022/10/23}
 %
 %
 %<*batchfile> 
@@ -57,39 +56,14 @@
 \fvset{commandchars=\~\#\@,formatcom=\color{gray}}
 \captionsetup{labelfont = bf}
 \usepackage{ragged2e}
-\usepackage[escape-inside=$$]{piton} % $$
+\usepackage[footnotehyper,escape-inside=$$]{piton} % $$
 
 \def\interitem{\vskip 7mm plus 2 mm minus 3mm}          
 \parindent 0pt
 \skip\footins = 2\bigskipamount
 
-\begin{filecontents}[noheader,overwrite]{example1.txt}
-from math import pi
+\PitonOptions{gobble=2}
 
-def arctan(x,n=10):
-    """Compute the value of arctan(x)
-       n is the number of terms if the sum"""
-    if x < 0:
-         return -arctan(-x) # recursive call
-    elif x > 1: 
-         return pi/2 - arctan(1/x) 
-         ## (we have used that $\arctan(x)+\arctan(1/x)=\frac{\pi}{2}$ for $x>0$)\footnote{This LaTeX escape has been done by beginning the comment by \ttfamily\#\#.}
-    else 
-         s = 0
-         for k in range(n):
-              s += (-1)**k/(2*k+1)*x**(2*k+1)
-         return s 
-\end{filecontents}
-
-\begin{filecontents}[noheader,overwrite]{example2.txt}
-def fact(n):
-    if n==0:
-        return 1
-    else:
-        $\colorbox{yellow!50}{$return n*fact(n-1)$}$
-\end{filecontents}
-
-
 \EnableCrossrefs
 
 \begin{document}
@@ -126,9 +100,26 @@
 % Here is an exemple of code typeset by \pkg{piton}, with the environment |{Piton}|.
 %
 % \bigskip
-% \PitonInputFile{Example1.txt}
 %
+%    \begin{Piton}
+% from math import pi
 %
+% def arctan(x,n=10):
+%     '''Compute the value of arctan(x)
+%        n is the number of terms of the sum'''
+%     if x < 0:
+%         return -arctan(-x) # recursive call
+%     elif x > 1: 
+%         return pi/2 - arctan(1/x) 
+%         ## (we have used that $\arctan(x)+\arctan(1/x)=\frac{\pi}{2}$ for $x>0$)\footnote{This LaTeX escape has been done by beginning the comment by \ttfamily\#\#.}
+%     else: 
+%         s = 0
+%         for k in range(n):
+%             s += (-1)**k/(2*k+1)*x**(2*k+1)
+%         return s 
+%    \end{Piton}
+% 
+%
 % \bigskip
 % 
 % The package \pkg{piton} is entirely contained in the file
@@ -139,10 +130,20 @@
 % 
 % \section{Use of the package}
 %
-% In order to use the package \pkg{piton}, one has only to load the package in
-% its document with the standard command |\usepackage| and remember that the
-% compilation must be done with |lualatex| (and no other LaTeX engine).
+% The package \pkg{piton} should be loaded with the classical command
+% |\usepackage|: |\usepackage{piton}|.
 %
+% \smallskip
+% Nevertheless, we have two remarks:
+% \begin{itemize}
+% \item the package \pkg{piton} uses the package \pkg{xcolor} (but \pkg{piton}
+% does \emph{not} load \pkg{xcolor}: if \pkg{xcolor} is not loaded before the
+% |\begin{document}|, a fatal error will be raised).
+% \item the package \pkg{piton} must be used with LuaLaTeX exclusively: if
+% another LaTeX engine (|latex|, |pdflatex|, |xelatex|,\dots ) is used, a
+% fatal error will be raised.
+% \end{itemize}
+% 
 % \medskip
 % The package \pkg{piton} provides three tools to typeset Python code: the
 % command |\piton|, the environment |{Piton}| and the command |\PitonInputFile|.
@@ -153,15 +154,18 @@
 % \emph{verbatim}. Therefore, it cannot be used in the argument of another
 % command (however, it can be used within an environment).
 % \item The environment |{Piton}| should be used to typeset multi-lines code.
-% 
+% For sake of customization, it's possible to define new environments similar to
+% the environment |{Piton}| with the command |\NewPitonEnvironment|:
+% cf.~\ref{NewPitonEnvironment} p.~\pageref{NewPitonEnvironment}.
 % \item The command |\PitonInputFile| is used to insert and typeset a whole
-% external file. 
+% external file.
 % \end{itemize}
 %
 % \bigskip
-% It's possible to compose comments in LaTeX by beginning with |##| (it's a
+% It's possible to compose comments in LaTeX by beginning them with |##| (it's a
 % ``LaTeX escape''). The characters |##| themselves won't be printed and the
-% spaces after |##| are removed.
+% spaces after |##| are removed. These comments will be called ``LaTeX
+% comments'' in this document.
 % 
 % \section{Customization}
 %
@@ -169,7 +173,8 @@
 %
 % The command |\PitonOptions| takes in as argument a comma-separated list of
 % \textsl{key=value} pairs. The scope of the settings done by that command is
-% the current TeX group.
+% the current TeX group.\footnote{We remind that an LaTeX environment is, in
+% particular, a TeX group.}
 %
 % \begin{itemize}
 % \item The key |gobble| takes in as value a positive integer~$n$: the first $n$
@@ -194,23 +199,27 @@
 % \item With the key |all-line-numbers|, \emph{all} the lines are numbered,
 % including the empty ones.
 %
-% \item \colorbox{yellow!50}{\textbf{New 0.7}}\enskip By default, the counter of
-% lines is set to zero at the beginning of each environment |{Piton}| or use of 
-% |\PitonInputFile|. With the key |resume|, that reinitialisation is not done.
+% \item By default, the counter of lines is set to zero at the beginning of each
+% environment |{Piton}| or use of |\PitonInputFile|. With the key |resume|, that
+% reinitialisation is not done.
 %
-% \item \colorbox{yellow!50}{\textbf{New 0.7}}\enskip The key |splittable| allows
-% pages breaks within the environments |{Piton}| and the listings produced by
+% \item The key |splittable| allows pages breaks within the environments
+% |{Piton}| and the listings produced by 
 % |\PitonInputFile|. 
 %
-% \item \colorbox{yellow!50}{\textbf{New 0.7}}\enskip The key |background-color|
-% sets the background color of the environments |{Piton}| and the listings
-% produced by |\PitonInputFile| (that background has a width of |\linewidth|).
-% Even with a background color, the pages breaks are allowed, as soon as the key
-% |splittable| is in force.\footnote{The environments \texttt{\{Piton\}} are breakable,
-% even whithin a breakable environment of \pkg{tcolorbox}. Remind that an
-% environment of \pkg{tcolorbox} included in another environment of
-% \pkg{tcolorbox} is \emph{not} breakable, even when both environments use the
-% key |breakable| of \pkg{tcolorbox}.}
+% \item The key |background-color| sets the background color of the environments
+% |{Piton}| and the listings produced by |\PitonInputFile| (that background has
+% a width of |\linewidth|). Even with a background color, the pages breaks are
+% allowed, as soon as the key |splittable| is in force.\footnote{The
+% environments \texttt{\{Piton\}} are breakable, even within a breakable
+% environment of \pkg{tcolorbox}. Remind that an environment of \pkg{tcolorbox}
+% included in another environment of \pkg{tcolorbox} is \emph{not} breakable,
+% even when both environments use the key |breakable| of \pkg{tcolorbox}.}
+%
+% \item \colorbox{yellow!50}{\textbf{New 0.8}}\enskip The key |left-margin|
+% corresponds to a margin on the left. That key may be useful in conjonction
+% with the key |line-numbers| or the key |line-all-numbers| if one does not want
+% the numbers in an overlapping position on the left.
 % \end{itemize}
 %
 % \bigskip
@@ -223,26 +232,41 @@
 %     from math import pi
 %
 %     def arctan(x,n=10):
-%         """Compute the value of arctan(x)
-%            n is the number of terms if the sum"""
+%         '''Compute the value of arctan(x)
+%            n is the number of terms of the sum'''
 %         if x < 0:
-%              return -arctan(-x) # recursive call
+%             return -arctan(-x) # recursive call
 %         elif x > 1: 
-%              return pi/2 - arctan(1/x) 
-%              ## (we have used that $\arctan(x)+\arctan(1/x)=\frac{\pi}{2}$ pour $x>0$)
+%             return pi/2 - arctan(1/x) 
+%             ## (we have used that $\arctan(x)+\arctan(1/x)=\frac{\pi}{2}$ pour $x>0$)
 %         else 
-%              s = 0
-%              for k in range(n):
-%                   s += (-1)**k/(2*k+1)*x**(2*k+1)
-%              return s 
+%             s = 0
+%             for k in range(n):
+%                 s += (-1)**k/(2*k+1)*x**(2*k+1)
+%             return s 
 % \end{Piton}
 % \end{Verbatim}
 % \endgroup
 %
+% \begingroup
+% \PitonOptions{line-numbers,background-color = gray!15}
+%    \begin{Piton}
+% from math import pi
 %
-% \begingroup
-% \PitonOptions{line-numbers,auto-gobble,background-color = gray!15}
-% \PitonInputFile{Example1.txt}
+% def arctan(x,n=10):
+%     '''Compute the value of arctan(x)
+%        n is the number of terms of the sum'''
+%     if x < 0:
+%         return -arctan(-x) # recursive call
+%     elif x > 1: 
+%         return pi/2 - arctan(1/x) 
+%         ## (we have used that $\arctan(x)+\arctan(1/x)=\frac{\pi}{2}$ for $x>0$)
+%     else 
+%         s = 0
+%         for k in range(n):
+%             s += (-1)**k/(2*k+1)*x**(2*k+1)
+%         return s 
+%    \end{Piton}
 % \endgroup
 % 
 % \subsection{The key escape-inside}
@@ -251,7 +275,7 @@
 % (that is to say in the instruction |\usepackage|). For technical reasons, it
 % can't be used in the command |\PitonOptions|. That option takes in as value
 % two characters which will be used to delimit pieces of code which will
-% thrown directly to LaTeX (and composed by LaTeX).e
+% thrown directly to LaTeX (and composed by LaTeX).
 %
 % \medskip
 % In the following example, we assume that the extension \pkg{piton} has been
@@ -275,21 +299,31 @@
 % \end{Piton}
 % \end{Verbatim}
 %
-% \PitonInputFile{Example2.txt}
-%
+%    \begin{Piton}
+% def fact(n):
+%     if n==0:
+%         return 1
+%     else:
+%         $\colorbox{yellow!50}{$return n*fact(n-1)$}$
+%    \end{Piton}
+%         
 % \bigskip
 %
 % \emph{Caution} : The escape to LaTeX allowed by the characters of
 % |escape-inside| is not active in the strings nor in the Python comments
 % (however, it's possible to have a whole Python comment composed in LaTeX by
-% beginning it with |##|). 
+% beginning it with |##|; such comments are merely called ``LaTeX comments'' in
+% this document). 
 %
 %
 % \subsection{The styles}
 %
+% \label{styles}
+%
 % The package \pkg{piton} provides the command |\SetPitonStyle| to customize the
 % different styles used to format the syntactic elements of the Python listings.
-% The customizations done by that command are limited to the current TeX group.
+% The customizations done by that command are limited to the current TeX
+% group.\footnote{We remind that an LaTeX environment is, in particuilar, a TeX group.}
 %
 % \bigskip
 % The command |\SetPitonStyle| takes in as argument a comma-separated list of
@@ -323,8 +357,12 @@
 % With that setting, we will have : \piton{def cube(x) : return x * x * x }
 % \endgroup
 % 
-% \medskip
-% The different styles are described in the table \ref{Semantic}.
+% \bigskip
+% The different styles are described in the table \ref{Semantic}. The initial
+% settings done by \pkg{piton} in |piton.sty| are inspired by the style
+% \pkg{manni} de Pygments.\footnote{See: \url{https://pygments.org/styles/}.
+% Remark that, by default, Pygments provides for its style \pkg{manni} a colored
+% background whose color is the HTML color \texttt{\#F0F3F3}.}
 %
 %
 %
@@ -355,8 +393,8 @@
 % Name.Class & the name of the classes at the point of their definition \\
 % Exception & the names of the exceptions (eg: \texttt{SyntaxError}) \\
 % Comment & the comments beginning with \verb|#| \\
-% LaTeX & the comments beginning by \verb|##| which are composed in LaTeX by
-% \pkg{piton} (\verb|##| is an espace sequence to LaTeX) \\
+% Comment.LaTeX & the comments beginning by \verb|##| which are composed in LaTeX by
+% \pkg{piton} (and called merely ``LaTeX comments'' in this document) \\
 % Keyword.Constant & |True|, |False| and |None| \\
 % Keyword & the following keywords :
 %           \ttfamily assert, break, case, continue, del,
@@ -373,9 +411,12 @@
 % 
 % \subsection{Creation of new environments}
 %
+% \label{NewPitonEnvironment}
+% 
 % Since the environment |{Piton}| has to catch its body in a special way (more
 % or less as verbatim text), it's not possible to construct new environments
-% directly over the environment |{Piton}|
+% directly over the environment |{Piton}| with the classical commands
+% |\newenvironment| or |\NewDocumentEnvironment|.
 %
 % That's why \pkg{piton} provides a command |\NewPitonEnvironment|. That
 % command takes in three mandatory arguments. 
@@ -387,7 +428,14 @@
 % With the following instruction, a new environment |{Python}| will be
 % constructed with the same behaviour as |{Piton}|:
 %
-% \verb|\NewPitonEnvironment{Python}{}{}{}|
+% {\color{gray}\verb|\NewPitonEnvironment{Python}{}{}{}|}
+%
+% \bigskip
+% If one wishes an environment |{Python}| with takes in as optional argument
+% (between square brackets) the keys of the command |\PitonOptions|, it's
+% possible to program as follows:
+%
+% {\color{gray}\verb|\NewPitonEnvironment{Python}{O{}}{\PitonOptions{#1}}{}|}
 % 
 % \bigskip
 % If one wishes to format Python code in a box of \pkg{tcolorbox}, it's possible
@@ -400,6 +448,397 @@
 % \end{verbatim}
 %
 %
+% \section{Advanced features}
+%
+% \subsection{Footnotes in the environments of piton}
+% 
+% \label{footnote}
+% If you want to put footnotes in an environment |{Piton}| or
+% (or, more unlikely, in a listing produced by |\PitonInputFile|), you can use a
+% pair |\footnotemark|--|\footnotetext|. 
+%
+% \smallskip
+% It's also possible to extract the footnotes with the help of the package
+% \pkg{footnote} or the package \pkg{footnotehyper}.
+%
+% \smallskip
+% If \pkg{piton} is loaded with the option |footnote| (with
+% |\usepackage[footnote]{piton}| or with |\PassOptionsToPackage|), the
+% package \pkg{footnote} is loaded (if it is not yet loaded) and it is used to
+% extract the footnotes.
+%
+% \smallskip
+% If \pkg{piton} is loaded with the option |footnotehyper|, the package
+% \pkg{footnotehyper} is loaded (if it is not yet loaded) ant it is used to
+% extract footnotes.
+%
+% \smallskip
+% Caution: The packages \pkg{footnote} and \pkg{footnotehyper} are incompatible.
+% The package \pkg{footnotehyper} is the successor of the package \pkg{footnote}
+% and should be used preferently. The package \pkg{footnote} has some drawbacks,
+% in particular: it must be loaded after the package \pkg{xcolor} and it is not
+% perfectly compatible with \pkg{hyperref}.
+%
+% \medskip
+% In this document, the package \pkg{piton} has been loaded with the option
+% |footnotehyper|: see the first page of this document for an example of a
+% footnote in an environment |{Piton}|.
+%
+%
+% \section{Examples}
+%
+%
+% \subsection{Line numbering}
+%
+% By default, the numbers of the lines are composed by \pkg{piton} in an
+% overlapping position on the left (by using internally the command |\llap| of LaTeX).
+%
+% In order to avoid that overlapping, it's necessary to reserve a place for the
+% number of the lines with the key |left-margin|.
+%
+%
+%
+% \begingroup
+% \fvset{commandchars=\~\&\@,formatcom=\small\color{gray}}
+% \begin{Verbatim}
+% ~emphase&\PitonOptions{background-color=gray!10, left-margin = 5mm, line-numbers}@
+% \begin{Piton}
+% 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{Piton}
+% \end{Verbatim}
+% \endgroup
+%
+%
+%
+% \begingroup
+% \PitonOptions{background-color=gray!10,left-margin = 5mm, line-numbers}
+% \begin{Piton}
+% 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{Piton}
+% \endgroup
+%
+%
+%
+%
+% \subsection{Formatting of the LaTeX comments}
+%
+% It's possible to modify the style |Comment.LaTeX| (with |\SetPitonStyle|) in
+% order to display the LaTeX comments (which begin with |##|) aligned on the
+% right margin.
+%
+%
+% \begingroup
+% \fvset{commandchars=\~\&\@,formatcom=\small\color{gray}}
+% \begin{Verbatim}
+% \PitonOptions{background-color=gray!10}
+% ~emphase&\SetPitonStyle{Comment.LaTeX = \hfill \normalfont\color{gray}}@
+% \begin{Piton}
+% 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{Piton}
+% \end{Verbatim}
+% \endgroup
+%
+% \begingroup
+% \PitonOptions{background-color=gray!10}
+% \SetPitonStyle{Comment.LaTeX = \hfill \normalfont\color{gray}}
+% \begin{Piton}
+% 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{Piton}
+% \endgroup
+%
+%
+% \vspace{1cm}
+% It's also possible to display these LaTeX comments in a kind of second column
+% by limiting the width of the Python code by an environment |{minipage}| of LaTeX.
+%
+%
+% \begingroup
+% \fvset{commandchars=\~\&\@,formatcom=\small\color{gray}}
+% \begin{Verbatim}
+% \PitonOptions{background-color=gray!10}
+% ~emphase&\NewDocumentCommand{\MyLaTeXCommand}{m}{\hfill \normalfont\itshape\rlap{\quad #1}}@
+% ~emphase&\SetPitonStyle{Comment.LaTeX = \MyLaTeXCommand}@
+% ~emphase&\begin{minipage}{12cm}@
+% \begin{Piton}
+% 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: 
+%         s = 0
+%         for k in range(n):
+%              s += (-1)**k/(2*k+1)*x**(2*k+1)
+%         return s 
+% \end{Piton}
+% ~emphase&\end{minipage}@
+% \end{Verbatim}
+% \endgroup
+%
+%
+%
+% \begingroup
+% \PitonOptions{background-color=gray!10}
+% \NewDocumentCommand{\MyLaTeXCommand}{m}{\hfill \normalfont\itshape\rlap{\quad #1}}
+% \SetPitonStyle{Comment.LaTeX = \MyLaTeXCommand}
+% \begin{minipage}{12cm}
+% \begin{Piton}
+% 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: 
+%         s = 0
+%         for k in range(n):
+%              s += (-1)**k/(2*k+1)*x**(2*k+1)
+%         return s 
+% \end{Piton}
+% \end{minipage}
+% \endgroup
+%
+%
+%
+% \subsection{Notes in the listings}
+%
+% In order to be able to extract the notes (which are typeset with the command
+% |\footnote|, the extension \pkg{piton} must be loaded with the key |footnote|
+% or the key |footenotehyper| as explained in the section \ref{footnote}
+% p.~\pageref{footnote}. In this document, the extension \pkg{piton} has been
+% loaded with the key |footnotehyper|.
+%
+% Of course, in an environment |{Piton}|, a command |\footnote| may appear only
+% within a LaTeX comment (which begins with |##|). It's possible to have comments
+% which contain only that command |\footnote|. That's the case in the following example.
+%
+%
+%
+% \begingroup
+% \fvset{commandchars=\~\&\@,formatcom=\small\color{gray}}
+% \begin{Verbatim}
+% \PitonOptions{background-color=gray!10}
+% \begin{Piton}
+% def arctan(x,n=10):
+%     if x < 0:
+%         return -arctan(-x)~emphase&##\footnote{First recursive call.}]@
+%     elif x > 1: 
+%         return pi/2 - arctan(1/x)~emphase&##\footnote{Second recursive call.}@
+%     else: 
+%         return sum( (-1)**k/(2*k+1)*x**(2*k+1) for k in range(n) ) 
+% \end{Piton}
+% \end{Verbatim}
+% \endgroup
+%
+% \begingroup
+% \PitonOptions{background-color=gray!10}
+% \begin{Piton}
+% def arctan(x,n=10):
+%     if x < 0:
+%         return -arctan(-x)##\footnote{First recursive call.}
+%     elif x > 1: 
+%         return pi/2 - arctan(1/x)##\footnote{Second recursive call.}
+%     else: 
+%         return sum( (-1)**k/(2*k+1)*x**(2*k+1) for k in range(n) ) 
+% \end{Piton}
+% \endgroup
+%
+%
+% \vspace{1cm}
+%
+% If an environment |{Piton}| is used in an environment |{minipage}| of LaTeX,
+% the notes are composed, of course, at the foot of the environment
+% |{minipage}|. Recall that such |{minipage}| can't be broken by a page break.
+
+%
+% \begingroup
+% \fvset{commandchars=\~\&\@,formatcom=\small\color{gray}}
+% \begin{Verbatim}
+% \PitonOptions{background-color=gray!10}
+% \emphase\begin{minipage}{\linewidth}
+% \begin{Piton}
+% def arctan(x,n=10):
+%     if x < 0:
+%         return -arctan(-x)~emphase&##\footnote{First recursive call.}@
+%     elif x > 1: 
+%         return pi/2 - arctan(1/x)~emphase&##\footnote{Second recursive call.}@
+%     else: 
+%         return sum( (-1)**k/(2*k+1)*x**(2*k+1) for k in range(n) ) 
+% \end{Piton}
+% \end{minipage}
+% \end{Verbatim}
+% \endgroup
+%
+% \begingroup
+% \PitonOptions{background-color=gray!10}
+% \begin{minipage}{\linewidth}
+% \begin{Piton}
+% def arctan(x,n=10):
+%     if x < 0:
+%         return -arctan(-x)##\footnote{First recursive call.}
+%     elif x > 1: 
+%         return pi/2 - arctan(1/x)##\footnote{Second recursive call.}
+%     else: 
+%         return sum( (-1)**k/(2*k+1)*x**(2*k+1) for k in range(n) ) 
+% \end{Piton}
+% \end{minipage}
+% \endgroup
+%
+%
+% \vspace{1cm}
+% If one embed an environment |{Piton}| in an environment |{minipage}|
+% (typically in order to limit the width of a colored background), it's
+% necessary to embed the whole environment |{minipage}| in an environment
+% |{savenotes}| (of \pkg{footnote} or \pkg{footnotehyper}) in order to have the
+% footnotes composed at the bottom of the page. 
+%
+% \begingroup
+% \fvset{commandchars=\~\&\@,formatcom=\small\color{gray}}
+% \begin{Verbatim}
+% \PitonOptions{background-color=gray!10}
+% ~emphase&\begin{savenotes}@
+% \begin{minipage}{13cm}
+% \begin{Piton}
+% def arctan(x,n=10):
+%     if x < 0:
+%         return -arctan(-x)~emphase&##\footnote{First recursive call.}@
+%     elif x > 1: 
+%         return pi/2 - arctan(1/x)~emphase&##\footnote{Second recursive call.}@
+%     else: 
+%         return sum( (-1)**k/(2*k+1)*x**(2*k+1) for k in range(n) ) 
+% \end{Piton}
+% \end{minipage}
+% ~emphase&\end{savenotes}@
+% \end{Verbatim}
+% \endgroup
+%
+%
+%
+% \begin{savenotes}
+% \PitonOptions{background-color=gray!10}
+% \begin{minipage}{13cm}
+% \begin{Piton}
+% def arctan(x,n=10):
+%     if x < 0:
+%         return -arctan(-x)##\footnote{First recursive call.}
+%     elif x > 1: 
+%         return pi/2 - arctan(1/x)##\footnote{Second recursive call.}
+%     else: 
+%         return sum( (-1)**k/(2*k+1)*x**(2*k+1) for k in range(n) ) 
+% \end{Piton}
+% \end{minipage}
+% \end{savenotes}
+%
+%
+% \subsection{An example of tuning of the styles}
+%
+% The graphical styles have been presented in the section \ref{styles},
+% p.~\pageref{styles}.
+%
+% \smallskip
+% We present now an example of tuning of these styles adapted to the documents
+% in black and white. We use the font \emph{DejaVu Sans Mono}\footnote{See:
+% \url{https://dejavu-fonts.github.io}} specified by the command |\setmonofont| of 
+% \pkg{fontspec}. 
+%
+%
+% \begin{Verbatim}
+% \setmonofont[Scale=0.85]{DejaVu Sans Mono}
+%
+% \SetPitonStyle
+%   {
+%     Number = ,
+%     String = \itshape , 
+%     String.Doc = \color{gray} \slshape ,
+%     Operator = , 
+%     Operator.Word = \bfseries ,
+%     Name.Builtin = ,
+%     Name.Function = \bfseries \colorbox{gray!20} ,
+%     Comment = \color{gray} ,
+%     Comment.LaTeX = \color{gray},
+%     Keyword = \bfseries ,
+%     Name.Namespace = ,
+%     Name.Class = , 
+%     Name.Type = ,
+%     InitialValues = \color{gray}
+%   }
+% \end{Verbatim}
+%
+%
+% \begingroup
+%
+% \setmonofont[Scale=0.85]{DejaVu Sans Mono}
+%
+% \PitonOptions{splittable}
+%
+% \SetPitonStyle
+%   {
+%     Number = ,
+%     String = \itshape , 
+%     String.Doc = \color{gray} \slshape ,
+%     Operator = , 
+%     Operator.Word = \bfseries ,
+%     Name.Builtin = ,
+%     Name.Function = \bfseries \colorbox{gray!20} ,
+%     Comment = \color{gray} ,
+%     Comment.LaTeX = \color{gray} ,
+%     Keyword = \bfseries ,
+%     Name.Namespace = ,
+%     Name.Class = , 
+%     Name.Type = ,
+%     InitialValues = \color{gray}
+%   }
+%
+%
+% \bigskip
+%
+% \begin{Piton}
+% from math import pi
+%
+% def arctan(x,n=10):
+%     '''Compute the value of arctan(x)
+%        n is the number of terms if the sum'''
+%     if x < 0:
+%         return -arctan(-x) # appel récursif
+%     elif x > 1: 
+%         return pi/2 - arctan(1/x) 
+%         ## (we have used that $\arctan(x)+\arctan(1/x)=\pi/2$ for $x>0$)
+%     else: 
+%         s = 0
+%         for k in range(n):
+%             s += (-1)**k/(2*k+1)*x**(2*k+1)
+%         return s 
+% \end{Piton}
+%
+% \endgroup
+% 
+%
+% \bigskip
+% The previous example has been composed while the key |splittable| (of
+% |\PitonOptions|) is in force. That's why a page break may have occurred.
 % \clearpage
 %
 % \section{Implementation}
@@ -427,10 +866,27 @@
 %    \end{macrocode}
 %
 % \bigskip
+% The boolean |\c_@@_footnotehyper_bool| will indicate if the option
+% |footnotehyper| is used.
+%    \begin{macrocode}
+\bool_new:N \c_@@_footnotehyper_bool
+%    \end{macrocode}
+%
+% \medskip
+% The boolean |\c_@@_footnote_bool| will indicate if the option |footnote| is
+% used, but quicky, it will also be set to |true| if the option |footnotehyper|
+% is used.
+%    \begin{macrocode}
+\bool_new:N \c_@@_footnote_bool
+%    \end{macrocode}
+% 
+% \bigskip
 % We define a set of keys for the options at load-time.
 %    \begin{macrocode}
 \keys_define:nn { piton / package }
   { 
+    footnote .bool_set:N = \c_@@_footnote_bool ,
+    footnotehyper .bool_set:N = \c_@@_footnotehyper_bool ,
     escape-inside .tl_set:N = \c_@@_escape_inside_tl ,
     escape-inside .initial:n = , 
     unknown .code:n = \msg_error:nn { piton } { unknown~key~for~package }
@@ -441,9 +897,9 @@
 \msg_new:nnn { piton } { unknown~key~for~package }
   {
     Unknown~key.\\
-    You~have~used~the~key~'\l_keys_key_str'~but~the~only~key~available~here~
-    is~the~key~'escape-inside'.~Other~keys~are~available~in~\token_to_str:N 
-    \PitonOptions.\\
+    You~have~used~the~key~'\l_keys_key_str'~but~the~only~keys~available~here~
+    are~'escape-inside',~'footnote'~and~'footnotehyper'.~Other~keys~are~
+    available~in~\token_to_str:N \PitonOptions.\\
     That~key~will~be~ignored.
   }
 %    \end{macrocode}
@@ -490,10 +946,79 @@
 %    \end{macrocode}
 % 
 %
+%    \begin{macrocode}
+\msg_new:nnn { piton } { footnote~with~footnotehyper~package }
+  { 
+    Footnote~forbidden.\\
+    You~can't~use~the~option~'footnote'~because~the~package~
+    footnotehyper~has~already~been~loaded.~
+    If~you~want,~you~can~use~the~option~'footnotehyper'~and~the~footnotes~  
+    within~the~environments~of~piton~will~be~extracted~with~the~tools~
+    of~the~package~footnotehyper.\\
+    If~you~go~on,~the~package~footnote~won't~be~loaded.
+  }
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\msg_new:nnn { piton } { footnotehyper~with~footnote~package }
+  { 
+    You~can't~use~the~option~'footnotehyper'~because~the~package~
+    footnote~has~already~been~loaded.~
+    If~you~want,~you~can~use~the~option~'footnote'~and~the~footnotes~  
+    within~the~environments~of~piton~will~be~extracted~with~the~tools~
+    of~the~package~footnote.\\ 
+    If~you~go~on,~the~package~footnotehyper~won't~be~loaded.
+  }
+%    \end{macrocode}
+%
+% \medskip
+%    \begin{macrocode}
+\bool_if:NT \c_@@_footnote_bool 
+  { 
+%    \end{macrocode}
+% The class \cls{beamer} has its own system to extract footnotes and that's why
+% we have nothing to do if \cls{beamer} is used. 
+%    \begin{macrocode}
+    \@ifclassloaded { beamer }
+      { \bool_set_false:N \c_@@_footnote_bool }
+      { 
+        \@ifpackageloaded { footnotehyper }
+          { \@@_error:n { footnote~with~footnotehyper~package } }
+          { \usepackage { footnote } }
+      }
+  }
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\bool_if:NT \c_@@_footnotehyper_bool 
+  { 
+%    \end{macrocode}
+% The class \cls{beamer} has its own system to extract footnotes and that's why
+% we have nothing to do if \cls{beamer} is used. 
+%    \begin{macrocode}
+    \@ifclassloaded { beamer }
+      { \bool_set_false:N \c_@@_footnote_bool }
+      { 
+        \@ifpackageloaded { footnote }
+          { \@@_error:n { footnotehyper~with~footnote~package } }
+          { \usepackage { footnotehyper } }
+        \bool_set_true:N \c_@@_footnote_bool 
+      }
+  }
+%    \end{macrocode}
+% The flag |\c_@@_footnote_bool| is raised and so, we will only have to test
+% |\c_@@_footnote_bool| in order to know if we have to insert an environment
+% |{savenotes}|.
 % 
 % \medskip
 % \subsection{Parameters}
 %
+% The following token list will contains the (potential) informations to write
+% on the |aux| (to be used in the next compilation).
+%    \begin{macrocode}
+\tl_new:N \g_@@_aux_tl
+%    \end{macrocode}
+% 
 % \medskip
 % The following flag corresponds to the key |splittable| of |\PitonOptions|.
 %    \begin{macrocode}
@@ -501,11 +1026,41 @@
 %    \end{macrocode}
 %
 % \medskip
-% The following string corresponds to the key |background-color|.
+% The following string corresponds to the key |background-color| of |\PitonOptions|.
 %    \begin{macrocode}
 \str_new:N \l_@@_background_color_str
 %    \end{macrocode}
+%
+% \medskip
+% We will compute the maximal width of the lines of an environment |{Piton}| in
+% |\l_@@_width_dim|.
+%    \begin{macrocode}
+\dim_new:N \l_@@_width_dim 
+%    \end{macrocode}
+% The value of that dimension as written on the |aux| file will be stored in 
+% |\l_@@_width_on_aux_dim|.
+%    \begin{macrocode}
+\dim_new:N \l_@@_width_on_aux_dim 
+%    \end{macrocode}
+%
+% \medskip
+% We will count the environments |{Piton}| (and, in fact, also the commands
+% |\PitonInputFile|, despite the name |\g_@@_env_int|).
+%    \begin{macrocode}
+\int_new:N \g_@@_env_int 
+%    \end{macrocode}
 % 
+% \medskip
+% The following boolean corresponds to the key |slim| of |\PitonOptions|.
+%    \begin{macrocode}
+\bool_new:N \l_@@_slim_bool
+%    \end{macrocode}
+%
+% \medskip
+% The following dimension corresponds to the key |left-margin| of |\PitonOptions|.
+%    \begin{macrocode}
+\dim_new:N \l_@@_left_margin_dim
+%    \end{macrocode}
 % 
 % \subsection{The gobbling mechanism}
 %
@@ -531,14 +1086,24 @@
 %    \begin{macrocode}
 \cs_set_protected:Npn \@@_begin_line: #1 \@@_end_line:
   { 
+    \bool_lazy_and:nnT \l_@@_splittable_bool \c_@@_footnote_bool
+      { \begin { savenotes } } 
 %    \end{macrocode}
-% Be careful: the following |\hbox_set:Nn| et |\hbox_set_to_wd:Nnn| take in an
-% argument by curryfication.
+%
+% Be careful: there is curryfication in the following lines.
 %    \begin{macrocode}
-    \str_if_empty:NTF \l_@@_background_color_str
+    \bool_if:NTF \l_@@_slim_bool
       { \hbox_set:Nn \l_tmpa_box }
-      { \hbox_set_to_wd:Nnn \l_tmpa_box \linewidth }
       { 
+        \str_if_empty:NTF \l_@@_background_color_str
+          { \hbox_set_to_wd:Nnn \l_tmpa_box \linewidth }
+          { 
+            \hbox_set_to_wd:Nnn \l_tmpa_box 
+              { \dim_eval:n { \linewidth - 0.5 em } }
+          }
+      }
+      { 
+        \skip_horizontal:N \l_@@_left_margin_dim
         \bool_if:NT \l_@@_line_numbers_bool
           {
             \bool_if:NF \l_@@_all_line_numbers_bool
@@ -547,26 +1112,35 @@
           }
         \strut 
         \str_if_empty:NF \l_@@_background_color_str \space 
-        #1 \hfill 
+        #1 \hfil 
       } 
-    \box_set_dp:Nn \l_tmpa_box { \box_dp:N \l_tmpa_box + 1 pt } 
-    \box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + 1.5 pt } 
+%    \end{macrocode}
+% We compute in |\l_@@_width_dim| the maximal width of the lines of the
+% environments. 
+%    \begin{macrocode}
+    \dim_compare:nNnT { \box_wd:N \l_tmpa_box } > \l_@@_width_dim 
+      { \dim_set:Nn \l_@@_width_dim { \box_wd:N \l_tmpa_box } }
+    \box_set_dp:Nn \l_tmpa_box { \box_dp:N \l_tmpa_box + 1.25 pt } 
+    \box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + 1.25 pt } 
     \tl_if_empty:NTF \l_@@_background_color_str
       { \box_use_drop:N \l_tmpa_box }
       {
         \vbox_top:n 
           { 
-            \hbox_to_wd:nn \linewidth
+            \hbox:n
               { 
                 \exp_args:NV \color \l_@@_background_color_str
                 \vrule height \box_ht:N \l_tmpa_box 
                        depth \box_dp:N \l_tmpa_box 
-                       width \linewidth 
+                       width \l_@@_width_on_aux_dim
               } 
             \skip_vertical:n { - \box_ht_plus_dp:N \l_tmpa_box }
-            \box_use_drop:N \l_tmpa_box 
+            \box_set_wd:Nn \l_tmpa_box \l_@@_width_on_aux_dim 
+            \box_use_drop:N \l_tmpa_box
           }
       }   
+    \bool_lazy_and:nnT \l_@@_splittable_bool \c_@@_footnote_bool
+      { \end { savenotes } }
     \vspace { - 2.5 pt }
   }
 %    \end{macrocode}
@@ -610,10 +1184,14 @@
     all-line-numbers .value_forbidden:n = true  ,
     resume           .bool_set:N        = \l_@@_resume_bool ,
     resume           .value_forbidden:n = true ,
-    splittable        .bool_set:N      = \l_@@_splittable_bool ,
-    splittable        .default:n       = true , 
+    splittable       .bool_set:N        = \l_@@_splittable_bool ,
+    splittable       .default:n         = true , 
     background-color .str_set:N         = \l_@@_background_color_str ,
     background-color .value_required:n  = true ,
+    slim             .bool_set:N        = \l_@@_slim_bool ,
+    slim             .default:n         = true ,
+    left-margin      .dim_set:N         = \l_@@_left_margin_dim ,
+    left-margin      .value_required:n  = true ,
     unknown          .code:n = 
       \msg_error:nn { piton } { Unknown~key~for~PitonOptions }
   }
@@ -626,7 +1204,7 @@
     Unknown~key. \\
     The~key~'\l_keys_key_str'~is~unknown~for~\token_to_str:N \PitonOptions.~The~
     available~keys~are:~all-line-numbers,~auto-gobble,~env-gobble,~gobble,~
-    line-numbers,~resume~and~splittable.\\
+    left-margin,~line-numbers,~resume,~slim~and~splittable.\\
     If~you~go~on,~that~key~will~be~ignored.
   }
 %    \end{macrocode}
@@ -655,12 +1233,49 @@
     \hbox_overlap_left:n
       { 
         { \color { gray } \footnotesize \int_to_arabic:n \g_@@_line_int }
-        \quad 
+        \skip_horizontal:n { 0.4 em } 
       }
   }
 %    \end{macrocode}
 % 
 %
+% \medskip
+% \subsection{The command to write on the aux file}
+%
+%   
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_write_aux:
+  {
+    \tl_if_empty:NF \g_@@_aux_tl 
+      {
+        \iow_now:Nn \@mainaux { \ExplSyntaxOn }
+        \iow_now:Nx \@mainaux 
+          {
+            \tl_gset:cn { c_@@_ \int_use:N \g_@@_env_int _ tl } 
+              { \exp_not:V \g_@@_aux_tl } 
+          }
+        \iow_now:Nn \@mainaux { \ExplSyntaxOff }
+      }
+    \tl_gclear:N \g_@@_aux_tl 
+  }
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_width_to_aux:
+  {
+    \bool_if:NT \l_@@_slim_bool
+      {
+        \str_if_empty:NF \l_@@_background_color_str
+          {
+            \tl_gput_right:Nx \g_@@_aux_tl
+              {
+                \dim_set:Nn \l_@@_width_on_aux_dim 
+                  { \dim_use:N \l_@@_width_dim + 0.5 em }
+              }
+          }
+      }
+  }
+%    \end{macrocode}
 % 
 % \medskip
 % \subsection{The main commands and environments for the final user}
@@ -695,12 +1310,24 @@
 %    \begin{macrocode}
 \NewDocumentCommand { \PitonInputFile } { m }
   {
+    \int_gincr:N \g_@@_env_int 
+    \tl_gclear:N \g_@@_aux_tl
+    \tl_if_exist:cT { c_@@ _ \int_use:N \g_@@_env_int _ tl }
+      { \use:c { c_@@ _ \int_use:N \g_@@_env_int _ tl } }
+    \bool_if:NF \l_@@_splittable_bool
+      { \bool_if:NT \c_@@_footnote_bool { \begin { savenotes } } }
+    \dim_compare:nNnT \l_@@_width_on_aux_dim = \c_zero_dim
+      { \dim_set_eq:NN \l_@@_width_on_aux_dim \linewidth }
     \bool_if:NF \l_@@_resume_bool { \int_gzero:N \g_@@_line_int }
     \group_begin:
       \dim_set_eq:NN \parindent \c_zero_dim 
       \ttfamily
       \lua_now:e { ParseFile(token.scan_argument()) } { #1 }
+    \@@_width_to_aux:
     \group_end:
+    \@@_write_aux:
+    \bool_if:NF \l_@@_splittable_bool
+      { \bool_if:NT \c_@@_footnote_bool { \end { savenotes } } }
   }
 %    \end{macrocode}
 %
@@ -708,7 +1335,8 @@
 % \bigskip 
 %    \begin{macrocode}
 \NewDocumentCommand { \NewPitonEnvironment } { m m m m }
-  {
+  { 
+    \dim_zero:N \parindent 
 %    \end{macrocode}
 % We construct a TeX macro which will catch as argument all the tokens until
 % |\end{|\texttt{\textsl{name_env}}|}| with, in that
@@ -725,8 +1353,17 @@
       }
           {
             \group_end:
-            \mode_if_vertical:TF \mode_leave_vertical: \newline 
-            \bool_if:NF \l_@@_splittable_bool \vbox_top:n 
+            \mode_if_vertical:TF 
+              { \mode_leave_vertical: } 
+              \newline 
+%    \end{macrocode}
+% Be careful: there is curryfication in the following code.
+%    \begin{macrocode}
+            \bool_if:NF \l_@@_splittable_bool 
+              { 
+                \bool_if:NT \c_@@_footnote_bool { \begin { savenotes } } 
+                \vbox_top:n 
+              }
               {
                 \ttfamily
                 \dim_zero:N \lineskip 
@@ -748,12 +1385,16 @@
                   }
                 { ##1 }
                 \vspace { 2.5 pt } 
+                \@@_width_to_aux:
               }
+            \bool_if:NF \l_@@_splittable_bool
+              { \bool_if:NT \c_@@_footnote_bool { \end { savenotes } } }
 %    \end{macrocode}
 % The following |\end{#1}| is only for the groups and the stack of
 % environments of LaTeX.
 %    \begin{macrocode}
             \end { #1 }
+            \@@_write_aux:
           }   
 %    \end{macrocode}
 % 
@@ -766,6 +1407,12 @@
     \NewDocumentEnvironment { #1 } { #2 } 
       {
         #3 
+        \int_gincr:N \g_@@_env_int 
+        \tl_gclear:N \g_@@_aux_tl
+        \tl_if_exist:cT { c_@@ _ \int_use:N \g_@@_env_int _ tl }
+          { \use:c { c_@@ _ \int_use:N \g_@@_env_int _ tl } }
+        \dim_compare:nNnT \l_@@_width_on_aux_dim = \c_zero_dim
+          { \dim_set_eq:NN \l_@@_width_on_aux_dim \linewidth }
         \bool_if:NF \l_@@_resume_bool { \int_gzero:N \g_@@_line_int }
         \group_begin:
         \box_clear:N \l_tmpa_box
@@ -999,7 +1646,10 @@
 
 local alpha , digit , space , punct = lpeg.alpha , lpeg.digit , lpeg.space , lpeg.punct
 
-local letter = alpha + S"âàçéèêëïîôûüÂÀÇÉÈÊËÏÎÔÛÜ_" 
+-- Remember that à, â, ç, etc. are strings of length 2 (2 bytes)
+local letter = alpha + P "_" 
+ + P "â" + P "à" + P "ç" + P "é" + P "è" + P "ê" + P "ë" + P "ï" + P "î" + P "ô" + P "û" + P "ü" + 
+     P "Â" + P "À" + P "Ç" + P "É" + P "È" + P "Ê" + P "Ë" + P "Ï" + P "Î" + P "Ô" + P "Û" + P "Ü" 
 
 local alphanum = letter + digit
 
@@ -1310,7 +1960,6 @@
             * ItemOfSet * ( C ( P "," ) * ItemOfSet )  ^ 0 
             * C ( P "}" )
 
-
 local Operator = K ( P "!=" + P "==" + P "<<" + P ">>" + S "-~+/*%=<>&.@|" , 'Operator')
 
 local OperatorWord = K ( P "in" + P "is" + P "and" + P "or" + P "not" , 'Operator.Word')
@@ -1450,8 +2099,14 @@
 % New keys |resume|, |splittable| and |background-color| in |\PitonOptions|.
 %
 % The file |piton.lua| has been embedded in the file |piton.sty|. That means
-% that the extension \pkg{piton} is now enterily contained in the file |piton.sty|.
+% that the extension \pkg{piton} is now entirely contained in the file |piton.sty|.
 % 
+% \subsection*{Changes between versions 0.7 and 0.8}
+% 
+% New keys |footnote| and |footnotehyper| at load-time.
+%
+% New key |left-margin|.
+%
 % \end{document}
 % 
 %

Modified: trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty	2022-10-23 20:38:45 UTC (rev 64793)
+++ trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty	2022-10-23 20:38:58 UTC (rev 64794)
@@ -18,10 +18,11 @@
 %% and version 1.3 or later is part of all distributions of
 %% LaTeX version 2005/12/01 or later.
 %% 
-\def\myfileversion{0.7}
-\def\myfiledate{2022/10/08}
+\def\myfileversion{0.8}
+\def\myfiledate{2022/10/23}
 
 
+
 \NeedsTeXFormat{LaTeX2e}
 \RequirePackage{l3keys2e}
 \ProvidesExplPackage
@@ -33,8 +34,12 @@
   { The~package~'piton'~must~be~used~with~LuaLaTeX.\\ It~won't~be~loaded. }
 \sys_if_engine_luatex:F { \msg_critical:nn { piton } { LuaLaTeX~mandatory } }
 \RequirePackage { luatexbase }
+\bool_new:N \c__piton_footnotehyper_bool
+\bool_new:N \c__piton_footnote_bool
 \keys_define:nn { piton / package }
   {
+    footnote .bool_set:N = \c__piton_footnote_bool ,
+    footnotehyper .bool_set:N = \c__piton_footnotehyper_bool ,
     escape-inside .tl_set:N = \c__piton_escape_inside_tl ,
     escape-inside .initial:n = ,
     unknown .code:n = \msg_error:nn { piton } { unknown~key~for~package }
@@ -42,9 +47,9 @@
 \msg_new:nnn { piton } { unknown~key~for~package }
   {
     Unknown~key.\\
-    You~have~used~the~key~'\l_keys_key_str'~but~the~only~key~available~here~
-    is~the~key~'escape-inside'.~Other~keys~are~available~in~\token_to_str:N
-    \PitonOptions.\\
+    You~have~used~the~key~'\l_keys_key_str'~but~the~only~keys~available~here~
+    are~'escape-inside',~'footnote'~and~'footnotehyper'.~Other~keys~are~
+    available~in~\token_to_str:N \PitonOptions.\\
     That~key~will~be~ignored.
   }
 \ProcessKeysOptions { piton / package }
@@ -71,17 +76,73 @@
     The~package~'xcolor'~is~required~by~'piton'.\\
     This~error~is~fatal.
   }
+\msg_new:nnn { piton } { footnote~with~footnotehyper~package }
+  {
+    Footnote~forbidden.\\
+    You~can't~use~the~option~'footnote'~because~the~package~
+    footnotehyper~has~already~been~loaded.~
+    If~you~want,~you~can~use~the~option~'footnotehyper'~and~the~footnotes~
+    within~the~environments~of~piton~will~be~extracted~with~the~tools~
+    of~the~package~footnotehyper.\\
+    If~you~go~on,~the~package~footnote~won't~be~loaded.
+  }
+\msg_new:nnn { piton } { footnotehyper~with~footnote~package }
+  {
+    You~can't~use~the~option~'footnotehyper'~because~the~package~
+    footnote~has~already~been~loaded.~
+    If~you~want,~you~can~use~the~option~'footnote'~and~the~footnotes~
+    within~the~environments~of~piton~will~be~extracted~with~the~tools~
+    of~the~package~footnote.\\
+    If~you~go~on,~the~package~footnotehyper~won't~be~loaded.
+  }
+\bool_if:NT \c__piton_footnote_bool
+  {
+    \@ifclassloaded { beamer }
+      { \bool_set_false:N \c__piton_footnote_bool }
+      {
+        \@ifpackageloaded { footnotehyper }
+          { \__piton_error:n { footnote~with~footnotehyper~package } }
+          { \usepackage { footnote } }
+      }
+  }
+\bool_if:NT \c__piton_footnotehyper_bool
+  {
+    \@ifclassloaded { beamer }
+      { \bool_set_false:N \c__piton_footnote_bool }
+      {
+        \@ifpackageloaded { footnote }
+          { \__piton_error:n { footnotehyper~with~footnote~package } }
+          { \usepackage { footnotehyper } }
+        \bool_set_true:N \c__piton_footnote_bool
+      }
+  }
+\tl_new:N \g__piton_aux_tl
 \bool_new:N \l__piton_splittable_bool
 \str_new:N \l__piton_background_color_str
+\dim_new:N \l__piton_width_dim
+\dim_new:N \l__piton_width_on_aux_dim
+\int_new:N \g__piton_env_int
+\bool_new:N \l__piton_slim_bool
+\dim_new:N \l__piton_left_margin_dim
 \int_new:N \l__piton_gobble_int
 \cs_new_protected:Npn \__piton_define_gobble_syntax:n #1
   { \lua_now:n { define_gobble_syntax(#1) } }
 \cs_set_protected:Npn \__piton_begin_line: #1 \__piton_end_line:
   {
-    \str_if_empty:NTF \l__piton_background_color_str
+    \bool_lazy_and:nnT \l__piton_splittable_bool \c__piton_footnote_bool
+      { \begin { savenotes } }
+    \bool_if:NTF \l__piton_slim_bool
       { \hbox_set:Nn \l_tmpa_box }
-      { \hbox_set_to_wd:Nnn \l_tmpa_box \linewidth }
       {
+        \str_if_empty:NTF \l__piton_background_color_str
+          { \hbox_set_to_wd:Nnn \l_tmpa_box \linewidth }
+          {
+            \hbox_set_to_wd:Nnn \l_tmpa_box
+              { \dim_eval:n { \linewidth - 0.5 em } }
+          }
+      }
+      {
+        \skip_horizontal:N \l__piton_left_margin_dim
         \bool_if:NT \l__piton_line_numbers_bool
           {
             \bool_if:NF \l__piton_all_line_numbers_bool
@@ -90,26 +151,31 @@
           }
         \strut
         \str_if_empty:NF \l__piton_background_color_str \space
-        #1 \hfill
+        #1 \hfil
       }
-    \box_set_dp:Nn \l_tmpa_box { \box_dp:N \l_tmpa_box + 1 pt }
-    \box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + 1.5 pt }
+    \dim_compare:nNnT { \box_wd:N \l_tmpa_box } > \l__piton_width_dim
+      { \dim_set:Nn \l__piton_width_dim { \box_wd:N \l_tmpa_box } }
+    \box_set_dp:Nn \l_tmpa_box { \box_dp:N \l_tmpa_box + 1.25 pt }
+    \box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + 1.25 pt }
     \tl_if_empty:NTF \l__piton_background_color_str
       { \box_use_drop:N \l_tmpa_box }
       {
         \vbox_top:n
           {
-            \hbox_to_wd:nn \linewidth
+            \hbox:n
               {
                 \exp_args:NV \color \l__piton_background_color_str
                 \vrule height \box_ht:N \l_tmpa_box
                        depth \box_dp:N \l_tmpa_box
-                       width \linewidth
+                       width \l__piton_width_on_aux_dim
               }
             \skip_vertical:n { - \box_ht_plus_dp:N \l_tmpa_box }
+            \box_set_wd:Nn \l_tmpa_box \l__piton_width_on_aux_dim
             \box_use_drop:N \l_tmpa_box
           }
       }
+    \bool_lazy_and:nnT \l__piton_splittable_bool \c__piton_footnote_bool
+      { \end { savenotes } }
     \vspace { - 2.5 pt }
   }
 \bool_new:N \l__piton_line_numbers_bool
@@ -131,10 +197,14 @@
     all-line-numbers .value_forbidden:n = true  ,
     resume           .bool_set:N        = \l__piton_resume_bool ,
     resume           .value_forbidden:n = true ,
-    splittable        .bool_set:N      = \l__piton_splittable_bool ,
-    splittable        .default:n       = true ,
+    splittable       .bool_set:N        = \l__piton_splittable_bool ,
+    splittable       .default:n         = true ,
     background-color .str_set:N         = \l__piton_background_color_str ,
     background-color .value_required:n  = true ,
+    slim             .bool_set:N        = \l__piton_slim_bool ,
+    slim             .default:n         = true ,
+    left-margin      .dim_set:N         = \l__piton_left_margin_dim ,
+    left-margin      .value_required:n  = true ,
     unknown          .code:n =
       \msg_error:nn { piton } { Unknown~key~for~PitonOptions }
   }
@@ -143,7 +213,7 @@
     Unknown~key. \\
     The~key~'\l_keys_key_str'~is~unknown~for~\token_to_str:N \PitonOptions.~The~
     available~keys~are:~all-line-numbers,~auto-gobble,~env-gobble,~gobble,~
-    line-numbers,~resume~and~splittable.\\
+    left-margin,~line-numbers,~resume,~slim~and~splittable.\\
     If~you~go~on,~that~key~will~be~ignored.
   }
 \NewDocumentCommand \PitonOptions { } { \keys_set:nn { PitonOptions } }
@@ -154,9 +224,37 @@
     \hbox_overlap_left:n
       {
         { \color { gray } \footnotesize \int_to_arabic:n \g__piton_line_int }
-        \quad
+        \skip_horizontal:n { 0.4 em }
       }
   }
+\cs_new_protected:Npn \__piton_write_aux:
+  {
+    \tl_if_empty:NF \g__piton_aux_tl
+      {
+        \iow_now:Nn \@mainaux { \ExplSyntaxOn }
+        \iow_now:Nx \@mainaux
+          {
+            \tl_gset:cn { c__piton_ \int_use:N \g__piton_env_int _ tl }
+              { \exp_not:V \g__piton_aux_tl }
+          }
+        \iow_now:Nn \@mainaux { \ExplSyntaxOff }
+      }
+    \tl_gclear:N \g__piton_aux_tl
+  }
+\cs_new_protected:Npn \__piton_width_to_aux:
+  {
+    \bool_if:NT \l__piton_slim_bool
+      {
+        \str_if_empty:NF \l__piton_background_color_str
+          {
+            \tl_gput_right:Nx \g__piton_aux_tl
+              {
+                \dim_set:Nn \l__piton_width_on_aux_dim
+                  { \dim_use:N \l__piton_width_dim + 0.5 em }
+              }
+          }
+      }
+  }
 \NewDocumentCommand { \piton } { v }
   {
     \group_begin:
@@ -176,15 +274,28 @@
   }
 \NewDocumentCommand { \PitonInputFile } { m }
   {
+    \int_gincr:N \g__piton_env_int
+    \tl_gclear:N \g__piton_aux_tl
+    \tl_if_exist:cT { c__piton _ \int_use:N \g__piton_env_int _ tl }
+      { \use:c { c__piton _ \int_use:N \g__piton_env_int _ tl } }
+    \bool_if:NF \l__piton_splittable_bool
+      { \bool_if:NT \c__piton_footnote_bool { \begin { savenotes } } }
+    \dim_compare:nNnT \l__piton_width_on_aux_dim = \c_zero_dim
+      { \dim_set_eq:NN \l__piton_width_on_aux_dim \linewidth }
     \bool_if:NF \l__piton_resume_bool { \int_gzero:N \g__piton_line_int }
     \group_begin:
       \dim_set_eq:NN \parindent \c_zero_dim
       \ttfamily
       \lua_now:e { ParseFile(token.scan_argument()) } { #1 }
+    \__piton_width_to_aux:
     \group_end:
+    \__piton_write_aux:
+    \bool_if:NF \l__piton_splittable_bool
+      { \bool_if:NT \c__piton_footnote_bool { \end { savenotes } } }
   }
 \NewDocumentCommand { \NewPitonEnvironment } { m m m m }
   {
+    \dim_zero:N \parindent
     \use:x
       {
         \cs_set_protected:Npn
@@ -194,9 +305,15 @@
       }
           {
             \group_end:
-            \mode_if_vertical:TF \mode_leave_vertical: \newline
-            \bool_if:NF \l__piton_splittable_bool \vbox_top:n
+            \mode_if_vertical:TF
+              { \mode_leave_vertical: }
+              \newline
+            \bool_if:NF \l__piton_splittable_bool
               {
+                \bool_if:NT \c__piton_footnote_bool { \begin { savenotes } }
+                \vbox_top:n
+              }
+              {
                 \ttfamily
                 \dim_zero:N \lineskip
                 \int_case:nnF \l__piton_gobble_int
@@ -214,12 +331,22 @@
                   }
                 { ##1 }
                 \vspace { 2.5 pt }
+                \__piton_width_to_aux:
               }
+            \bool_if:NF \l__piton_splittable_bool
+              { \bool_if:NT \c__piton_footnote_bool { \end { savenotes } } }
             \end { #1 }
+            \__piton_write_aux:
           }
     \NewDocumentEnvironment { #1 } { #2 }
       {
         #3
+        \int_gincr:N \g__piton_env_int
+        \tl_gclear:N \g__piton_aux_tl
+        \tl_if_exist:cT { c__piton _ \int_use:N \g__piton_env_int _ tl }
+          { \use:c { c__piton _ \int_use:N \g__piton_env_int _ tl } }
+        \dim_compare:nNnT \l__piton_width_on_aux_dim = \c_zero_dim
+          { \dim_set_eq:NN \l__piton_width_on_aux_dim \linewidth }
         \bool_if:NF \l__piton_resume_bool { \int_gzero:N \g__piton_line_int }
         \group_begin:
         \box_clear:N \l_tmpa_box
@@ -383,7 +510,10 @@
 
 local alpha , digit , space , punct = lpeg.alpha , lpeg.digit , lpeg.space , lpeg.punct
 
-local letter = alpha + S"âàçéèêëïîôûüÂÀÇÉÈÊËÏÎÔÛÜ_"
+-- Remember that à, â, ç, etc. are strings of length 2 (2 bytes)
+local letter = alpha + P "_"
+ + P "â" + P "à" + P "ç" + P "é" + P "è" + P "ê" + P "ë" + P "ï" + P "î" + P "ô" + P "û" + P "ü" +
+     P "Â" + P "À" + P "Ç" + P "É" + P "È" + P "Ê" + P "Ë" + P "Ï" + P "Î" + P "Ô" + P "Û" + P "Ü"
 
 local alphanum = letter + digit
 



More information about the tex-live-commits mailing list.