summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-02-19 20:58:49 +0000
committerKarl Berry <karl@freefriends.org>2024-02-19 20:58:49 +0000
commitc575fe89761773b749dd54b1adf9b29301927fc1 (patch)
tree3efd0554ab4941c9262b866bb1dc8ddb8875bc47
parent264909756b83341b55bc72b898091b64652aafce (diff)
pynotebook (19feb24)
git-svn-id: svn://tug.org/texlive/trunk@69985 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.pdfbin392958 -> 436049 bytes
-rw-r--r--Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.tex213
-rw-r--r--Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.pdfbin74884 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.tex239
-rw-r--r--Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.pdfbin0 -> 83036 bytes
-rw-r--r--Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.tex374
-rw-r--r--Master/texmf-dist/tex/latex/pynotebook/pynotebook.sty57
7 files changed, 581 insertions, 302 deletions
diff --git a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.pdf b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.pdf
index d688335cf97..e64acd414c1 100644
--- a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.pdf
+++ b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.tex b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.tex
index ef408c246b1..ca6d4511e1d 100644
--- a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.tex
+++ b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.tex
@@ -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 @@ Just to use all capacities of Jupyter notebook ;-)
\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 @@ def fibonacci_of(n) :
%
%\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 @@ def fibonacci_of(n) :
\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 @@ The blocks with \textit{header} (\texttt{In/Out}) are automatically numbered, an
\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)
-
-[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)
+
+[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}
-\begin{NotebookIn}{\linewidth}
-def fibonacci_of(n) :
- if n in {0,1} :
- return n
- return fibonacci_of(n-1) + fibonacci_of(n-2)
+\pagebreak
-[fibonacci_of(n) for n in range(15)]
+\begin{NotebookIn}{\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{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)
-
-[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)
+
+[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 @@ The package provides environments :
\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 @@ The package provides environments :
\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 @@ Due to the necessary usage of \hologo{LuaLaTeX} and \textsf{--shell-escape}, exa
\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 @@ The package provides to macro, in order to :
\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 @@ def fibonacci_of(n) :
\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)
-
-[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)
+
+[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
diff --git a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.pdf b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.pdf
deleted file mode 100644
index 7869f7ff323..00000000000
--- a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.tex b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.tex
deleted file mode 100644
index 86123fccfa4..00000000000
--- a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.tex
+++ /dev/null
@@ -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
diff --git a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.pdf b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.pdf
new file mode 100644
index 00000000000..f5a8cfb3313
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.tex b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.tex
new file mode 100644
index 00000000000..6dfdc9bd531
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.tex
@@ -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
diff --git a/Master/texmf-dist/tex/latex/pynotebook/pynotebook.sty b/Master/texmf-dist/tex/latex/pynotebook/pynotebook.sty
index 6a84f42a6bf..f899c44b15d 100644
--- a/Master/texmf-dist/tex/latex/pynotebook/pynotebook.sty
+++ b/Master/texmf-dist/tex/latex/pynotebook/pynotebook.sty
@@ -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