commit 3acc483048b04e4dd560d01ea1610f815235e763
parent 2dc34e4d63d2e58bfc628644a6641fb08109acaa
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date: Wed, 11 Sep 2024 19:41:46 -0300
added `nbconvert` latex template
Diffstat:
7 files changed, 689 insertions(+), 0 deletions(-)
diff --git a/latex-template/base.tex.j2 b/latex-template/base.tex.j2
@@ -0,0 +1,260 @@
+((=- Latex base template (must inherit)
+This template builds upon the abstract template, adding common latex output
+functions. Figures, data_text,
+This template defines defines a default docclass, the inheriting class should
+override this.-=))
+
+((*- extends 'document_contents.tex.j2' -*))
+
+%===============================================================================
+% Abstract overrides
+%===============================================================================
+
+((*- block header -*))
+ ((* block docclass *))\documentclass[11pt]{article}((* endblock docclass *))
+
+ ((* block packages *))
+
+ % Basic figure setup, for now with no caption control since it's done
+ % automatically by Pandoc (which extracts ![](path) syntax from Markdown).
+ \usepackage{graphicx}
+ % Maintain compatibility with old templates. Remove in nbconvert 6.0
+ \let\Oldincludegraphics\includegraphics
+ % Ensure that by default, figures have no caption (until we provide a
+ % proper Figure object with a Caption API and a way to capture that
+ % in the conversion process - todo).
+ \usepackage{caption}
+ \DeclareCaptionFormat{nocaption}{}
+ \captionsetup{format=nocaption,aboveskip=0pt,belowskip=-20pt}
+ \setlength{\belowcaptionskip}{-20pt}
+
+ \usepackage[spanish]{babel}
+ \usepackage{float}
+ \floatplacement{figure}{H} % forces figures to be placed at the correct location
+ \usepackage{xcolor} % Allow colors to be defined
+ \usepackage{enumerate} % Needed for markdown enumerations to work
+ \usepackage[a4paper]{geometry} % Used to adjust the document margins
+ \usepackage{amsmath} % Equations
+ \usepackage{amssymb} % Equations
+ \usepackage{textcomp} % defines textquotesingle
+ % Hack from http://tex.stackexchange.com/a/47451/13684:
+ \AtBeginDocument{%
+ \def\PYZsq{\textquotesingle}% Upright quotes in Pygmentized code
+ }
+ \usepackage{upquote} % Upright quotes for verbatim code
+ \usepackage{eurosym} % defines \euro
+ \usepackage{helvet}
+ \renewcommand\familydefault{\sfdefault}
+
+ \usepackage{iftex}
+ \ifPDFTeX
+ \usepackage[T1]{fontenc}
+ \IfFileExists{alphabeta.sty}{
+ \usepackage{alphabeta}
+ }{
+ \usepackage[mathletters]{ucs}
+ \usepackage[utf8x]{inputenc}
+ }
+ \else
+ \usepackage{fontspec}
+ \usepackage{unicode-math}
+ \fi
+
+ \usepackage{fancyvrb} % verbatim replacement that allows latex
+ \usepackage{grffile} % extends the file name processing of package graphics
+ % to support a larger range
+ \makeatletter % fix for old versions of grffile with XeLaTeX
+ \@ifpackagelater{grffile}{2019/11/01}
+ {
+ % Do nothing on new versions
+ }
+ {
+ \def\Gread@@xetex#1{%
+ \IfFileExists{"\Gin@base".bb}%
+ {\Gread@eps{\Gin@base.bb}}%
+ {\Gread@@xetex@aux#1}%
+ }
+ }
+ \makeatother
+ \usepackage[Export]{adjustbox} % Used to constrain images to a maximum size
+ \adjustboxset{max size={\linewidth}{\paperheight}}
+
+ % The hyperref package gives us a pdf with properly built
+ % internal navigation ('pdf bookmarks' for the table of contents,
+ % internal cross-reference links, web links for URLs, etc.)
+ \usepackage{hyperref}
+ % The default LaTeX title has an obnoxious amount of whitespace. By default,
+ % titling removes some of it. It also provides customization options.
+ \usepackage{titling}
+ \setlength{\droptitle}{0em}
+ \usepackage{longtable} % longtable support required by pandoc >1.10
+ \usepackage{booktabs} % table support for pandoc > 1.12.2
+ \usepackage{array} % table support for pandoc >= 2.11.3
+ \usepackage{calc} % table minipage width calculation for pandoc >= 2.11.1
+ \usepackage[inline]{enumitem} % IRkernel/repr support (it uses the enumerate* environment)
+ \usepackage[normalem]{ulem} % ulem is needed to support strikethroughs (\sout)
+ % normalem makes italics be italics, not underlines
+ \usepackage{soul} % strikethrough (\st) support for pandoc >= 3.0.0
+ \usepackage{mathrsfs}
+ ((* endblock packages *))
+
+ ((* block definitions *))
+ % Colors for the hyperref package
+ \definecolor{urlcolor}{rgb}{0,.145,.698}
+ \definecolor{linkcolor}{rgb}{.71,0.21,0.01}
+ \definecolor{citecolor}{rgb}{.12,.54,.11}
+
+ % ANSI colors
+ \definecolor{ansi-black}{HTML}{3E424D}
+ \definecolor{ansi-black-intense}{HTML}{282C36}
+ \definecolor{ansi-red}{HTML}{E75C58}
+ \definecolor{ansi-red-intense}{HTML}{B22B31}
+ \definecolor{ansi-green}{HTML}{00A250}
+ \definecolor{ansi-green-intense}{HTML}{007427}
+ \definecolor{ansi-yellow}{HTML}{DDB62B}
+ \definecolor{ansi-yellow-intense}{HTML}{B27D12}
+ \definecolor{ansi-blue}{HTML}{208FFB}
+ \definecolor{ansi-blue-intense}{HTML}{0065CA}
+ \definecolor{ansi-magenta}{HTML}{D160C4}
+ \definecolor{ansi-magenta-intense}{HTML}{A03196}
+ \definecolor{ansi-cyan}{HTML}{60C6C8}
+ \definecolor{ansi-cyan-intense}{HTML}{258F8F}
+ \definecolor{ansi-white}{HTML}{C5C1B4}
+ \definecolor{ansi-white-intense}{HTML}{A1A6B2}
+ \definecolor{ansi-default-inverse-fg}{HTML}{FFFFFF}
+ \definecolor{ansi-default-inverse-bg}{HTML}{000000}
+
+ % common color for the border for error outputs.
+ \definecolor{outerrorbackground}{HTML}{FFDFDF}
+
+ % commands and environments needed by pandoc snippets
+ % extracted from the output of `pandoc -s`
+ \providecommand{\tightlist}{%
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
+ \DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
+ % Add ',fontsize=\small' for more characters per line
+ \newenvironment{Shaded}{}{}
+ \newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
+ \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
+ \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
+ \newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
+ \newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
+ \newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
+ \newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
+ \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
+ \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
+ \newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
+ \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
+ \newcommand{\RegionMarkerTok}[1]{{#1}}
+ \newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
+ \newcommand{\NormalTok}[1]{{#1}}
+
+ % Additional commands for more recent versions of Pandoc
+ \newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{{#1}}}
+ \newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
+ \newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
+ \newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{{#1}}}
+ \newcommand{\ImportTok}[1]{{#1}}
+ \newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{{#1}}}}
+ \newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
+ \newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
+ \newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{{#1}}}
+ \newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
+ \newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{{#1}}}
+ \newcommand{\BuiltInTok}[1]{{#1}}
+ \newcommand{\ExtensionTok}[1]{{#1}}
+ \newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{{#1}}}
+ \newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{{#1}}}
+ \newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
+ \newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
+
+
+ % Define a nice break command that doesn't care if a line doesn't already
+ % exist.
+ \def\br{\hspace*{\fill} \\* }
+ % Math Jax compatibility definitions
+ \def\gt{>}
+ \def\lt{<}
+ \let\Oldtex\TeX
+ \let\Oldlatex\LaTeX
+ \renewcommand{\TeX}{\textrm{\Oldtex}}
+ \renewcommand{\LaTeX}{\textrm{\Oldlatex}}
+ % Document parameters
+ % Document title
+ ((* block title -*))
+ ((*- set nb_title = nb.metadata.get('title', '') or resources['metadata']['name'] -*))
+ ((*- set nb_subtitle = nb.metadata.get('subtitle', '') -*))
+ \title{
+ \Huge{\bfseries ((( nb_title | escape_latex ))) \\
+ \large{\mdseries ((( nb_subtitle )))}}
+ }
+
+ ((*- endblock title *))
+ ((* block date *))
+ ((* if 'date' in nb.metadata *))
+ \small{\date{((( nb.metadata.date | escape_latex )))}}
+ ((* endif *))
+ ((* endblock date *))
+ ((* block author *))
+ ((* if 'authors' in nb.metadata *))
+ % ((( nb.metadata.authors | join('\\\\ ', attribute='name'))))
+ % ((( nb.metadata.authors | join('\\\\ ', attribute='email'))))
+
+ \author{
+ ((*- for author in nb.metadata.authors -*))
+ ((*- if not nb.metadata.authors.last -*))
+ \small\mdseries ((( author.name ))) - \itshape\href{mailto:((( author.email )))}{((( author.email )))} \\
+ ((*- else -*))
+ ((( author.name ))) - ((( author.email )))
+ ((*- endif -*))
+ ((*- endfor -*))
+ }
+
+ ((* endif *))
+ ((* endblock author *))
+ ((* endblock definitions *))
+
+ ((* block commands *))
+ % Prevent overflowing lines due to hard-to-break entities
+ \sloppy
+ % Setup hyperref package
+ \hypersetup{
+ breaklinks=true, % so long urls are correctly broken across lines
+ colorlinks=true,
+ urlcolor=urlcolor,
+ linkcolor=linkcolor,
+ citecolor=citecolor,
+ }
+ % Slightly bigger margins than the latex defaults
+ ((* block margins *))
+ \geometry{
+ verbose,
+ tmargin=2.00cm,
+ bmargin=1.25cm,
+ lmargin=1.75cm,
+ rmargin=1.75cm,
+ includefoot, heightrounded
+ }
+
+ ((* endblock margins *))
+ ((* endblock commands *))
+((* endblock header *))
+
+((* block body *))
+\begin{document}
+ ((* block predoc *))
+ ((* block maketitle *))
+ \maketitle
+ ((* endblock maketitle *))
+ ((* block abstract *))((* endblock abstract *))
+ \vspace{2em}
+ ((* endblock predoc *))
+
+ ((( super() )))
+
+ % Add a bibliography block to the postdoc
+ ((* block postdoc *))
+ ((* block bibliography *))((* endblock bibliography *))
+ ((* endblock postdoc *))
+\end{document}
+((* endblock body *))
diff --git a/latex-template/conf.json b/latex-template/conf.json
@@ -0,0 +1,7 @@
+{
+ "mimetypes": {
+ "text/latex": true,
+ "text/tex": true,
+ "application/pdf": true
+ }
+}
diff --git a/latex-template/display_priority.j2 b/latex-template/display_priority.j2
@@ -0,0 +1,47 @@
+((= Auto-generated template file, DO NOT edit directly!
+ To edit this file, please refer to ../../skeleton/README.md =))
+
+
+((*- extends 'null.j2' -*))
+
+((=display data priority=))
+
+
+((*- block data_priority scoped -*))
+ ((*- for type in output.data | filter_data_type -*))
+ ((*- if type == 'application/pdf' -*))
+ ((*- block data_pdf -*))
+ ((*- endblock -*))
+ ((*- elif type == 'image/svg+xml' -*))
+ ((*- block data_svg -*))
+ ((*- endblock -*))
+ ((*- elif type == 'image/png' -*))
+ ((*- block data_png -*))
+ ((*- endblock -*))
+ ((*- elif type == 'text/html' -*))
+ ((*- block data_html -*))
+ ((*- endblock -*))
+ ((*- elif type == 'text/markdown' -*))
+ ((*- block data_markdown -*))
+ ((*- endblock -*))
+ ((*- elif type == 'image/jpeg' -*))
+ ((*- block data_jpg -*))
+ ((*- endblock -*))
+ ((*- elif type == 'text/plain' -*))
+ ((*- block data_text -*))
+ ((*- endblock -*))
+ ((*- elif type == 'text/latex' -*))
+ ((*- block data_latex -*))
+ ((*- endblock -*))
+ ((*- elif type == 'application/javascript' -*))
+ ((*- block data_javascript -*))
+ ((*- endblock -*))
+ ((*- elif type == 'application/vnd.jupyter.widget-view+json' -*))
+ ((*- block data_widget_view -*))
+ ((*- endblock -*))
+ ((*- else -*))
+ ((*- block data_other -*))
+ ((*- endblock -*))
+ ((*- endif -*))
+ ((*- endfor -*))
+((*- endblock data_priority -*))
diff --git a/latex-template/document_contents.tex.j2 b/latex-template/document_contents.tex.j2
@@ -0,0 +1,74 @@
+((*- extends 'display_priority.j2' -*))
+
+%===============================================================================
+% Support blocks
+%===============================================================================
+
+% Displaying simple data text
+((* block data_text *))
+ \begin{Verbatim}[commandchars=\\\{\}]
+((( output.data['text/plain'] | escape_latex | ansi2latex )))
+ \end{Verbatim}
+((* endblock data_text *))
+
+% Display python error text with colored frame (saves printer ink vs bkgnd)
+((* block error *))
+ \begin{Verbatim}[commandchars=\\\{\}, frame=single, framerule=2mm, rulecolor=\color{outerrorbackground}]
+(((- super() )))
+ \end{Verbatim}
+((* endblock error *))
+% Display error lines with coloring
+((*- block traceback_line *))
+((( line | escape_latex | ansi2latex )))
+((*- endblock traceback_line *))
+
+% Display stream ouput with coloring
+((* block stream *))
+ \begin{Verbatim}[commandchars=\\\{\}]
+((( output.text | escape_latex | ansi2latex )))
+ \end{Verbatim}
+((* endblock stream *))
+
+% Display latex
+((* block data_latex -*))
+ ((( output.data['text/latex'] | strip_files_prefix )))
+((* endblock data_latex *))
+
+% Display markdown
+((* block data_markdown -*))
+ ((( output.data['text/markdown'] | citation2latex | strip_files_prefix | convert_pandoc('markdown+tex_math_double_backslash', 'latex'))))
+((* endblock data_markdown *))
+
+% Default mechanism for rendering figures
+((*- block data_png -*))((( draw_figure(output.metadata.filenames['image/png']) )))((*- endblock -*))
+((*- block data_jpg -*))((( draw_figure(output.metadata.filenames['image/jpeg']) )))((*- endblock -*))
+((*- block data_svg -*))((( draw_figure(output.metadata.filenames['image/svg+xml']) )))((*- endblock -*))
+((*- block data_pdf -*))((( draw_figure(output.metadata.filenames['application/pdf']) )))((*- endblock -*))
+
+% Draw a figure using the graphicx package.
+((* macro draw_figure(filename) -*))
+((* set filename = filename | posix_path *))
+((*- block figure scoped -*))
+ \begin{center}
+ \adjustimage{max size={\linewidth}{\paperheight}}{((( filename )))}
+ \end{center}
+ { \hspace*{\fill} \\}
+ \vspace{-2.5em}
+((*- endblock figure -*))
+((*- endmacro *))
+
+% Redirect execute_result to display data priority.
+((* block execute_result scoped *))
+ ((* block data_priority scoped *))
+ ((( super() )))
+ ((* endblock *))
+((* endblock execute_result *))
+
+% Render markdown
+((* block markdowncell scoped *))
+ ((( cell.source | citation2latex | strip_files_prefix | convert_pandoc('markdown+tex_math_double_backslash', 'json',extra_args=[]) | resolve_references | convert_explicitly_relative_paths | convert_pandoc('json','latex'))))
+((* endblock markdowncell *))
+
+% Don't display unknown types
+((* block unknowncell scoped *))
+((* endblock unknowncell *))
diff --git a/latex-template/index.tex.j2 b/latex-template/index.tex.j2
@@ -0,0 +1,17 @@
+
+((=- Default to the notebook output style -=))
+((*- if not cell_style is defined -*))
+ ((* set cell_style = 'style_jupyter.tex.j2' *))
+((*- endif -*))
+
+((=- Inherit from the specified cell style. -=))
+((* extends cell_style *))
+
+
+%===============================================================================
+% Latex Article
+%===============================================================================
+
+((*- block docclass -*))
+\documentclass[11pt]{article}
+((*- endblock docclass -*))
diff --git a/latex-template/null.j2 b/latex-template/null.j2
@@ -0,0 +1,106 @@
+((=- Auto-generated template file, DO NOT edit directly!
+ To edit this file, please refer to ../../skeleton/README.md -=))
+
+
+((=
+
+DO NOT USE THIS AS A BASE,
+IF YOU ARE COPY AND PASTING THIS FILE
+YOU ARE PROBABLY DOING THINGS INCORRECTLY.
+
+Null template, does nothing except defining a basic structure
+To layout the different blocks of a notebook.
+
+Subtemplates can override blocks to define their custom representation.
+
+If one of the block you do overwrite is not a leaf block, consider
+calling super.
+
+((*- block nonLeafBlock -*))
+ #add stuff at beginning
+ ((( super() )))
+ #add stuff at end
+((*- endblock nonLeafBlock -*))
+
+consider calling super even if it is a leaf block, we might insert more blocks later.
+
+=))
+((*- block header -*))
+((*- endblock header -*))
+((*- block body -*))
+((*- for cell in nb.cells -*))
+ ((*- block any_cell scoped -*))
+ ((*- if cell.cell_type == 'code'-*))
+ ((*- if resources.global_content_filter.include_code -*))
+ ((*- block codecell scoped -*))
+ ((*- if resources.global_content_filter.include_input and not cell.metadata.get("transient",{}).get("remove_source", false) -*))
+ ((*- block input_group -*))
+ ((*- if resources.global_content_filter.include_input_prompt -*))
+ ((*- block in_prompt -*))((*- endblock in_prompt -*))
+ ((*- endif -*))
+ ((*- block input -*))((*- endblock input -*))
+ ((*- endblock input_group -*))
+ ((*- endif -*))
+ ((*- if cell.outputs and resources.global_content_filter.include_output -*))
+ ((*- block output_group -*))
+ ((*- if resources.global_content_filter.include_output_prompt -*))
+ ((*- block output_prompt -*))((*- endblock output_prompt -*))
+ ((*- endif -*))
+ ((*- block outputs scoped -*))
+ ((*- for output in cell.outputs -*))
+ ((*- block output scoped -*))
+ ((*- if output.output_type == 'execute_result' -*))
+ ((*- block execute_result scoped -*))((*- endblock execute_result -*))
+ ((*- elif output.output_type == 'stream' -*))
+ ((*- block stream scoped -*))
+ ((*- if output.name == 'stdout' -*))
+ ((*- block stream_stdout scoped -*))
+ ((*- endblock stream_stdout -*))
+ ((*- elif output.name == 'stderr' -*))
+ ((*- block stream_stderr scoped -*))
+ ((*- endblock stream_stderr -*))
+ ((*- endif -*))
+ ((*- endblock stream -*))
+ ((*- elif output.output_type == 'display_data' -*))
+ ((*- block display_data scoped -*))
+ ((*- block data_priority scoped -*))
+ ((*- endblock data_priority -*))
+ ((*- endblock display_data -*))
+ ((*- elif output.output_type == 'error' -*))
+ ((*- block error scoped -*))
+ ((*- for line in output.traceback -*))
+ ((*- block traceback_line scoped -*))((*- endblock traceback_line -*))
+ ((*- endfor -*))
+ ((*- endblock error -*))
+ ((*- endif -*))
+ ((*- endblock output -*))
+ ((*- endfor -*))
+ ((*- endblock outputs -*))
+ ((*- endblock output_group -*))
+ ((*- endif -*))
+ ((*- endblock codecell -*))
+ ((*- endif -*))
+ ((*- elif cell.cell_type in ['markdown'] -*))
+ ((*- if resources.global_content_filter.include_markdown and not cell.metadata.get("transient",{}).get("remove_source", false) -*))
+ ((*- block markdowncell scoped-*)) ((*- endblock markdowncell -*))
+ ((*- endif -*))
+ ((*- elif cell.cell_type in ['raw'] -*))
+ ((*- if resources.global_content_filter.include_raw and not cell.metadata.get("transient",{}).get("remove_source", false) -*))
+ ((*- block rawcell scoped -*))
+ ((*- if cell.metadata.get('raw_mimetype', '').lower() in resources.get('raw_mimetypes', ['']) -*))
+ ((( cell.source )))
+ ((*- endif -*))
+ ((*- endblock rawcell -*))
+ ((*- endif -*))
+ ((*- else -*))
+ ((*- if resources.global_content_filter.include_unknown and not cell.metadata.get("transient",{}).get("remove_source", false) -*))
+ ((*- block unknowncell scoped-*))
+ ((*- endblock unknowncell -*))
+ ((*- endif -*))
+ ((*- endif -*))
+ ((*- endblock any_cell -*))
+((*- endfor -*))
+((*- endblock body -*))
+
+((*- block footer -*))
+((*- endblock footer -*))
diff --git a/latex-template/style_jupyter.tex.j2 b/latex-template/style_jupyter.tex.j2
@@ -0,0 +1,178 @@
+((=- IPython input/output style -=))
+((*- extends 'base.tex.j2' -*))
+
+((*- block packages -*))
+ \usepackage[breakable]{tcolorbox}
+ \usepackage{parskip} % Stop auto-indenting (to mimic markdown behaviour)
+ ((( super() )))
+((*- endblock packages -*))
+
+((*- block definitions -*))
+ ((( super() )))
+% Pygments definitions
+ (((- resources.latex.pygments_definitions )))
+
+ % For linebreaks inside Verbatim environment from package fancyvrb.
+ \makeatletter
+ \newbox\Wrappedcontinuationbox
+ \newbox\Wrappedvisiblespacebox
+ \newcommand*\Wrappedvisiblespace {\textcolor{red}{\textvisiblespace}}
+ \newcommand*\Wrappedcontinuationsymbol {\textcolor{red}{\llap{\tiny$\m@th\hookrightarrow$}}}
+ \newcommand*\Wrappedcontinuationindent {3ex }
+ \newcommand*\Wrappedafterbreak {\kern\Wrappedcontinuationindent\copy\Wrappedcontinuationbox}
+ % Take advantage of the already applied Pygments mark-up to insert
+ % potential linebreaks for TeX processing.
+ % {, <, #, %, $, ' and ": go to next line.
+ % _, }, ^, &, >, - and ~: stay at end of broken line.
+ % Use of \textquotesingle for straight quote.
+ \newcommand*\Wrappedbreaksatspecials {%
+ \def\PYGZus{\discretionary{\char`\_}{\Wrappedafterbreak}{\char`\_}}%
+ \def\PYGZob{\discretionary{}{\Wrappedafterbreak\char`\{}{\char`\{}}%
+ \def\PYGZcb{\discretionary{\char`\}}{\Wrappedafterbreak}{\char`\}}}%
+ \def\PYGZca{\discretionary{\char`\^}{\Wrappedafterbreak}{\char`\^}}%
+ \def\PYGZam{\discretionary{\char`\&}{\Wrappedafterbreak}{\char`\&}}%
+ \def\PYGZlt{\discretionary{}{\Wrappedafterbreak\char`\<}{\char`\<}}%
+ \def\PYGZgt{\discretionary{\char`\>}{\Wrappedafterbreak}{\char`\>}}%
+ \def\PYGZsh{\discretionary{}{\Wrappedafterbreak\char`\#}{\char`\#}}%
+ \def\PYGZpc{\discretionary{}{\Wrappedafterbreak\char`\%}{\char`\%}}%
+ \def\PYGZdl{\discretionary{}{\Wrappedafterbreak\char`\$}{\char`\$}}%
+ \def\PYGZhy{\discretionary{\char`\-}{\Wrappedafterbreak}{\char`\-}}%
+ \def\PYGZsq{\discretionary{}{\Wrappedafterbreak\textquotesingle}{\textquotesingle}}%
+ \def\PYGZdq{\discretionary{}{\Wrappedafterbreak\char`\"}{\char`\"}}%
+ \def\PYGZti{\discretionary{\char`\~}{\Wrappedafterbreak}{\char`\~}}%
+ }
+ % Some characters . , ; ? ! / are not pygmentized.
+ % This macro makes them "active" and they will insert potential linebreaks
+ \newcommand*\Wrappedbreaksatpunct {%
+ \lccode`\~`\.\lowercase{\def~}{\discretionary{\hbox{\char`\.}}{\Wrappedafterbreak}{\hbox{\char`\.}}}%
+ \lccode`\~`\,\lowercase{\def~}{\discretionary{\hbox{\char`\,}}{\Wrappedafterbreak}{\hbox{\char`\,}}}%
+ \lccode`\~`\;\lowercase{\def~}{\discretionary{\hbox{\char`\;}}{\Wrappedafterbreak}{\hbox{\char`\;}}}%
+ \lccode`\~`\:\lowercase{\def~}{\discretionary{\hbox{\char`\:}}{\Wrappedafterbreak}{\hbox{\char`\:}}}%
+ \lccode`\~`\?\lowercase{\def~}{\discretionary{\hbox{\char`\?}}{\Wrappedafterbreak}{\hbox{\char`\?}}}%
+ \lccode`\~`\!\lowercase{\def~}{\discretionary{\hbox{\char`\!}}{\Wrappedafterbreak}{\hbox{\char`\!}}}%
+ \lccode`\~`\/\lowercase{\def~}{\discretionary{\hbox{\char`\/}}{\Wrappedafterbreak}{\hbox{\char`\/}}}%
+ \catcode`\.\active
+ \catcode`\,\active
+ \catcode`\;\active
+ \catcode`\:\active
+ \catcode`\?\active
+ \catcode`\!\active
+ \catcode`\/\active
+ \lccode`\~`\~
+ }
+ \makeatother
+
+ \let\OriginalVerbatim=\Verbatim
+ \makeatletter
+ \renewcommand{\Verbatim}[1][1]{%
+ %\parskip\z@skip
+ \sbox\Wrappedcontinuationbox {\Wrappedcontinuationsymbol}%
+ \sbox\Wrappedvisiblespacebox {\FV@SetupFont\Wrappedvisiblespace}%
+ \def\FancyVerbFormatLine ##1{\hsize\linewidth
+ \vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@
+ \doublehyphendemerits\z@\finalhyphendemerits\z@
+ \strut ##1\strut}%
+ }%
+ % If the linebreak is at a space, the latter will be displayed as visible
+ % space at end of first line, and a continuation symbol starts next line.
+ % Stretch/shrink are however usually zero for typewriter font.
+ \def\FV@Space {%
+ \nobreak\hskip\z@ plus\fontdimen3\font minus\fontdimen4\font
+ \discretionary{\copy\Wrappedvisiblespacebox}{\Wrappedafterbreak}
+ {\kern\fontdimen2\font}%
+ }%
+
+ % Allow breaks at special characters using \PYG... macros.
+ \Wrappedbreaksatspecials
+ % Breaks at punctuation characters . , ; ? ! and / need catcode=\active
+ \OriginalVerbatim[#1,codes*=\Wrappedbreaksatpunct]%
+ }
+ \makeatother
+
+ % Exact colors from NB
+ ((*- block style_colors *))
+ \definecolor{incolor}{HTML}{303F9F}
+ \definecolor{outcolor}{HTML}{D84315}
+ \definecolor{cellborder}{HTML}{CFCFCF}
+ \definecolor{cellbackground}{HTML}{F7F7F7}
+ ((*- endblock style_colors *))
+
+ % prompt
+ \makeatletter
+ \newcommand{\boxspacing}{\kern\kvtcb@left@rule\kern\kvtcb@boxsep}
+ \makeatother
+ ((*- block style_prompt *))
+ \newcommand{\prompt}[4]{
+ {\ttfamily\llap{{\color{#2}[#3]:\hspace{3pt}#4}}\vspace{-\baselineskip}}
+ }
+ ((* endblock style_prompt *))
+
+((*- endblock definitions -*))
+
+%===============================================================================
+% Input
+%===============================================================================
+
+((* block input scoped *))
+ ((( draw_cell(cell.source | highlight_code(strip_verbatim=True), cell, 'In', 'incolor', '\\boxspacing') )))
+((* endblock input *))
+
+
+%===============================================================================
+% Output
+%===============================================================================
+
+((*- if charlim is not defined -*))
+ ((* set charlim = 80 *))
+((*- endif -*))
+
+((* block execute_result scoped *))
+ ((*- for type in output.data | filter_data_type -*))
+ ((*- if type in ['text/plain']*))
+ ((( draw_cell(output.data['text/plain'] | wrap_text(charlim) | escape_latex | ansi2latex, cell, 'Out', 'outcolor', '\\boxspacing') )))
+ ((* else -*))
+ ((( " " )))
+ ((( draw_prompt(cell, 'Out', 'outcolor','') )))((( super() )))
+ ((*- endif -*))
+ ((*- endfor -*))
+((* endblock execute_result *))
+
+((* block stream *))
+ \begin{Verbatim}[commandchars=\\\{\}]
+((( output.text | wrap_text(charlim) | escape_latex | strip_trailing_newline | ansi2latex )))
+ \end{Verbatim}
+((* endblock stream *))
+
+%==============================================================================
+% Support Macros
+%==============================================================================
+
+% Name: draw_cell
+% Purpose: Renders an output/input prompt
+((*- if draw_cell is not defined -*)) % Required to allow overriding.
+((* macro draw_cell(text, cell, prompt, prompt_color, extra_space) -*))
+((*- if prompt == 'In' -*))
+((*- set style = "breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder"-*))
+((*- else -*))((*- set style = "breakable, size=fbox, boxrule=.5pt, pad at break*=1mm, opacityfill=0"-*))((*- endif -*))
+
+\begin{tcolorbox}[((( style ))), fontupper=\footnotesize]
+(((- draw_prompt(cell, prompt, prompt_color, extra_space) )))
+\begin{Verbatim}[commandchars=\\\{\}]
+((( text )))
+\end{Verbatim}
+\end{tcolorbox}
+((*- endmacro *))
+((*- endif -*))
+
+% Name: draw_prompt
+% Purpose: Renders an output/input prompt
+((* macro draw_prompt(cell, prompt, prompt_color, extra_space) -*))
+ ((*- if cell.execution_count is defined -*))
+ ((*- set execution_count = "" ~ (cell.execution_count | replace(None, " ")) -*))
+ ((*- else -*))((*- set execution_count = " " -*))((*- endif *))
+
+ ((*- if (resources.global_content_filter.include_output_prompt and prompt == 'Out')
+ or (resources.global_content_filter.include_input_prompt and prompt == 'In' ) *))
+\prompt{(((prompt)))}{(((prompt_color)))}{(((execution_count)))}{(((extra_space)))}
+ ((*- endif -*))
+((*- endmacro *))