diff options
author | Karl Berry <karl@freefriends.org> | 2024-02-16 21:06:30 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-02-16 21:06:30 +0000 |
commit | 6eba0f2ddc69d22154f045e2795972107832121f (patch) | |
tree | 9015caf0edd24092fe70b7f96179b5b9170c2d4d /Master/texmf-dist/doc/latex | |
parent | 7d41c56dca4a7b341a662744f327fb9f4e4ce0ab (diff) |
pynotebook (16feb24)
git-svn-id: svn://tug.org/texlive/trunk@69909 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex')
-rw-r--r-- | Master/texmf-dist/doc/latex/pynotebook/README.md | 6 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.pdf | bin | 0 -> 392958 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.tex | 482 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.pdf | bin | 0 -> 74884 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.tex | 239 |
5 files changed, 727 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/pynotebook/README.md b/Master/texmf-dist/doc/latex/pynotebook/README.md new file mode 100644 index 00000000000..e291f076eda --- /dev/null +++ b/Master/texmf-dist/doc/latex/pynotebook/README.md @@ -0,0 +1,6 @@ +pynotebook is a package to present (raw, markdown or python) codes (and execution with lualatex) as in a jupyter notebook. +-------------------------------------------------------------------------------------------------------------------------- + +Author....: Cédric Pierquet +email.....: cpierquet@outlook.fr +Licence...: Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txt diff --git a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.pdf b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.pdf Binary files differnew file mode 100644 index 00000000000..d688335cf97 --- /dev/null +++ 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 new file mode 100644 index 00000000000..ef408c246b1 --- /dev/null +++ b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-doc.tex @@ -0,0 +1,482 @@ +% !TeX TXS-program:compile = txs:///arara +% arara: pdflatex: {shell: no, synctex: no, interaction: batchmode} +% arara: pdflatex: {shell: no, synctex: no, interaction: batchmode} if found('log', '(undefined references|Please rerun|Rerun to get)') + +\documentclass[english,11pt,a4paper]{article} +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{pynotebook} +\usepackage{enumitem} +\usepackage{soul} +\usepackage{codehigh} +\usepackage{multicol} +\usepackage{fontawesome5} +\usepackage{fancyvrb} +\usepackage{fancyhdr} +\fancyhf{} +\renewcommand{\headrulewidth}{0pt} +%\rhead{\sffamily\small\affloetalab[Legende]} +\lfoot{\sffamily\small [pynotebook]} +\cfoot{\sffamily\small - \thepage{} -} +\rfoot{\hyperlink{matoc}{\small\faArrowAltCircleUp[regular]}} +\usepackage{hologo} +\usepackage{xspace} +\providecommand\tikzlogo{Ti\textit{k}Z} +\providecommand\TeXLive{\TeX{}Live\xspace} +\providecommand\PSTricks{\textsf{PSTricks}\xspace} +\let\pstricks\PSTricks +\let\TikZ\tikzlogo + +\usepackage{hyperref} +\urlstyle{same} +\hypersetup{pdfborder=0 0 0} +\usepackage[margin=2cm]{geometry} +\setlength{\parindent}{0pt} + +\def\TPversion{0.1.0} +\def\TPdate{15/02/2024} + +\sethlcolor{lightgray!25} +\NewDocumentCommand\ShowCode{ m }{% + \hl{\vphantom{\texttt{pf}}\texttt{#1}}% +} + +\usepackage{babel} + +\begin{document} + +\pagestyle{fancy} + +\thispagestyle{empty} + +\begin{center} + \begin{minipage}{0.88\linewidth} + \begin{tcolorbox}[colframe=yellow,colback=yellow!15] + \begin{center} + \begin{tabular}{c} + {\Huge \texttt{pynotebook}}\\ + \\ + {\LARGE Present a Jupyter notebook, with} \\ + {\LARGE tcolorbox, and listings or piton/pyluatex.} \\ + \\ + {\small \texttt{Version \TPversion{} -- \TPdate}} + \end{tabular} + \end{center} + \end{tcolorbox} +\end{minipage} +\end{center} + +\begin{center} + \begin{tabular}{c} + \texttt{Cédric Pierquet}\\ + {\ttfamily c pierquet -- at -- outlook . fr}\\ + \texttt{\url{https://github.com/cpierquet/pynotebook}} +\end{tabular} +\end{center} + +\hrule + +\phantomsection + +\hypertarget{matoc}{} + +\tableofcontents + +\vspace*{5mm} + +\hrule + +\vspace*{5mm} + +\vfill~ + +\pagebreak + +\section{Samples, with listings} + +\begin{NotebookMarkdown}{\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{NotebookMarkdown} + +\begin{NotebookRaw}{\linewidth} +This is a sample block, with RAW output. + +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)] +\end{NotebookIn} + +\begin{NotebookOut}{\linewidth} +[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377] +\end{NotebookOut} + +%\vspace*{5mm} +% +%\begin{center} +% With \ShowCode{piton} and \ShowCode{pyluatex} (with code execution, but with \hologo{LuaLaTeX} and \textsf{--shell-escape}) : +%\end{center} +% +%\includegraphics[clip]{pynotebook-samples-pitonpyluatex.pdf} + +\vfill~ + +\section{History} + +\verb|v0.1.0|~:~~~~Initial version + +\vspace*{15mm} + +\pagebreak + +\section{The package pynotebook} + +\subsection{Ideas} + +The idea is to provides environments to reproduce a Jupyter notebook : + +\begin{itemize} + \item with \textit{blocks} for \textsf{RAW} or \textsf{Markdown} ; + \item with \ShowCode{listings} and no limitation with compiler, but without code execution ; + \item with \ShowCode{piton} and \ShowCode{pyluatex} with \hologo{LuaLaTeX} and \textsf{--shell-escape}. +\end{itemize} + +The documentation use \hologo{pdfLaTeX}, but examples with \hologo{LuaLaTeX} are given in an other doc. + +\subsection{Loading} + +The package loads within the preamble, with \ShowCode{\textbackslash usepackage\{pynotebook\}}. + +The loaded packages are \ShowCode{tcolorbox} (with \ShowCode{skins,breakable,listings}), \ShowCode{calc}, \ShowCode{xstring} and \ShowCode{iftex}. + +If \hologo{LuaLaTeX} is detected, \ShowCode{piton} is loaded (but there's an option to avoid the loading), whereas \ShowCode{pyluatex} needs to be manually loaded, due to the declaration of the executable. + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +%with pdflatex +\usepackage{pynotebook} +\end{codehigh} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +%with LuaLaTeX and piton +\usepackage{pynotebook} +\usepackage[options]{pyluatex} +\end{codehigh} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +%with LuaLaTeX but without piton capability +\usepackage[nopiton]{pynotebook} +\end{codehigh} + +\subsection{Global usage} + +In order to respect the left-alignment, the \textit{titles} \ShowCode{In [ ]} and \ShowCode{Out[ ]} can add a blank character, to avoid offset due to counter with two digits ! + +\pagebreak + +\section{Common text blocks} + +\subsection{Intro} + +The different text blocks are given with their own output. + +The package provides environments : + +\begin{itemize} + \item for a \textsf{RAW} block, with \texttt{teletype} font ; for a \textsf{Mardown} block, with all \hologo{LaTeX} support ; + \item a version with \textsf{piton} is given, in order to align perfectly the blocks ! +\end{itemize} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +\begin{NotebookRaw}[options tcbox]{<width>} +<code> +\end{NotebookRaw} +\end{codehigh} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +\begin{NotebookMarkdown}[options tcbox]{<width>} +<code> +\end{NotebookMarkdown} +\end{codehigh} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +\begin{NotebookPitonRaw}[options tcbox]{<width>} +<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} + +\subsection{Examples} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +\begin{NotebookMarkdown}{\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{NotebookMarkdown} + +\begin{NotebookRaw}{\linewidth} +This is a sample block, with RAW output. + +Just to use all capacities of Jupyter notebook ;-) +\end{NotebookRaw} +\end{codehigh} + +\begin{NotebookMarkdown}{\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{NotebookMarkdown} + +\begin{NotebookRaw}{\linewidth} +This is a sample block, with RAW output. + +Just to use all capacities of Jupyter notebook ;-) +\end{NotebookRaw} + +\pagebreak + +\section{The code blocks, with listings} + +\subsection{Intro} + +With \ShowCode{listings}, the different blocks are given with their own output (no code execution). + +The package provides environments : + +\begin{itemize} + \item with \texttt{In~[...]} ; + \item with \texttt{Out[...]} ; + \item without \textit{header}, eg for a \textit{console execution}. +\end{itemize} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +\begin{NotebookIn}(*)[options tcbox]{<width>} +<code> +\end{NotebookIn} +\end{codehigh} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +\begin{NotebookOut}(*)[options tcbox]{<width>} +<code> +\end{NotebookOut} +\end{codehigh} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +\begin{NotebookConsole}[options tcbox]{<width>} +<code> +\end{NotebookConsole} +\end{codehigh} + +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. + +\subsection{Examples} + +\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)] +\end{NotebookIn} + +\begin{NotebookOut}{\linewidth} +[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377] +\end{NotebookOut} + +\begin{NotebookConsole}{\linewidth} +[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377] +\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) + +[fibonacci_of(n) for n in range(15)] +\end{NotebookIn} + +\begin{NotebookOut}{\linewidth} +[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377] +\end{NotebookOut} + +\begin{NotebookConsole}{\linewidth} +[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377] +\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) + +\end{NotebookIn} + +\begin{NotebookOut}*[flush right]{13cm} +[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377] +\end{NotebookOut} + +\begin{NotebookConsole}[flush right]{13cm} +[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377] +\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)] +\end{NotebookIn} + +\begin{NotebookOut}*[flush right]{13cm} +[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377] +\end{NotebookOut} + +\begin{NotebookConsole}[flush right]{13cm} +[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377] +\end{NotebookConsole} + +\pagebreak + +\section{The code blocks, with piton and pyluatex} + +\subsection{Intro} + +With \ShowCode{piton} and \ShowCode{pyluatex}, the different blocks are given with the code to be displayed (\texttt{In/Out}) or with the code to be executed (\textsf{Out} or \textsf{Console}). + +The package provides environments : + +\begin{itemize} + \item with \texttt{In~[...]} ; + \item with \texttt{Out[...]} ; + \item without \textit{header}, eg for a \textit{console execution}. +\end{itemize} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +\begin{NotebookPitonIn}(*)[options tcbox]{<width>} +<code> +\end{NotebookPitonIn} +\end{codehigh} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +\begin{NotebookPitonOut}(*)[options tcbox]{<width>} +<code> +\end{NotebookPitonOut} +\end{codehigh} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +\begin{NotebookPitonConsole}[options tcbox]{<width>} +<code> +\end{NotebookPitonConsole} +\end{codehigh} + +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. + +\subsection{Examples} + +Due to the necessary usage of \hologo{LuaLaTeX} and \textsf{--shell-escape}, examples are given in a separate file. + +\pagebreak + +\section{Some customization} + +\subsection{Ideas} + +The package provides to macro, in order to : + +\begin{itemize} + \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} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +\SetJupyterLng{fr} %set french words + +\SetJupyterParSkip{<length>} %modify space before/after (or default) + +\setcounter{JupyterIn}{<nb>} %modify the counter +\end{codehigh} + +\subsection{Examples} + +\begin{codehigh}[language=latex/latex2,style/main=cyan!10,style/code=cyan!10] +\SetJupyterLng{fr} +\SetJupyterParSkip{\baselineskip} +\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) + +[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] +\end{NotebookOut} +\end{codehigh} + +\SetJupyterLng{fr} +\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)] +\end{NotebookIn} + +\begin{NotebookOut}{0.75\linewidth} +[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377] +\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 Binary files differnew file mode 100644 index 00000000000..7869f7ff323 --- /dev/null +++ b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.pdf diff --git a/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.tex b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.tex new file mode 100644 index 00000000000..86123fccfa4 --- /dev/null +++ b/Master/texmf-dist/doc/latex/pynotebook/pynotebook-examples-pitonpylautex.tex @@ -0,0 +1,239 @@ +% !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 |