summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/pynotebook/doc/pynotebook-doc.tex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2024-02-17 03:01:13 +0000
committerNorbert Preining <norbert@preining.info>2024-02-17 03:01:13 +0000
commit8886ad587a305595ce543a74b0fc779f0732a6e9 (patch)
tree25f6e576a52343cad4a3b56b2f669e09432211b8 /macros/latex/contrib/pynotebook/doc/pynotebook-doc.tex
parenta6e02d45ad0d10cfc3256fc91abe80d6228325a4 (diff)
CTAN sync 202402170301
Diffstat (limited to 'macros/latex/contrib/pynotebook/doc/pynotebook-doc.tex')
-rw-r--r--macros/latex/contrib/pynotebook/doc/pynotebook-doc.tex482
1 files changed, 482 insertions, 0 deletions
diff --git a/macros/latex/contrib/pynotebook/doc/pynotebook-doc.tex b/macros/latex/contrib/pynotebook/doc/pynotebook-doc.tex
new file mode 100644
index 0000000000..ef408c246b
--- /dev/null
+++ b/macros/latex/contrib/pynotebook/doc/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