diff options
author | Karl Berry <karl@freefriends.org> | 2024-03-30 19:55:01 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-03-30 19:55:01 +0000 |
commit | 806bb58716423a6f1170989fb6ce5c4be2529a2e (patch) | |
tree | c34dda2b67a9830924f793e5e9dc09bba5ce5781 /Master | |
parent | fce96fb14ef55dc09927cf3fb882415b73dd8953 (diff) |
pynotebook (30mar24)
git-svn-id: svn://tug.org/texlive/trunk@70818 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.pdf | bin | 436049 -> 436863 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.tex | 40 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.pdf | bin | 83036 -> 103153 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.tex | 42 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/pynotebook/pynotebook.sty | 192 |
5 files changed, 229 insertions, 45 deletions
diff --git a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.pdf b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.pdf Binary files differindex e64acd414c1..47e8ae1f0ec 100644 --- a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.pdf +++ b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.pdf diff --git a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.tex b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.tex index ca6d4511e1d..b721cb848d6 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.1} -\def\TPdate{19/02/2024} +\def\TPversion{0.1.3} +\def\TPdate{30/03/2024} \sethlcolor{lightgray!25} \NewDocumentCommand\ShowCode{ m }{% @@ -189,6 +189,10 @@ Recommencer [o/n] ? n \section{History} +\verb|v0.1.3|~:~~~~Modification with \texttt{gobble} (for \textsf{piton}) + +\verb|v0.1.2|~:~~~~Enhancements with \texttt{gobble} (for \textsf{piton}) + \verb|v0.1.1|~:~~~~New block \textsf{In/Out} with \textsf{piton/pyluatex} (tks to F. Pantigny) \verb|v0.1.0|~:~~~~Initial version @@ -474,25 +478,37 @@ The package provides environments : \end{itemize} \begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] -\begin{NotebookPitonIn}(*)[options tcbox]{<width>} +\begin{NotebookPitonRaw}[options tcbox]{width}<gobble options> +<code> +\end{NotebookPitonRaw} +\end{codehigh} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +\begin{NotebookPitonMarkdown}[options tcbox]{width} +<code> +\end{NotebookPitonMarkdown} +\end{codehigh} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +\begin{NotebookPitonIn}(*)[options tcbox]{width}<gobble options> <code> \end{NotebookPitonIn} \end{codehigh} \begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] -\begin{NotebookPitonOut}(*)[options tcbox]{<width>} +\begin{NotebookPitonOut}(*)[options tcbox]{width}<gobble options> <code> \end{NotebookPitonOut} \end{codehigh} \begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] -\begin{NotebookPitonInOut}(*)[options tcbox]{<width>} +\begin{NotebookPitonInOut}(*)[options tcbox]{width}<gobble options> <code> \end{NotebookPitonInOut} \end{codehigh} \begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] -\begin{NotebookPitonConsole}[options tcbox]{<width>} +\begin{NotebookPitonConsole}[options tcbox]{width}<gobble options> <code> \end{NotebookPitonConsole} \end{codehigh} @@ -501,6 +517,18 @@ The starred versions removes the counter, and don't display it. The blocks with \textit{header} (\texttt{In/Out}) are automatically numbered, and the global style is fixed. +\smallskip + +\texttt{gobble options} are given within \textsf{piton} syntax : + +\begin{itemize} + \item \texttt{auto-gobble} ; + \item \texttt{env-gobble} ; + \item \texttt{gobble=xx} ; + \item \texttt{tabs-auto-gobble} ; + \item a mix of them. +\end{itemize} + \subsection{Examples} Due to the necessary usage of \hologo{LuaLaTeX} and \textsf{--shell-escape}, examples are given in a separate 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 Binary files differindex f5a8cfb3313..5a816e5ebaa 100644 --- a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.pdf +++ b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.pdf diff --git a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.tex b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.tex index 6dfdc9bd531..34112ed0c77 100644 --- a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.tex +++ b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpyluatex.tex @@ -3,7 +3,7 @@ % 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} +\def\PLver{0.1.3} \usepackage[margin=1.5cm]{geometry} \usepackage{pynotebook} \usepackage[executable=python]{pyluatex} @@ -21,6 +21,23 @@ \usepackage[executable=python]{pyluatex} % with a specific compilation !! \end{codehigh} +\section{With gobble} + +Due to \texttt{gobble} options with \textsf{piton}, it's possible to add \texttt{gobble} parameters to the environments, given within last argument between \texttt{<...>}, and default is \texttt{empty} : + +\begin{itemize} + \item \texttt{<gobble=xx>} ; + \item \texttt{<env-gobble>} ; + \item \texttt{<auto-gobble>} ; + \item \texttt{<tabs-auto-gobble>}. +\end{itemize} + +\noindent{}\textbf{Explanations} are given in the doc of \textsf{piton} : + +\begin{itemize} + \item \texttt{https://ctan.org/pkg/piton} +\end{itemize} + \section{Examples of text blocks} \begin{codehigh} @@ -116,7 +133,7 @@ print([fibonacci_of(n) for n in range(10)]) \end{NotebookPitonOut} \end{codehigh} -\begin{NotebookPitonOut}{\linewidth} +\begin{NotebookPitonOut}{0.75\linewidth} def fibonacci_aux(n,a,b): if n == 0 : return a @@ -279,6 +296,20 @@ def fibonacci_of(n): print([fibonacci_of(n) for n in range(10)]) \end{NotebookPitonInOut} +\subsection{Alternate environment for In/Out} + +Thanks to F. Pantigny, an alternate environment for \texttt{In/Out} is available, with \textit{all} line numbers and continuation symbol. + +\begin{codehigh} +\begin{NotebookPitonAllNum}{0.66\linewidth} +print([i**2 for i in range(50)]) +\end{NotebookPitonAllNum} +\end{codehigh} + +\begin{NotebookPitonAllNum}{0.66\linewidth} +print([i**2 for i in range(50)]) +\end{NotebookPitonAllNum} + \pagebreak \section{Global example} @@ -353,14 +384,14 @@ def calculPerimetre(cote1, cote2, cote3) : 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}.") +print(f"Le périm de mon 1er triangle est {perimetre1}, et celui 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)}.") +print(f"Le périmètre de mon triangle est {calculPerimetre(A,B,C)}.") \end{NotebookPitonInOut} \begin{NotebookPitonIn}{\linewidth} @@ -371,4 +402,7 @@ calculPerimetre(4, 4, 4) print(calculPerimetre(4, 4, 4)) \end{NotebookPitonConsole} +\begin{NotebookPitonInOut}{0.5\linewidth} +print([i**2 for i in range(50)]) +\end{NotebookPitonInOut} \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 f899c44b15d..242c6c09886 100644 --- a/Master/texmf-dist/tex/latex/pynotebook/pynotebook.sty +++ b/Master/texmf-dist/tex/latex/pynotebook/pynotebook.sty @@ -3,7 +3,9 @@ % 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/19 0.1.1 Present codes like in jupyter notebook] +\ProvidesPackage{pynotebook}[2024/03/30 0.1.3 Present codes like in jupyter notebook] +%0.1.3 Modification with gobble (piton) +%0.1.2 Enhancement with gobble and new code for in/out with all numbers lines %0.1.1 New block In/Out %0.1.0 Initial version @@ -116,7 +118,7 @@ {\tcbset{tcbjpuptitlein/.style={title=\promptjupyter*{\JupyterPromptIn}{red!75!black}{\theJupyterIn}{\hspace*{\OffsetPromptJupyter}}}}}% {\refstepcounter{JupyterIn}\tcbset{tcbjpuptitlein/.style={title=\promptjupyter{\JupyterPromptIn\ifnum\value{JupyterIn}<10~\fi}{red!75!black}{\theJupyterIn}{\hspace*{\OffsetPromptJupyter}}}}}% \tcblisting{% - breakable,sharp corners=all,boxrule=0.5pt,enhanced,size=small,width=#3,tcbjpuparskip, + breakable,sharp corners=all,enhanced,size=small,width=#3,tcbjpuparskip,boxrule=0.5pt, colframe=gray,colback=lightgray!15, left skip=\LargeurPromptJupyter+\OffsetPromptJupyter-2mm, tcbjpuptitlein, @@ -124,7 +126,7 @@ attach title to upper, listing only, listing options={style=PLJupyter,xleftmargin=\LargeurNumbersJupyter,numbers=left,firstnumber=1,numbersep=2mm},% - overlay={\begin{tcbclipinterior}\draw[line width=0.375pt,gray!75] ([xshift={\LargeurNumbersJupyter+1mm}]frame.south west)--([xshift={\LargeurNumbersJupyter+1mm}]frame.north west);\end{tcbclipinterior}},% + overlay={\begin{tcbclipinterior}\draw[line width=0.5pt,gray] ([xshift={\LargeurNumbersJupyter+1mm}]frame.south west)--([xshift={\LargeurNumbersJupyter+1mm}]frame.north west);\end{tcbclipinterior}},% #2 }% }% @@ -138,8 +140,8 @@ \addtolength{\LargeurNumbersJupyter}{0.5mm}% \noindent% \tcblisting{% - breakable,sharp corners=all,boxrule=0.3pt,enhanced,size=small,width=#2,tcbjpuparskip, - colframe=lightgray!15,colback=white, + breakable,sharp corners=all,enhanced,size=small,width=#2,tcbjpuparskip,boxrule=0.5pt, + colframe=lightgray!25,colback=white, left skip=\LargeurPromptJupyter+\OffsetPromptJupyter-2mm, attach title to upper, listing only, @@ -160,8 +162,8 @@ {\tcbset{tcbjpuptitleout/.style={title=\promptjupyter{\JupyterPromptOut\ifnum\value{JupyterIn}<10~\fi}{blue!75!black}{\theJupyterIn}{\hspace*{\OffsetPromptJupyter}}}}}% \noindent% \tcblisting{% - breakable,sharp corners=all,boxrule=0.3pt,enhanced,size=small,width=#3,tcbjpuparskip, - colframe=lightgray!15,colback=white, + breakable,sharp corners=all,enhanced,size=small,width=#3,tcbjpuparskip,boxrule=0.5pt, + colframe=lightgray!25,colback=white, left skip=\LargeurPromptJupyter+\OffsetPromptJupyter-2mm, tcbjpuptitleout, fonttitle=\linespread{1}\footnotesize, @@ -181,13 +183,13 @@ \addtolength{\LargeurNumbersJupyter}{0.5mm}% \noindent% \tcblisting{% - breakable,sharp corners=all,boxrule=0.5pt,enhanced,size=small,width=#2,tcbjpuparskip, + breakable,sharp corners=all,enhanced,size=small,width=#2,tcbjpuparskip,boxrule=0.5pt, colframe=gray,colback=lightgray!15, left skip=\LargeurPromptJupyter+\OffsetPromptJupyter-2mm, attach title to upper, listing only, listing options={style=tcblatex,basicstyle=\ttfamily\footnotesize,numberstyle=\scriptsize\ttfamily\color{gray},xleftmargin=\LargeurNumbersJupyter,numbers=left,firstnumber=1,numbersep=2mm},% - overlay={\begin{tcbclipinterior}\draw[line width=0.375pt,gray!75] ([xshift={\LargeurNumbersJupyter+1mm}]frame.south west)--([xshift={\LargeurNumbersJupyter+1mm}]frame.north west);\end{tcbclipinterior}},% + overlay={\begin{tcbclipinterior}\draw[line width=0.5pt,gray] ([xshift={\LargeurNumbersJupyter+1mm}]frame.south west)--([xshift={\LargeurNumbersJupyter+1mm}]frame.north west);\end{tcbclipinterior}},% #1 }% }% @@ -200,7 +202,7 @@ \SetJupyterLengths% \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, + \tcolorbox[breakable,sharp corners=all,enhanced,size=small,boxrule=0.5pt,width=#2,tcbjpuparskip,colframe=lightgray!25,colback=white,left skip=\LargeurPromptJupyter+\OffsetPromptJupyter-2mm, attach title to upper,fontupper=\footnotesize,tcbjpuparskip,#1]% }% {% @@ -211,7 +213,7 @@ %----With Piton (only lualatex) \ifluatex \RequirePackage{piton} -\RequirePackage{environ} +%\RequirePackage{environ} \newlength{\LargeurPromptJupiter} \newlength{\LargeurPromptJupiterIn} \newlength{\LargeurPromptJupiterOut} @@ -226,31 +228,32 @@ \settowidth{\LargeurNumbersJupiter}{\footnotesize\texttt{00}}% } -\NewPitonEnvironment{NotebookPitonIn}{ s O{} m }% +\NewPitonEnvironment{NotebookPitonIn}{ s O{} m !D<>{} }% {% \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% - \PitonOptions{left-margin={\LargeurNumbersJupiter+1.75mm},all-line-numbers}% - \PitonOptions{tabs-auto-gobble,break-lines,indent-broken-lines}% + \PitonOptions{left-margin={\LargeurNumbersJupiter+1.75mm},line-numbers={skip-empty-lines=false,label-empty-lines=true}}% + \PitonOptions{break-lines,indent-broken-lines,continuation-symbol={},#4}% %on crée la boîte - \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]% + \tcolorbox[size=small,breakable,sharp corners=all,boxrule=0.5pt,enhanced,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.5pt,gray] ([xshift={\LargeurNumbersJupiter+2.25mm}]frame.south west)--([xshift={\LargeurNumbersJupiter+2.25mm}]frame.north west);\end{tcbclipinterior}},bottom=-0.5mm,top=0.5mm,tcbjpuparskip,#2]% }% {% \endtcolorbox% + \ignorespacesafterend% } -\NewDocumentEnvironment{NotebookPitonConsole}{ O{} m }% +\NewDocumentEnvironment{NotebookPitonConsole}{ O{} m !D<>{} }% {% \SetJupiterLengths% \noindent% - \PitonOptions{tabs-auto-gobble,break-lines,indent-broken-lines}% + \PitonOptions{width={#2-5mm-\LargeurPromptJupiter-\OffsetPromptJupiter+2mm},break-lines,end-of-broken-line={},continuation-symbol={},#3}% %on crée la boîte \PyLTVerbatimEnv% - \tcolorbox[breakable,sharp corners=all,boxrule=0.3pt,enhanced,size=small,width=#2,colframe=lightgray!15,colback=white,left skip=\LargeurPromptJupiter+\OffsetPromptJupiter-2mm,attach title to upper,fontupper=\footnotesize,bottom=-0.5mm,tcbjpuparskip,#1]% + \tcolorbox[breakable,sharp corners=all,enhanced,size=small,boxrule=0.5pt,width=#2,colframe=lightgray!25,colback=white,left skip=\LargeurPromptJupiter+\OffsetPromptJupiter-2mm,attach title to upper,fontupper=\footnotesize,bottom=-0.5mm,tcbjpuparskip,#1]% \begin{pythonq}% }% {% @@ -261,19 +264,20 @@ tex.print("\\end{Piton}") }% \endtcolorbox% + \ignorespacesafterend% } -\NewDocumentEnvironment{NotebookPitonOut}{ s O{} m }% +\NewDocumentEnvironment{NotebookPitonOut}{ s O{} m !D<>{} }% {% \SetJupiterLengths% \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}}}}}% \noindent% - \PitonOptions{tabs-auto-gobble,break-lines,indent-broken-lines}% + \PitonOptions{continuation-symbol={},end-of-broken-line={},break-lines,#4}% %on crée la boîte \PyLTVerbatimEnv% - \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]% + \tcolorbox[breakable,sharp corners=all,enhanced,size=small,boxrule=0.5pt,width=#3,colframe=lightgray!25,colback=white,left skip=\LargeurPromptJupiter+\OffsetPromptJupiter-2mm,tcbjpuptitleout,fonttitle=\linespread{1}\footnotesize,attach title to upper,fontupper=\footnotesize,bottom=-0.5mm,top=0.5mm,tcbjpuparskip,#2]% \begin{pythonq}% }% {% @@ -284,42 +288,44 @@ tex.print("\\end{Piton}") }% \endtcolorbox% + \ignorespacesafterend% } -\NewPitonEnvironment{NotebookPitonRaw}{ O{} m }% +\NewPitonEnvironment{NotebookPitonRaw}{ O{} m !D<>{} }% {% \SetJupiterLengths% \noindent% \SetPitonStyle{Number=}% - \PitonOptions{left-margin={\LargeurNumbersJupiter+1.75mm},all-line-numbers,language=minimal}% - \PitonOptions{tabs-auto-gobble,break-lines,indent-broken-lines}% + \PitonOptions{left-margin={\LargeurNumbersJupiter+1.75mm},line-numbers={skip-empty-lines=false,label-empty-lines=true},language=minimal}% + \PitonOptions{continuation-symbol={},break-lines,indent-broken-lines,#3}% %on crée la boîte - \tcolorbox[breakable,sharp corners=all,boxrule=0.5pt,enhanced,size=small,width=#2,colframe=gray,colback=lightgray!15,left skip=\LargeurPromptJupiter+\OffsetPromptJupiter-2mm,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,#1]% + \tcolorbox[breakable,sharp corners=all,enhanced,size=small,boxrule=0.5pt,width=#2,colframe=gray,colback=lightgray!25,left skip=\LargeurPromptJupiter+\OffsetPromptJupiter-2mm,attach title to upper,fontupper=\footnotesize,overlay={% + \begin{tcbclipinterior}\draw[line width=0.5pt,gray] ([xshift={\LargeurNumbersJupiter+2.25mm}]frame.south west)--([xshift={\LargeurNumbersJupiter+2.25mm}]frame.north west);\end{tcbclipinterior}},bottom=-0.5mm,tcbjpuparskip,#1]% }% {% \endtcolorbox% + \ignorespacesafterend% } \NewDocumentEnvironment{NotebookPitonMarkdown}{ O{} m }% {% \SetJupiterLengths% \noindent% - \tcolorbox[breakable,sharp corners=all,boxrule=0.3pt,enhanced,size=small,width=#2,tcbjpuparskip,colframe=lightgray!15,colback=white,left skip=\LargeurPromptJupiter+\OffsetPromptJupiter-2mm, + \tcolorbox[breakable,sharp corners=all,enhanced,size=small,boxrule=0.5pt,width=#2,tcbjpuparskip,colframe=lightgray!25,colback=white,left skip=\LargeurPromptJupiter+\OffsetPromptJupiter-2mm, attach title to upper,fontupper=\footnotesize,tcbjpuparskip,#1]% }% {% \endtcolorbox% + \ignorespacesafterend% }% -\NewDocumentEnvironment{NotebookPitonInOut}{ s O{} m }% +\NewDocumentEnvironment{NotebookPitonInOut}{ s O{} m !D<>{} }% {% \PyLTVerbatimEnv% \begin{pythonq}% }% {% \end{pythonq}% - % \SetJupiterLengths% \IfBooleanTF{#1}% {% @@ -330,10 +336,11 @@ \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]% + \tcolorbox[breakable,sharp corners=all,enhanced,size=small,boxrule=0.5pt,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.5pt,gray] ([xshift={\LargeurNumbersJupiter+2.25mm}]frame.south west)--([xshift={\LargeurNumbersJupiter+2.25mm}]frame.north west) ;\end{tcbclipinterior}},bottom=-0.5mm,top=0.5mm,tcbjpuparskip,#2]% + %\PitonOptions{width={#3-5mm}} \directlua{% - tex.print("\\begin{Piton}[left-margin=\\LargeurNumbersJupiter+1.75mm,all-line-numbers,tabs-auto-gobble,break-lines,indent-broken-lines]") + tex.print("\\begin{Piton}[left-margin=\\LargeurNumbersJupiter+1.75mm,line-numbers={skip-empty-lines=false,label-empty-lines=true},break-lines,indent-broken-lines,continuation-symbol={},#4]") tex.print(pyluatex.get_last_code()) tex.print("\\end{Piton}") }% @@ -347,13 +354,128 @@ }% \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]% + \tcolorbox[breakable,sharp corners = all,enhanced,size=small,boxrule=0.5pt,width=#3,colframe=lightgray!25,colback=white,left skip=\LargeurPromptJupiter+\OffsetPromptJupiter-2mm,tcbjpuptitleout,fonttitle=\linespread{1}\footnotesize,attach title to upper,fontupper=\footnotesize,bottom=-0.5mm,top=0.5mm,tcbjpuparskip,#2]% + %\PitonOptions{width={#3-5mm-\LargeurPromptJupiter-\OffsetPromptJupiter+2mm}} \directlua{% - tex.print("\\begin{Piton}[tabs-auto-gobble,break-lines,indent-broken-lines]") + tex.print("\\begin{Piton}[break-lines,continuation-symbol={},end-of-broken-line={},#4]") tex.print(pyluatex.get_last_output()) tex.print("\\end{Piton}") }% \endtcolorbox% + \ignorespacesafterend% +} + +\NewPitonEnvironment{NotebookPitonAllNum}{ s O{} m !D<>{} }% +{% +\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 +\PitonOptions +{ +left-margin = \LargeurNumbersJupiter + 1.75mm , +all-line-numbers, +break-lines, +indent-broken-lines, +continuation-symbol={}, +#4 +}% +\tcolorbox[breakable, + sharp corners=all, + enhanced, + size = small, + boxrule = 0.5pt, + 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.5pt,gray] + ([xshift={\LargeurNumbersJupiter+2.25mm}]frame.south west) + --([xshift={\LargeurNumbersJupiter+2.25mm}]frame.north west) ; + \end{tcbclipinterior}}, + bottom = -0.5mm, + tcbjpuparskip, + #2]% +} +{ +\endtcolorbox +% +\tcbset{reset}% +\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}} + } +}% +}% +\tcolorbox[breakable, + sharp corners = all, + enhanced, + size = small, + boxrule = 0.5pt, + width = #3, + colframe = lightgray!25, + colback = white, + left skip = \LargeurPromptJupiter + \OffsetPromptJupiter - 2mm, + tcbjpuptitleout, + fonttitle = \linespread{1}\footnotesize, + attach title to upper, + fontupper = \footnotesize, + overlay = {% + \begin{tcbclipinterior} + \draw[line width=0.5pt,lightgray!15] + ([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}") +tex.print(pyluatex.execute(piton.get_last_code(), false, true, false, true)) +tex.print("\\end{Piton}") +}% +\endtcolorbox% } \fi |