texlive[69985] Master/texmf-dist: pynotebook (19feb24)

commits+karl at tug.org commits+karl at tug.org
Mon Feb 19 21:58:49 CET 2024


Revision: 69985
          https://tug.org/svn/texlive?view=revision&revision=69985
Author:   karl
Date:     2024-02-19 21:58:49 +0100 (Mon, 19 Feb 2024)
Log Message:
-----------
pynotebook (19feb24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.pdf
    trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.tex
    trunk/Master/texmf-dist/tex/latex/pynotebook/pynotebook.sty

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.pdf
    trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.tex

Removed Paths:
-------------
    trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.pdf
    trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.tex

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

Modified: trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.tex	2024-02-19 20:58:35 UTC (rev 69984)
+++ trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.tex	2024-02-19 20:58:49 UTC (rev 69985)
@@ -33,8 +33,8 @@
 \usepackage[margin=2cm]{geometry}
 \setlength{\parindent}{0pt}
 
-\def\TPversion{0.1.0}
-\def\TPdate{15/02/2024}
+\def\TPversion{0.1.1}
+\def\TPdate{19/02/2024}
 
 \sethlcolor{lightgray!25}
 \NewDocumentCommand\ShowCode{ m }{%
@@ -90,6 +90,10 @@
 
 \vfill~
 
+\textit{\footnotesize Thanks to F. Pantigny for his package \textsf{piton} and his help.}\dotfill{\footnotesize\ttfamily\url{https://ctan.org/pkg/piton}}
+
+\textit{\footnotesize And thanks to Tobias Enderle for his package \textsf{pyluatex}.}\dotfill{\footnotesize\ttfamily\url{https://ctan.org/pkg/pyluatex}}
+
 \pagebreak
 
 \section{Samples, with listings}
@@ -114,18 +118,65 @@
 \end{NotebookRaw}
 
 \begin{NotebookIn}{\linewidth}
-def fibonacci_of(n) :
-	if n in {0,1} :
-		return n
-	return fibonacci_of(n-1) + fibonacci_of(n-2)
-	
-[fibonacci_of(n) for n in range(15)]
+def fibonacci_aux(n,a,b):
+	if n == 0 :
+		return a
+	elif n == 1 :
+		return b
+	else:
+		return fibonacci_aux(n-1,b,a+b)
+
+def fibonacci_of(n):
+	return fibonacci_aux(n,0,1)
+
+print([fibonacci_of(n) for n in range(10)])
 \end{NotebookIn}
 
 \begin{NotebookOut}{\linewidth}
-[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]
+[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
 \end{NotebookOut}
 
+\begin{NotebookRaw}{\linewidth}
+Now we’re going to work with lists.
+
+Just a little example with a prime numbers, in french.
+\end{NotebookRaw}
+
+\begin{NotebookIn}{\linewidth}
+def proc_exec() :
+	choix = "o"
+	while choix == "o" :
+		n = -1
+		while n <= 1 :
+			n = int(input("Saisir un entier n, supérieur à 2 : "))
+		if estpremier(n) == True :
+			print(f"{n} est premier.")
+		else :
+			print(f"{n} n'est pas premier.")
+		listeres = listenombrepremiers(n)
+		print(f"La liste des entiers premiers <= à {n} est {listeres}.")
+		print(f"Il y a donc {len(listeres)} entiers premiers <= à {n}.")
+		choix = input("Recommencer [o/n] ? ")
+\end{NotebookIn}
+
+\begin{NotebookIn}{\linewidth}
+proc_exec()
+\end{NotebookIn}
+
+\begin{NotebookConsole}{\linewidth}
+Saisir un entier n, supérieur à 2 : 14
+14 n'est pas premier.
+La liste des entiers premiers <= à 14 est [2, 3, 5, 7, 11, 13].
+Il y a donc 6 entiers premiers <= à 14.
+Recommencer [o/n] ? o
+Saisir un entier n, supérieur à 2 : 1
+Saisir un entier n, supérieur à 2 : -3
+Saisir un entier n, supérieur à 2 : 25
+25 n'est pas premier.
+La liste des entiers premiers <= à 25 est [2, 3, 5, 7, 11, 13, 17, 19, 23].
+Il y a donc 9 entiers premiers <= à 25.
+Recommencer [o/n] ? n
+\end{NotebookConsole}
 %\vspace*{5mm}
 %
 %\begin{center}
@@ -134,10 +185,12 @@
 %
 %\includegraphics[clip]{pynotebook-samples-pitonpyluatex.pdf}
 
-\vfill~
+\pagebreak
 
 \section{History}
 
+\verb|v0.1.1|~:~~~~New block \textsf{In/Out} with \textsf{piton/pyluatex} (tks to F. Pantigny)
+
 \verb|v0.1.0|~:~~~~Initial version
 
 \vspace*{15mm}
@@ -148,7 +201,7 @@
 
 \subsection{Ideas}
 
-The idea is to provides environments to reproduce a Jupyter notebook :
+The idea is to provide environments to reproduce a Jupyter notebook :
 
 \begin{itemize}
 	\item with \textit{blocks} for \textsf{RAW} or \textsf{Markdown} ;
@@ -307,73 +360,100 @@
 
 \begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10]
 \begin{NotebookIn}{\linewidth}
-def fibonacci_of(n) :
-  if n in {0,1} :
-    return n
-  return fibonacci_of(n-1) + fibonacci_of(n-2)
+def fibonacci_aux(n,a,b):
+  if n == 0 :
+    return a
+  elif n == 1 :
+    return b
+  else:
+    return fibonacci_aux(n-1,b,a+b)
 
-[fibonacci_of(n) for n in range(15)]
+def fibonacci_of(n):
+  return fibonacci_aux(n,0,1)
+
+[fibonacci_of(n) for n in range(10)]
 \end{NotebookIn}
 
 \begin{NotebookOut}{\linewidth}
-[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]
+[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
 \end{NotebookOut}
 
 \begin{NotebookConsole}{\linewidth}
-[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]
+[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
 \end{NotebookConsole}
 \end{codehigh}
 
+\pagebreak
+
 \begin{NotebookIn}{\linewidth}
-def fibonacci_of(n) :
-	if n in {0,1} :
-		return n
-	return fibonacci_of(n-1) + fibonacci_of(n-2)
+def fibonacci_aux(n,a,b):
+	if n == 0 :
+		return a
+	elif n == 1 :
+		return b
+	else:
+		return fibonacci_aux(n-1,b,a+b)
 
-[fibonacci_of(n) for n in range(15)]
+def fibonacci_of(n):
+	return fibonacci_aux(n,0,1)
+
+[fibonacci_of(n) for n in range(10)]
 \end{NotebookIn}
 
 \begin{NotebookOut}{\linewidth}
-[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]
+[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
 \end{NotebookOut}
 
 \begin{NotebookConsole}{\linewidth}
-[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]
+[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
 \end{NotebookConsole}
 
 \begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10]
 \begin{NotebookIn}*[flush right]{13cm}
-def fibonacci_of(n) :
-  if n in {0,1} :
-    return n
-  return fibonacci_of(n-1) + fibonacci_of(n-2)
+def fibonacci_aux(n,a,b):
+  if n == 0 :
+    return a
+  elif n == 1 :
+    return b
+  else:
+    return fibonacci_aux(n-1,b,a+b)
 
+def fibonacci_of(n):
+  return fibonacci_aux(n,0,1)
+
+[fibonacci_of(n) for n in range(10)]
 \end{NotebookIn}
 
 \begin{NotebookOut}*[flush right]{13cm}
-[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]
+[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
 \end{NotebookOut}
 
 \begin{NotebookConsole}[flush right]{13cm}
-[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]
+[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
 \end{NotebookConsole}
 \end{codehigh}
 
 \begin{NotebookIn}*[flush right]{13cm}
-def fibonacci_of(n) :
-	if n in {0,1} :
-		return n
-	return fibonacci_of(n-1) + fibonacci_of(n-2)
+def fibonacci_aux(n,a,b):
+	if n == 0 :
+		return a
+	elif n == 1 :
+		return b
+	else:
+		return fibonacci_aux(n-1,b,a+b)
 
-[fibonacci_of(n) for n in range(15)]
+def fibonacci_of(n):
+	return fibonacci_aux(n,0,1)
+
+[fibonacci_of(n) for n in range(10)]
 \end{NotebookIn}
 
 \begin{NotebookOut}*[flush right]{13cm}
-[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]
+[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
 \end{NotebookOut}
 
 \begin{NotebookConsole}[flush right]{13cm}
-[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]
+[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
 \end{NotebookConsole}
 
 \pagebreak
@@ -389,6 +469,7 @@
 \begin{itemize}
 	\item with \texttt{In~[...]} ;
 	\item with \texttt{Out[...]} ;
+	\item with \texttt{In[...]\&{}Out[...]} ;
 	\item without \textit{header}, eg for a \textit{console execution}.
 \end{itemize}
 
@@ -405,6 +486,12 @@
 \end{codehigh}
 
 \begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10]
+\begin{NotebookPitonInOut}(*)[options tcbox]{<width>}
+<code>
+\end{NotebookPitonInOut}
+\end{codehigh}
+
+\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10]
 \begin{NotebookPitonConsole}[options tcbox]{<width>}
 <code>
 \end{NotebookPitonConsole}
@@ -424,9 +511,9 @@
 
 \subsection{Ideas}
 
-The package provides to macro, in order to :
+The package provides macros, in order to :
 
-\begin{itemize}
+\begin{itemize}[itemsep=2pt]
 	\item configure the \textit{words} \texttt{In/Out} in \textsf{french} ;
 	\item configure the spacing before and after the boxes (\ShowCode{0.33\textbackslash baselineskip} by default).
 \end{itemize}
@@ -447,16 +534,22 @@
 \setcounter{JupyterIn}{14}
 
 \begin{NotebookIn}{0.75\linewidth}
-def fibonacci_of(n) :
-  if n in {0,1} :
-    return n
-  return fibonacci_of(n-1) + fibonacci_of(n-2)
+def fibonacci_aux(n,a,b):
+  if n == 0 :
+    return a
+  elif n == 1 :
+    return b
+  else:
+    return fibonacci_aux(n-1,b,a+b)
 
+def fibonacci_of(n):
+  return fibonacci_aux(n,0,1)
+
 [fibonacci_of(n) for n in range(15)]
 \end{NotebookIn}
 
 \begin{NotebookOut}{0.75\linewidth}
-[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]
+[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
 \end{NotebookOut}
 \end{codehigh}
 
@@ -464,19 +557,23 @@
 \SetJupyterParSkip{\baselineskip}
 \setcounter{JupyterIn}{14}
 
-\hrulefill
-
 \begin{NotebookIn}{0.75\linewidth}
-def fibonacci_of(n) :
-	if n in {0,1} :
-		return n
-	return fibonacci_of(n-1) + fibonacci_of(n-2)
+def fibonacci_aux(n,a,b):
+	if n == 0 :
+		return a
+	elif n == 1 :
+		return b
+	else:
+		return fibonacci_aux(n-1,b,a+b)
 
-[fibonacci_of(n) for n in range(15)]
+def fibonacci_of(n):
+	return fibonacci_aux(n,0,1)
+
+[fibonacci_of(n) for n in range(10)]
 \end{NotebookIn}
 
 \begin{NotebookOut}{0.75\linewidth}
-[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]
+[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
 \end{NotebookOut}
 
 \end{document}
\ No newline at end of file

Deleted: trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.pdf
===================================================================
(Binary files differ)

Deleted: trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.tex	2024-02-19 20:58:35 UTC (rev 69984)
+++ trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.tex	2024-02-19 20:58:49 UTC (rev 69985)
@@ -1,239 +0,0 @@
-% !TeX TXS-program:compile = txs:///arara
-% arara: lualatex: {shell: yes, synctex: yes, interaction: batchmode}
-% arara: lualatex: {shell: yes, synctex: yes, interaction: batchmode} if found('log', '(undefined references|Please rerun|Rerun to get)')
-
-\documentclass[a4paper,11pt]{article}
-\def\PLver{0.1.0}
-\usepackage[margin=1.5cm]{geometry}
-\usepackage{pynotebook}
-\usepackage[executable=python]{pyluatex}
-\usepackage{codehigh}
-
-\begin{document}
-
-\part*{pynotebook (\PLver), with piton and pyluatex}
-
-\section{Preamble}
-
-\begin{codehigh}
-\documentclass{article}
-\usepackage{pynotebook}
-\usepackage[executable=python]{pyluatex}  % with a specific compilation !!
-\end{codehigh}
-
-\section{Examples of text blocks}
-
-\begin{codehigh}
-\begin{NotebookPitonMarkdown}{\linewidth}
-{\Large\bfseries This is a test for a \textsf{Markdown} block.}
-
-It's possible to use \LaTeX{} formulas, like %
-\[
-  \left\lbrace\begin{array}{l}
-    F_0 = 0\\
-    F_1 = 1 \\
-    F_{n+2} = F_{n+1} + F_n
-  \end{array}\right.
-\]
-\end{NotebookPitonMarkdown}
-
-\begin{NotebookPitonRaw}{\linewidth}
-This is a sample block, with RAW output.
-
-Just to use all capacities of Jupyter notebook ;-)
-\end{NotebookPitonRaw}
-\end{codehigh}
-
-\begin{NotebookPitonMarkdown}{\linewidth}
-{\Large\bfseries This is a test for a \textsf{Markdown} block.}
-
-It's possible to use \LaTeX{} formulas, like %
-\[
-\left\lbrace\begin{array}{l}
-F_0 = 0\\
-F_1 = 1 \\
-F_{n+2} = F_{n+1} + F_n
-\end{array}\right.
-\]
-\end{NotebookPitonMarkdown}
-
-\begin{NotebookPitonRaw}{\linewidth}
-This is a sample block, with RAW output.
-
-Just to use all capacities of Jupyter notebook ;-)
-\end{NotebookPitonRaw}
-
-\section{Examples of code blocks (with execution of code !)}
-
-\begin{codehigh}
-\begin{NotebookPitonIn}{0.75\linewidth}
-def fibonacci_of(n) :
-  if n in {0,1} :
-    return n
-  return fibonacci_of(n-1) + fibonacci_of(n-2)
-
-[fibonacci_of(n) for n in range(15)]
-\end{NotebookPitonIn}
-\end{codehigh}
-
-\begin{NotebookPitonIn}{0.75\linewidth}
-def fibonacci_of(n) :
-	if n in {0,1} :
-		return n
-	return fibonacci_of(n-1) + fibonacci_of(n-2)
-
-[fibonacci_of(n) for n in range(15)]
-\end{NotebookPitonIn}
-
-\begin{codehigh}
-\begin{NotebookPitonOut}{0.75\linewidth}
-def fibonacci_of(n) :
-  if n in {0,1} :
-    return n
-  return fibonacci_of(n-1) + fibonacci_of(n-2)
-
-print([fibonacci_of(n) for n in range(15)])
-\end{NotebookPitonOut}
-\end{codehigh}
-
-\begin{NotebookPitonOut}{\linewidth}
-def fibonacci_of(n) :
-	if n in {0,1} :
-		return n
-	return fibonacci_of(n-1) + fibonacci_of(n-2)
-
-print([fibonacci_of(n) for n in range(15)])
-\end{NotebookPitonOut}
-
-\begin{codehigh}
-\SetJupyterLng{fr}
-\SetJupyterParSkip{\baselineskip}
-\setcounter{JupyterIn}{11}
-\end{codehigh}
-
-\SetJupyterLng{fr}
-\SetJupyterParSkip{\baselineskip}
-\setcounter{JupyterIn}{14}
-
-\begin{codehigh}
-\begin{NotebookPitonIn}[center]{0.75\linewidth}
-def fibonacci_of(n) :
-  if n in {0,1} :
-    return n
-  return fibonacci_of(n-1) + fibonacci_of(n-2)
-
-[fibonacci_of(n) for n in range(15)]
-\end{NotebookPitonIn}
-\end{codehigh}
-
-\begin{NotebookPitonIn}[center]{0.75\linewidth}
-def fibonacci_of(n) :
-	if n in {0,1} :
-		return n
-	return fibonacci_of(n-1) + fibonacci_of(n-2)
-
-[fibonacci_of(n) for n in range(15)]
-\end{NotebookPitonIn}
-
-\begin{codehigh}
-\begin{NotebookPitonOut}[center]{0.75\linewidth}
-def fibonacci_of(n) :
-  if n in {0,1} :
-    return n
-  return fibonacci_of(n-1) + fibonacci_of(n-2)
-
-print([fibonacci_of(n) for n in range(15)])
-\end{NotebookPitonOut}
-\end{codehigh}
-
-\begin{NotebookPitonOut}[center]{0.75\linewidth}
-def fibonacci_of(n) :
-	if n in {0,1} :
-		return n
-	return fibonacci_of(n-1) + fibonacci_of(n-2)
-
-print([fibonacci_of(n) for n in range(15)])
-\end{NotebookPitonOut}
-
-\begin{codehigh}
-\begin{NotebookPitonConsole}[center]{0.75\linewidth}
-def fibonacci_of(n) :
-  if n in {0,1} :
-    return n
-  return fibonacci_of(n-1) + fibonacci_of(n-2)
-
-print([fibonacci_of(n) for n in range(15)])
-\end{NotebookPitonConsole}
-\end{codehigh}
-
-\begin{NotebookPitonConsole}[center]{0.75\linewidth}
-def fibonacci_of(n) :
-	if n in {0,1} :
-		return n
-	return fibonacci_of(n-1) + fibonacci_of(n-2)
-
-print([fibonacci_of(n) for n in range(15)])
-\end{NotebookPitonConsole}
-
-\pagebreak
-
-\section{Global example}
-
-\SetJupyterParSkip{default}
-\setcounter{JupyterIn}{0}
-
-\begin{NotebookPitonMarkdown}{\linewidth}
-{\Large\bfseries This is a test for a \textsf{Markdown} block.}
-
-It's possible to use \LaTeX{} formulas, like %
-\[
-\left\lbrace\begin{array}{l}
-F_0 = 0\\
-F_1 = 1 \\
-F_{n+2} = F_{n+1} + F_n
-\end{array}\right.
-\]
-\end{NotebookPitonMarkdown}
-
-\begin{NotebookPitonRaw}{\linewidth}
-This is a sample block, with RAW output.
-
-Just to use all capacities of Jupyter notebook ;-)
-\end{NotebookPitonRaw}
-
-\begin{NotebookPitonIn}{\linewidth}
-def fibonacci_of(n) :
-	if n in {0,1} :
-		return n
-	return fibonacci_of(n-1) + fibonacci_of(n-2)
-
-[fibonacci_of(n) for n in range(15)]
-\end{NotebookPitonIn}
-
-\begin{NotebookPitonOut}{\linewidth}
-def fibonacci_of(n) :
-	if n in {0,1} :
-		return n
-	return fibonacci_of(n-1) + fibonacci_of(n-2)
-
-print([fibonacci_of(n) for n in range(15)])
-\end{NotebookPitonOut}
-
-\begin{NotebookPitonRaw}{\linewidth}
-Let’s compute Fibonacci terms from 10th to 20th :-)
-\end{NotebookPitonRaw}
-
-\begin{NotebookPitonIn}{\linewidth}
-[fibonacci_of(n) for n in range(10,21)]
-\end{NotebookPitonIn}
-
-\begin{NotebookPitonConsole}{\linewidth}
-def fibonacci_of(n) :
-	if n in {0,1} :
-		return n
-	return fibonacci_of(n-1) + fibonacci_of(n-2)
-
-print([fibonacci_of(n) for n in range(10,21)])
-\end{NotebookPitonConsole}
-
-\end{document}
\ No newline at end of file

Added: trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.pdf	2024-02-19 20:58:35 UTC (rev 69984)
+++ trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.pdf	2024-02-19 20:58:49 UTC (rev 69985)

Property changes on: trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.tex	2024-02-19 20:58:49 UTC (rev 69985)
@@ -0,0 +1,374 @@
+% !TeX TXS-program:compile = txs:///arara
+% arara: lualatex: {shell: yes, synctex: no, interaction: batchmode}
+% arara: lualatex: {shell: yes, synctex: no, interaction: batchmode} if found('log', '(undefined references|Please rerun|Rerun to get)')
+
+\documentclass[a4paper,11pt]{article}
+\def\PLver{0.1.1}
+\usepackage[margin=1.5cm]{geometry}
+\usepackage{pynotebook}
+\usepackage[executable=python]{pyluatex}
+\usepackage{codehigh}
+
+\begin{document}
+
+\part*{pynotebook (\PLver), with piton and pyluatex}
+
+\section{Preamble}
+
+\begin{codehigh}
+\documentclass{article}
+\usepackage{pynotebook}
+\usepackage[executable=python]{pyluatex}  % with a specific compilation !!
+\end{codehigh}
+
+\section{Examples of text blocks}
+
+\begin{codehigh}
+\begin{NotebookPitonMarkdown}{\linewidth}
+{\Large\bfseries This is a test for a \textsf{Markdown} block.}
+
+It's possible to use \LaTeX{} formulas, like %
+\[
+  \left\lbrace\begin{array}{l}
+    F_0 = 0\\
+    F_1 = 1 \\
+    F_{n+2} = F_{n+1} + F_n
+  \end{array}\right.
+\]
+\end{NotebookPitonMarkdown}
+
+\begin{NotebookPitonRaw}{\linewidth}
+This is a sample block, with RAW output.
+
+Just to use all capacities of Jupyter notebook ;-)
+\end{NotebookPitonRaw}
+\end{codehigh}
+
+\begin{NotebookPitonMarkdown}{\linewidth}
+{\Large\bfseries This is a test for a \textsf{Markdown} block.}
+
+It's possible to use \LaTeX{} formulas, like %
+\[
+\left\lbrace\begin{array}{l}
+F_0 = 0\\
+F_1 = 1 \\
+F_{n+2} = F_{n+1} + F_n
+\end{array}\right.
+\]
+\end{NotebookPitonMarkdown}
+
+\begin{NotebookPitonRaw}{\linewidth}
+This is a sample block, with RAW output.
+
+Just to use all capacities of Jupyter notebook ;-)
+\end{NotebookPitonRaw}
+
+\section{Examples of code blocks (with execution of code !)}
+
+\subsection{With block In then block Out}
+
+\begin{codehigh}
+\begin{NotebookPitonIn}{0.75\linewidth}
+def fibonacci_aux(n,a,b):
+  if n == 0 :
+    return a
+  elif n == 1 :
+    return b
+  else:
+    return fibonacci_aux(n-1,b,a+b)
+
+def fibonacci_of(n):
+  return fibonacci_aux(n,0,1)
+
+[fibonacci_of(n) for n in range(10)]
+\end{NotebookPitonIn}
+\end{codehigh}
+
+\begin{NotebookPitonIn}{0.75\linewidth}
+def fibonacci_aux(n,a,b):
+	if n == 0 :
+		return a
+	elif n == 1 :
+		return b
+	else:
+		return fibonacci_aux(n-1,b,a+b)
+
+def fibonacci_of(n):
+	return fibonacci_aux(n,0,1)
+
+[fibonacci_of(n) for n in range(10)]
+\end{NotebookPitonIn}
+
+\begin{codehigh}
+\begin{NotebookPitonOut}{0.75\linewidth}
+def fibonacci_aux(n,a,b):
+  if n == 0 :
+    return a
+  elif n == 1 :
+    return b
+  else:
+    return fibonacci_aux(n-1,b,a+b)
+
+def fibonacci_of(n):
+  return fibonacci_aux(n,0,1)
+
+print([fibonacci_of(n) for n in range(10)])
+\end{NotebookPitonOut}
+\end{codehigh}
+
+\begin{NotebookPitonOut}{\linewidth}
+def fibonacci_aux(n,a,b):
+	if n == 0 :
+		return a
+	elif n == 1 :
+		return b
+	else:
+		return fibonacci_aux(n-1,b,a+b)
+
+def fibonacci_of(n):
+	return fibonacci_aux(n,0,1)
+
+print([fibonacci_of(n) for n in range(10)])
+\end{NotebookPitonOut}
+
+\pagebreak
+
+\begin{codehigh}
+\SetJupyterLng{fr}
+\SetJupyterParSkip{\baselineskip}
+\setcounter{JupyterIn}{11}
+\end{codehigh}
+
+\SetJupyterLng{fr}
+\SetJupyterParSkip{\baselineskip}
+\setcounter{JupyterIn}{11}
+
+\begin{codehigh}
+\begin{NotebookPitonIn}[center]{0.75\linewidth}
+def fibonacci_aux(n,a,b):
+  if n == 0 :
+    return a
+  elif n == 1 :
+    return b
+  else:
+    return fibonacci_aux(n-1,b,a+b)
+
+def fibonacci_of(n):
+  return fibonacci_aux(n,0,1)
+
+print([fibonacci_of(n) for n in range(10)])
+\end{NotebookPitonIn}
+\end{codehigh}
+
+\begin{NotebookPitonIn}[center]{0.75\linewidth}
+def fibonacci_aux(n,a,b):
+	if n == 0 :
+		return a
+	elif n == 1 :
+		return b
+	else:
+		return fibonacci_aux(n-1,b,a+b)
+
+def fibonacci_of(n):
+	return fibonacci_aux(n,0,1)
+
+print([fibonacci_of(n) for n in range(10)])
+\end{NotebookPitonIn}
+
+\begin{codehigh}
+\begin{NotebookPitonOut}[center]{0.75\linewidth}
+def fibonacci_aux(n,a,b):
+  if n == 0 :
+    return a
+  elif n == 1 :
+    return b
+  else:
+    return fibonacci_aux(n-1,b,a+b)
+
+def fibonacci_of(n):
+  return fibonacci_aux(n,0,1)
+
+print([fibonacci_of(n) for n in range(10)])
+\end{NotebookPitonOut}
+\end{codehigh}
+
+\begin{NotebookPitonOut}[center]{0.75\linewidth}
+def fibonacci_aux(n,a,b):
+	if n == 0 :
+		return a
+	elif n == 1 :
+		return b
+	else:
+		return fibonacci_aux(n-1,b,a+b)
+
+def fibonacci_of(n):
+	return fibonacci_aux(n,0,1)
+
+print([fibonacci_of(n) for n in range(10)])
+\end{NotebookPitonOut}
+
+\begin{codehigh}
+\begin{NotebookPitonConsole}[center]{0.75\linewidth}
+def fibonacci_aux(n,a,b):
+  if n == 0 :
+    return a
+  elif n == 1 :
+    return b
+  else:
+    return fibonacci_aux(n-1,b,a+b)
+
+def fibonacci_of(n):
+  return fibonacci_aux(n,0,1)
+
+print([fibonacci_of(n) for n in range(10)])
+\end{NotebookPitonConsole}
+\end{codehigh}
+
+\begin{NotebookPitonConsole}[center]{0.75\linewidth}
+def fibonacci_aux(n,a,b):
+	if n == 0 :
+		return a
+	elif n == 1 :
+		return b
+	else:
+		return fibonacci_aux(n-1,b,a+b)
+
+def fibonacci_of(n):
+	return fibonacci_aux(n,0,1)
+
+print([fibonacci_of(n) for n in range(10)])
+\end{NotebookPitonConsole}
+
+\pagebreak
+
+\subsection{With block In/Out}
+
+\SetJupyterLng{en}
+\SetJupyterParSkip{0.33\baselineskip}
+\setcounter{JupyterIn}{0}
+
+\begin{codehigh}
+\begin{NotebookPitonInOut}{0.75\linewidth}
+def fibonacci_aux(n,a,b):
+  if n == 0 :
+    return a
+  elif n == 1 :
+    return b
+  else:
+    return fibonacci_aux(n-1,b,a+b)
+
+def fibonacci_of(n):
+  return fibonacci_aux(n,0,1)
+
+print([fibonacci_of(n) for n in range(10)])
+\end{NotebookPitonInOut}
+\end{codehigh}
+
+\begin{NotebookPitonInOut}{0.75\linewidth}
+def fibonacci_aux(n,a,b):
+	if n == 0 :
+		return a
+	elif n == 1 :
+		return b
+	else:
+		return fibonacci_aux(n-1,b,a+b)
+
+def fibonacci_of(n):
+	return fibonacci_aux(n,0,1)
+
+print([fibonacci_of(n) for n in range(10)])
+\end{NotebookPitonInOut}
+
+\pagebreak
+
+\section{Global example}
+
+\SetJupyterParSkip{default}
+\setcounter{JupyterIn}{0}
+
+\begin{NotebookPitonMarkdown}{\linewidth}
+{\Large\bfseries This is a test for a \textsf{Markdown} block.}
+
+It's possible to use \LaTeX{} formulas, like %
+\[
+\left\lbrace\begin{array}{l}
+F_0 = 0 \: ; \: F_1 = 1 \\
+F_{n+2} = F_{n+1} + F_n
+\end{array}\right.
+\]
+\end{NotebookPitonMarkdown}
+
+\begin{NotebookPitonRaw}{\linewidth}
+This is a sample block, with RAW output.
+Just to use all capacities of Jupyter notebook ;-)
+\end{NotebookPitonRaw}
+
+\begin{NotebookPitonInOut}{\linewidth}
+def fibonacci_aux(n,a,b):
+	if n == 0 :
+		return a
+	elif n == 1 :
+		return b
+	else:
+		return fibonacci_aux(n-1,b,a+b)
+
+def fibonacci_of(n):
+	return fibonacci_aux(n,0,1)
+
+print([fibonacci_of(n) for n in range(10)])
+\end{NotebookPitonInOut}
+
+\begin{NotebookPitonRaw}{\linewidth}
+Let’s compute Fibonacci terms from 10th to 20th :-)
+\end{NotebookPitonRaw}
+
+\begin{NotebookPitonIn}{\linewidth}
+[fibonacci_of(n) for n in range(10,21)]
+\end{NotebookPitonIn}
+
+\begin{NotebookPitonConsole}{\linewidth}
+def fibonacci_aux(n,a,b):
+	if n == 0 :
+		return a
+	elif n == 1 :
+		return b
+	else:
+		return fibonacci_aux(n-1,b,a+b)
+
+def fibonacci_of(n):
+	return fibonacci_aux(n,0,1)
+
+print([fibonacci_of(n) for n in range(10,21)])
+\end{NotebookPitonConsole}
+
+\begin{NotebookPitonRaw}{\linewidth}
+Let’s work with an other function.
+This time in french :-)
+\end{NotebookPitonRaw}
+
+\begin{NotebookPitonInOut}{\linewidth}
+def calculPerimetre(cote1, cote2, cote3) :
+	perimetre = cote1 + cote2 + cote3
+	return perimetre
+
+perimetre1 = calculPerimetre(6, 4, 3)
+perimetre2 = calculPerimetre(10, 3, 11)
+print(f"Le périmètre de mon 1er triangle est {perimetre1}, et celle de mon 2d est {perimetre2}.")
+\end{NotebookPitonInOut}
+
+\begin{NotebookPitonInOut}{\linewidth}
+A = 15
+B = 10
+C = 11
+print(f"Le périmètre de mon triangle est {calculPerimetre(A, B, C)}.")
+\end{NotebookPitonInOut}
+
+\begin{NotebookPitonIn}{\linewidth}
+calculPerimetre(4, 4, 4)
+\end{NotebookPitonIn}
+
+\begin{NotebookPitonConsole}{\linewidth}
+print(calculPerimetre(4, 4, 4))
+\end{NotebookPitonConsole}
+
+\end{document}
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/pynotebook/pynotebook.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/pynotebook/pynotebook.sty	2024-02-19 20:58:35 UTC (rev 69984)
+++ trunk/Master/texmf-dist/tex/latex/pynotebook/pynotebook.sty	2024-02-19 20:58:49 UTC (rev 69985)
@@ -1,8 +1,10 @@
 % Author     : C. Pierquet
+% Thanks     : F. Pantigny (for helping with piton/pyluatex)
 % licence    : Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txtf
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{pynotebook}[2024/02/15 0.1.0 Present codes like in jupyter notebook]
+\ProvidesPackage{pynotebook}[2024/02/19 0.1.1 Present codes like in jupyter notebook]
+%0.1.1	New block In/Out
 %0.1.0	Initial version
 
 %------Usefull packages and libraries
@@ -108,6 +110,7 @@
 \NewDocumentEnvironment{NotebookIn}{ s O{} m }%
 {%
 	\SetJupyterLengths%
+	\addtolength{\LargeurNumbersJupyter}{0.5mm}%
 	\noindent%
 	\IfBooleanTF{#1}%
 		{\tcbset{tcbjpuptitlein/.style={title=\promptjupyter*{\JupyterPromptIn}{red!75!black}{\theJupyterIn}{\hspace*{\OffsetPromptJupyter}}}}}%
@@ -132,7 +135,7 @@
 \NewDocumentEnvironment{NotebookConsole}{ O{} m }%
 {%
 	\SetJupyterLengths%
-	\addtolength{\LargeurNumbersJupyter}{0.5mm}
+	\addtolength{\LargeurNumbersJupyter}{0.5mm}%
 	\noindent%
 	\tcblisting{%
 		breakable,sharp corners=all,boxrule=0.3pt,enhanced,size=small,width=#2,tcbjpuparskip,
@@ -151,7 +154,7 @@
 \NewDocumentEnvironment{NotebookOut}{ s O{} m }%
 {%
 	\SetJupyterLengths%
-	\addtolength{\LargeurNumbersJupyter}{0.5mm}
+	\addtolength{\LargeurNumbersJupyter}{0.5mm}%
 	\IfBooleanTF{#1}%
 		{\tcbset{tcbjpuptitleout/.style={title=\promptjupyter*{\JupyterPromptOut}{blue!75!black}{\theJupyterIn}{\hspace*{\OffsetPromptJupyter}}}}}%
 		{\tcbset{tcbjpuptitleout/.style={title=\promptjupyter{\JupyterPromptOut\ifnum\value{JupyterIn}<10~\fi}{blue!75!black}{\theJupyterIn}{\hspace*{\OffsetPromptJupyter}}}}}%
@@ -175,7 +178,7 @@
 \NewDocumentEnvironment{NotebookRaw}{ O{} m }%
 {%
 	\SetJupyterLengths%
-	\addtolength{\LargeurNumbersJupyter}{0.5mm}
+	\addtolength{\LargeurNumbersJupyter}{0.5mm}%
 	\noindent%
 	\tcblisting{%
 		breakable,sharp corners=all,boxrule=0.5pt,enhanced,size=small,width=#2,tcbjpuparskip,
@@ -195,7 +198,7 @@
 \NewDocumentEnvironment{NotebookMarkdown}{ O{} m }%
 {%
 	\SetJupyterLengths%
-	\addtolength{\LargeurNumbersJupyter}{0.5mm}
+	\addtolength{\LargeurNumbersJupyter}{0.5mm}%
 	\noindent%
 	\tcolorbox[breakable,sharp corners=all,boxrule=0.3pt,enhanced,size=small,width=#2,tcbjpuparskip,colframe=lightgray!15,colback=white,left skip=\LargeurPromptJupyter+\OffsetPromptJupyter-2mm,
 		attach title to upper,fontupper=\footnotesize,tcbjpuparskip,#1]%
@@ -309,6 +312,50 @@
 	\endtcolorbox%
 }%
 
+\NewDocumentEnvironment{NotebookPitonInOut}{ s O{} m }%
+{%
+	\PyLTVerbatimEnv%
+	\begin{pythonq}%
+}%
+{%
+	\end{pythonq}%
+	%
+	\SetJupiterLengths%
+	\IfBooleanTF{#1}%
+		{%
+			\tcbset{tcbjpuptitlein/.style={title=\promptjupyter*{\JupyterPromptIn}{red!75!black}{\theJupyterIn}{\hspace*{\OffsetPromptJupiter}}}}%
+		}%
+		{%
+			\refstepcounter{JupyterIn}%
+			\tcbset{tcbjpuptitlein/.style={title=\promptjupyter{\JupyterPromptIn\ifnum\value{JupyterIn}<10~\fi}{red!75!black}{\theJupyterIn}{\hspace*{\OffsetPromptJupiter}}}}%
+		}%
+	\noindent%
+	\tcolorbox[breakable,sharp corners=all,boxrule=0.5pt,enhanced,size=small,width=#3,colframe=gray,colback=lightgray!15,left skip=\LargeurPromptJupiter+\OffsetPromptJupiter-2mm,tcbjpuptitlein,fonttitle=\linespread{1}\footnotesize,
+	attach title to upper,fontupper=\footnotesize,overlay={\begin{tcbclipinterior}\draw[line width=0.375pt,gray!75] ([xshift={\LargeurNumbersJupiter+2.25mm}]frame.south west)--([xshift={\LargeurNumbersJupiter+2.25mm}]frame.north west) ;\end{tcbclipinterior}},bottom=-0.5mm,tcbjpuparskip,#2]%
+	\directlua{%
+		tex.print("\\begin{Piton}[left-margin=\\LargeurNumbersJupiter+1.75mm,all-line-numbers,tabs-auto-gobble,break-lines,indent-broken-lines]")
+		tex.print(pyluatex.get_last_code())
+		tex.print("\\end{Piton}")
+	}%
+	\endtcolorbox%
+	\IfBooleanTF{#1}%
+		{%
+			\tcbset{tcbjpuptitleout/.style={title=\promptjupyter*{\JupyterPromptOut}{blue!75!black}{\theJupyterIn}{\hspace*{\OffsetPromptJupiter}}}}%
+		}%
+		{%
+			\tcbset{tcbjpuptitleout/.style={title=\promptjupyter{\JupyterPromptOut\ifnum\value{JupyterIn}<10~\fi}{blue!75!black}{\theJupyterIn}{\hspace*{\OffsetPromptJupiter}}}}%
+		}%
+	\tcbset{reset}%
+	\noindent%
+	\tcolorbox[breakable,sharp corners = all,boxrule=0.3pt,enhanced,size=small,width=#3,colframe=lightgray!15,colback=white,left skip=\LargeurPromptJupiter+\OffsetPromptJupiter-2mm,tcbjpuptitleout,fonttitle=\linespread{1}\footnotesize,attach title to upper,fontupper=\footnotesize,bottom=-0.5mm,tcbjpuparskip,#2]%
+	\directlua{%
+		tex.print("\\begin{Piton}[tabs-auto-gobble,break-lines,indent-broken-lines]")
+		tex.print(pyluatex.get_last_output())
+		tex.print("\\end{Piton}")
+	}%
+	\endtcolorbox%
+}
+
 \fi
 \fi
 



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