diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/pynotebook/pynotebook.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/pynotebook/pynotebook.sty | 192 |
1 files changed, 157 insertions, 35 deletions
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 |