From d1c1d6c04c1121e7b83bc35e2077738d7cbd5839 Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 20 Nov 2020 08:49:03 +1100 Subject: [PATCH 1/9] update configuration for download notebooks --- lectures/_config.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lectures/_config.yml b/lectures/_config.yml index f19df2d1..8b5cb686 100644 --- a/lectures/_config.yml +++ b/lectures/_config.yml @@ -12,7 +12,7 @@ html: baseurl: https://python.quantecon.org/ sphinx: - extra_extensions: [sphinx_multitoc_numbering, sphinx_exercise, sphinxext.rediraffe] + extra_extensions: [sphinx_multitoc_numbering, sphinx_exercise, sphinxext.rediraffe, sphinx_tojupyter] config: html_favicon: _static/lectures-favicon.ico html_theme: quantecon_book_theme @@ -29,3 +29,9 @@ sphinx: google_analytics_id: UA-54984338-9 rediraffe_redirects: index_toc.md: intro.md + tojupyter_static_file_path: ["source/_static", "_static"] + tojupyter_target_html: true + tojupyter_urlpath: "https://python-programming.quantecon.org/" + tojupyter_image_urlpath: "https://python-programming.quantecon.org/_static/" + tojupyter_lang_synonyms: ["ipython", "ipython3", "python"] + tojupyter_allow_html_only: true From 0b85158db7a86f886ea8490c801bbbfde30e4f19 Mon Sep 17 00:00:00 2001 From: mmcky Date: Wed, 25 Nov 2020 17:06:08 +1100 Subject: [PATCH 2/9] enable pdf production --- .gitignore | 3 +- lectures/_config.yml | 12 +- templates/latex.tpl | 323 +++++++++++++++++++++++++++++++++++++++ templates/latex_book.tpl | 319 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 655 insertions(+), 2 deletions(-) create mode 100644 templates/latex.tpl create mode 100644 templates/latex_book.tpl diff --git a/.gitignore b/.gitignore index f79935a8..5b84697c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ _build/ __pycache__/ -.DS_Store \ No newline at end of file +.DS_Store +dask-worker-space \ No newline at end of file diff --git a/lectures/_config.yml b/lectures/_config.yml index 8b5cb686..8aac2930 100644 --- a/lectures/_config.yml +++ b/lectures/_config.yml @@ -30,8 +30,18 @@ sphinx: rediraffe_redirects: index_toc.md: intro.md tojupyter_static_file_path: ["source/_static", "_static"] - tojupyter_target_html: true tojupyter_urlpath: "https://python-programming.quantecon.org/" tojupyter_image_urlpath: "https://python-programming.quantecon.org/_static/" tojupyter_lang_synonyms: ["ipython", "ipython3", "python"] tojupyter_allow_html_only: true + tojupyter_kernels: + python3: + kernelspec: + display_name: "Python" + language: python3 + name: python3 + file_extension: ".py" + tojupyter_images_markdown: true + tojupyter_template_path: ../templates/ + tojupyter_latex_template: latex.tpl + tojupyter_latex_template_book: latex_book.tpl \ No newline at end of file diff --git a/templates/latex.tpl b/templates/latex.tpl new file mode 100644 index 00000000..86405eff --- /dev/null +++ b/templates/latex.tpl @@ -0,0 +1,323 @@ +((*- extends 'article.tplx' -*)) + +% See http://blog.juliusschulz.de/blog/ultimate-ipython-notebook#templates +% for some useful tips + +%=============================================================================== +% Document class +%=============================================================================== + +((* block docclass *)) +\documentclass[11pt, twoside, a4paper]{article} +((* endblock docclass *)) + +%=============================================================================== +% Packages +%=============================================================================== + +((* block packages *)) +\usepackage[T1]{fontenc} +\usepackage{graphicx} +\usepackage[breakable]{tcolorbox} +% We will generate all images so they have a width \maxwidth. This means +% that they will get their normal width if they fit onto the page, but +% are scaled down if they would overflow the margins. +\makeatletter +\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth +\else\Gin@nat@width\fi} +\makeatother +\let\Oldincludegraphics\includegraphics + +% propose delete% +% 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} +% \DeclareCaptionLabelFormat{empty}{} +%\captionsetup{format=empty,aboveskip=0pt,belowskip=0pt} +% end - propose delete% + +% float figure settings% +\usepackage{float} +\floatplacement{figure}{H} % used to force figures for placement in text + +\usepackage{adjustbox} % Used to constrain images to a maximum size +\usepackage{xcolor} % Allow colors to be defined +\usepackage{enumerate} % Needed for markdown enumerations to work +\usepackage{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[mathletters]{ucs} % Extended unicode (utf-8) support +\usepackage[utf8x]{inputenc} % Allow utf-8 characters in the tex document +\usepackage{fancyvrb} % verbatim replacement that allows latex +\usepackage{xcolor} +\usepackage{listings} +\lstset{escapeinside={<@}{@>}} +\usepackage{grffile} % extends the file name processing of package graphics + % to support a larger range +% 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} +\usepackage{longtable} % longtable support required by pandoc >1.10 +\usepackage{booktabs} % table support for pandoc > 1.12.2 +\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{braket} +\usepackage{mathrsfs} +\usepackage{natbib} +\usepackage[document]{ragged2e} +\usepackage{fontspec, unicode-math} +\usepackage[greek,english]{babel} +\usepackage{xunicode} +\usepackage{letltxmacro} +\newcommand{\argmax}{\operatornamewithlimits{argmax}} +\newcommand{\argmin}{\operatornamewithlimits{argmin}} +\DeclareMathOperator{\col}{col} +\setlength{\parskip}{1.5ex plus0.5ex minus0.5ex} +\setlength{\parindent}{0pt} + +\usepackage{letltxmacro} +% https://tex.stackexchange.com/q/88001/5764 +\LetLtxMacro\oldttfamily\ttfamily +\DeclareRobustCommand{\ttfamily}{\oldttfamily\csname ttsize\endcsname} +\newcommand{\setttsize}[1]{\def\ttsize{#1}}% + +\DeclareTextFontCommand{\texttt}{\ttfamily} + +% Enable Unicode characters in `Out` code-blocks within verbatim +\usepackage{pmboxdraw} + +% renew commands % +% Set max figure width to be 80% of text width, for now hardcoded. +\renewcommand{\includegraphics}[1]{\begin{center}\Oldincludegraphics[width=.8\maxwidth]{#1}\end{center}} +\renewcommand \caption [2][]{} % removes captions from all figures +\setlist[itemize]{nosep} + +% using CMU Serif for greek and latin letters in code blocks and Liberation Mono for rest% +\setmonofont{Liberation Mono} +\usepackage[Latin,Greek]{ucharclasses} +\newfontfamily\substitutefont{CMU Serif} +\setTransitionsForGreek{\begingroup\substitutefont}{\endgroup} +((* endblock packages *)) + +% 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} + + +% 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} + +%=============================================================================== +% Title Page +%=============================================================================== + +((* block maketitle *)) +\setttsize{\footnotesize} + +\title{((( nb.metadata.get("latex_metadata", {}).get("title", "") | escape_latex )))} + +((*- if nb.metadata.get("latex_metadata", {}).get("author", ""): -*)) +\author{((( nb.metadata["latex_metadata"]["author"] )))} +((*- endif *)) + +((*- if nb.metadata.get("latex_metadata", {}).get("affiliation", ""): -*)) +\affiliation{((( nb.metadata["latex_metadata"]["affiliation"] )))} +((*- endif *)) + +\date{\today} +\maketitle + +((*- if nb.metadata.get("latex_metadata", {}).get("logo", ""): -*)) +\begin{center} + \adjustimage{max size={0.6\linewidth}{0.6\paperheight}}{((( nb.metadata["latex_metadata"]["logo"] )))} +\end{center} +((*- endif -*)) + +% delete-till-here-book % +((* endblock maketitle *)) + + +%=============================================================================== +% Input +%=============================================================================== + +% Input cells can be hidden using the "Hide input" and "Hide input all" +% nbextensions (which set the hide_input metadata flags) + +((* block input scoped *)) +((( cell.metadata.get("hide_input", "") ))) +((*- if cell.metadata.hide_input or nb.metadata.hide_input or cell.metadata.get("hide_input", ""): -*)) +((*- else -*)) + ((( custom_add_prompt(cell.source | wrap_text(88) | highlight_code(strip_verbatim=True), cell, 'In ', 'incolor', 'plain') ))) +((*- endif *)) +((* endblock input *)) + + +%=============================================================================== +% Output +%=============================================================================== + +((* block output_group -*)) +((*- if cell.metadata.hide_output: -*)) +((*- else -*)) + ((( super() ))) +((*- endif -*)) +((* endblock output_group *)) + +((* block execute_result scoped *)) + ((*- for type in output.data | filter_data_type -*)) + ((*- if type in ['text/plain']*)) + ((( custom_add_prompt(output.data['text/plain'] | wrap_text(88) | escape_latex | ansi2latex, cell, 'Out', 'outcolor', 'plain') ))) + ((*- elif type in ['text/latex']*)) + ((( custom_add_prompt(output.data['text/latex'] | wrap_text(88) | ansi2latex, cell, 'Out', 'outcolor', 'latex') ))) + ((* else -*)) + ((( custom_add_prompt( '' | wrap_text(88)| escape_latex | ansi2latex, cell, 'Out', 'outcolor', 'plain') ))) + ((*- endif -*)) + ((*- endfor -*)) +((* endblock execute_result *)) + +% Display stream ouput with coloring +((* block stream *)) +\begin{Verbatim}[commandchars=\\\{\}, fontsize=\footnotesize] + ((( output.text | wrap_text(86) | escape_latex | ansi2latex ))) +\end{Verbatim} +%((* endblock stream *)) + +%============================================================================== +% Define macro custom_add_prompt() (derived from add_prompt() macro in style_ipython.tplx) +%============================================================================== + +((* macro custom_add_prompt(text, cell, prompt, prompt_color, type) -*)) + ((*- if cell.execution_count is defined -*)) + ((*- set execution_count = "" ~ (cell.execution_count | replace(None, " ")) -*)) + ((*- else -*)) + ((*- set execution_count = "" -*)) + ((*- endif -*)) + ((*- set indention = " " * (execution_count | length + 7) -*)) +((*- if type == 'plain' -*)) +\begin{Verbatim}[commandchars=\\\{\}, fontsize=\small, xleftmargin=-3.9em] +((( text.replace('$$','').replace('$\\',"\\(\\").replace('$','\)') | add_prompts(first='{\color{' ~ prompt_color ~ '}' ~ prompt ~ '[{\\color{' ~ prompt_color ~ '}' ~ execution_count ~ '}]:} ', cont=indention) ))) +\end{Verbatim} +((*- else -*)) +\begin{lstlisting}[mathescape, basicstyle=\small\ttfamily\color{black}, keywordstyle={\color{red}}, xleftmargin=-4.8em] +((( text | add_prompts(first='<@\\textcolor{red}{' ~ prompt ~ '[' ~ execution_count ~ ']: }@>', cont=indention) ))) +\end{lstlisting} +((*- endif -*)) +((*- endmacro *)) + +%============================================================================== +% Support Macros +%============================================================================== + +% 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 *)) + + +%============================================================================== +% Bibliography +%============================================================================== + +% Insert citations in markdown as e.g. +% [DevoretS2013] +% requires file references.bib in current directory (or the file set as "bib" in the latex_metadata) + + +((* block bibliography *)) +% delete-from-here-book % +((*- if nb.metadata.get("latex_metadata", {}).get("bib_include", ""): -*)) +% Add a bibliography block to the postdoc +\bibliographystyle{plain} +\bibliography{((( nb.metadata.get("latex_metadata", {}).get("bib", "quant-econ") )))} +((*- endif -*)) +((* endblock bibliography *)) diff --git a/templates/latex_book.tpl b/templates/latex_book.tpl new file mode 100644 index 00000000..23813f14 --- /dev/null +++ b/templates/latex_book.tpl @@ -0,0 +1,319 @@ +((*- extends 'article.tplx' -*)) + +% See http://blog.juliusschulz.de/blog/ultimate-ipython-notebook#templates +% for some useful tips + +%=============================================================================== +% Document class +%=============================================================================== + +((* block docclass *)) +\documentclass[a4paper,11pt, twoside]{book} +((* endblock docclass *)) + +%=============================================================================== +% Packages +%=============================================================================== + +((* block packages *)) +\usepackage[T1]{fontenc} +\usepackage{graphicx} +\usepackage[breakable]{tcolorbox} +% We will generate all images so they have a width \maxwidth. This means +% that they will get their normal width if they fit onto the page, but +% are scaled down if they would overflow the margins. +\makeatletter +\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth +\else\Gin@nat@width\fi} +\makeatother +\let\Oldincludegraphics\includegraphics + +% propose delete% +% 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} +% \DeclareCaptionLabelFormat{empty}{} +%\captionsetup{format=empty,aboveskip=0pt,belowskip=0pt} +% end - propose delete% + +% float figure settings% +\usepackage{float} +\floatplacement{figure}{H} % used to force figures for placement in text + +\usepackage{adjustbox} % Used to constrain images to a maximum size +\usepackage{xcolor} % Allow colors to be defined +\usepackage{enumerate} % Needed for markdown enumerations to work +\usepackage{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[mathletters]{ucs} % Extended unicode (utf-8) support +\usepackage[utf8x]{inputenc} % Allow utf-8 characters in the tex document +\usepackage{fancyvrb} % verbatim replacement that allows latex +\usepackage{listings} +\lstset{escapeinside={<@}{@>}} +\usepackage{grffile} % extends the file name processing of package graphics + % to support a larger range +% 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} +\usepackage{longtable} % longtable support required by pandoc >1.10 +\usepackage{booktabs} % table support for pandoc > 1.12.2 +\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{braket} +\usepackage{mathrsfs} +\usepackage{natbib} +\usepackage[document]{ragged2e} +\usepackage{fontspec, unicode-math} +\usepackage[greek,english]{babel} +\usepackage{xunicode} +\usepackage{letltxmacro} +\newcommand{\argmax}{\operatornamewithlimits{argmax}} +\newcommand{\argmin}{\operatornamewithlimits{argmin}} +\DeclareMathOperator{\col}{col} +\setlength{\parskip}{1.5ex plus0.5ex minus0.5ex} +\setlength{\parindent}{0pt} + +\usepackage{letltxmacro} +% https://tex.stackexchange.com/q/88001/5764 +\LetLtxMacro\oldttfamily\ttfamily +\DeclareRobustCommand{\ttfamily}{\oldttfamily\csname ttsize\endcsname} +\newcommand{\setttsize}[1]{\def\ttsize{#1}}% + +\DeclareTextFontCommand{\texttt}{\ttfamily} + +% Enable Unicode characters in `Out` code-blocks within verbatim +\usepackage{pmboxdraw} + +% renew commands % +% Set max figure width to be 80% of text width, for now hardcoded. +\renewcommand{\includegraphics}[1]{\begin{center}\Oldincludegraphics[width=.8\maxwidth]{#1}\end{center}} +\renewcommand \caption [2][]{} % removes captions from all figures +\setlist[itemize]{nosep} + +% using CMU Serif for greek and latin letters in code blocks and Liberation Mono for rest% +\setmonofont{Liberation Mono} +\usepackage[Latin,Greek]{ucharclasses} +\newfontfamily\substitutefont{CMU Serif} +\setTransitionsForGreek{\begingroup\substitutefont}{\endgroup} +((* endblock packages *)) + +% 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} + + +% 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} + +%=============================================================================== +% Title Page +%=============================================================================== + +((* block maketitle *)) +\setttsize{\footnotesize} + +((*- if nb.metadata.get("latex_metadata", {}).get("jupyter_pdf_book_title", ""): -*)) +\title{\Huge \textbf{((( nb.metadata["latex_metadata"]["jupyter_pdf_book_title"] )))}} +((*- endif *)) + +((*- if nb.metadata.get("latex_metadata", {}).get("author", ""): -*)) +\author{\textsc{((( nb.metadata["latex_metadata"]["author"] )))}} +((*- endif *)) + +((*- if nb.metadata.get("latex_metadata", {}).get("affiliation", ""): -*)) +\affiliation{((( nb.metadata["latex_metadata"]["affiliation"] )))} +((*- endif *)) + +\date{\today} +\maketitle + +\setcounter{tocdepth}{0} +\tableofcontents + + +\parskip 0.09in + +\mainmatter + +((* endblock maketitle *)) + +%=============================================================================== +% Input +%=============================================================================== + +% Input cells can be hidden using the "Hide input" and "Hide input all" +% nbextensions (which set the hide_input metadata flags) + +((* block input scoped *)) +((( cell.metadata.get("hide_input", "") ))) +((*- if cell.metadata.hide_input or nb.metadata.hide_input or cell.metadata.get("hide_input", ""): -*)) +((*- else -*)) + ((( custom_add_prompt(cell.source | wrap_text(88) | highlight_code(strip_verbatim=True), cell, 'In ', 'incolor', 'plain') ))) +((*- endif *)) +((* endblock input *)) + + +%=============================================================================== +% Output +%=============================================================================== + +((* block output_group -*)) +((*- if cell.metadata.hide_output: -*)) +((*- else -*)) + ((( super() ))) +((*- endif -*)) +((* endblock output_group *)) + +((* block execute_result scoped *)) + ((*- for type in output.data | filter_data_type -*)) + ((*- if type in ['text/plain']*)) + ((( custom_add_prompt(output.data['text/plain'] | wrap_text(88) | escape_latex | ansi2latex, cell, 'Out', 'outcolor', 'plain') ))) + ((*- elif type in ['text/latex']*)) + ((( custom_add_prompt(output.data['text/latex'] | wrap_text(88) | ansi2latex, cell, 'Out', 'outcolor', 'latex') ))) + ((* else -*)) + ((( custom_add_prompt( '' | wrap_text(88)| escape_latex | ansi2latex, cell, 'Out', 'outcolor', 'plain') ))) + ((*- endif -*)) + ((*- endfor -*)) +((* endblock execute_result *)) + +% Display stream ouput with coloring +((* block stream *)) +\begin{Verbatim}[commandchars=\\\{\}, fontsize=\footnotesize] + ((( output.text | wrap_text(86) | escape_latex | ansi2latex ))) +\end{Verbatim} +%((* endblock stream *)) + +%============================================================================== +% Define macro custom_add_prompt() (derived from add_prompt() macro in style_ipython.tplx) +%============================================================================== + +((* macro custom_add_prompt(text, cell, prompt, prompt_color, type) -*)) + ((*- if cell.execution_count is defined -*)) + ((*- set execution_count = "" ~ (cell.execution_count | replace(None, " ")) -*)) + ((*- else -*)) + ((*- set execution_count = "" -*)) + ((*- endif -*)) + ((*- set indention = " " * (execution_count | length + 7) -*)) +((*- if type == 'plain' -*)) +\begin{Verbatim}[commandchars=\\\{\}, fontsize=\small, xleftmargin=-3.9em] +((( text.replace('$$','').replace('$\\',"\\(\\").replace('$','\)') | add_prompts(first='{\color{' ~ prompt_color ~ '}' ~ prompt ~ '[{\\color{' ~ prompt_color ~ '}' ~ execution_count ~ '}]:} ', cont=indention) ))) +\end{Verbatim} +((*- else -*)) +\begin{lstlisting}[mathescape, basicstyle=\small\ttfamily\color{black}, xleftmargin=-3.9em] +((( text | add_prompts(first='<@\\textcolor{red}{' ~ prompt ~ '[' ~ execution_count ~ ']: }@>', cont=indention) ))) +\end{lstlisting} +((*- endif -*)) +((*- endmacro *)) + +%============================================================================== +% Support Macros +%============================================================================== + +% 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 *)) + + +%============================================================================== +% Bibliography +%============================================================================== + +% Insert citations in markdown as e.g. +% [DevoretS2013] +% requires file references.bib in current directory (or the file set as "bib" in the latex_metadata) + + +((* block bibliography *)) +% Add a bibliography block to the postdoc +((* endblock bibliography *)) From 9bb9ce9487b38b75e9c14a53a4e24e2842fbca93 Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 26 Nov 2020 12:37:38 +1100 Subject: [PATCH 3/9] update ci, enable download notebooks --- .github/workflows/ci.yml | 6 ++++++ environment.yml | 3 ++- lectures/_config.yml | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 800517d5..805dfea0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,12 @@ jobs: shell: bash -l {0} run: | jb build lectures --path-output ./ + - name: Build Download Notebooks (sphinx-tojupyter) + shell: bash -l {0} + run: | + jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter + mkdir _build/html/_notebooks + cp _build/jupyter/*.ipynb _build/html/_notebooks - name: Preview Deploy to Netlify uses: nwtgck/actions-netlify@v1.1 with: diff --git a/environment.yml b/environment.yml index 9b2c10e6..4ea32d56 100644 --- a/environment.yml +++ b/environment.yml @@ -6,11 +6,12 @@ dependencies: - anaconda=2020.07 - pip - pip: - - jupyter-book + - git+https://github.com/executablebooks/jupyter-book.git - sphinxext-rediraffe - git+https://github.com/executablebooks/sphinx-multitoc-numbering - git+https://github.com/quantecon/quantecon-book-theme - git+https://github.com/executablebooks/sphinx-exercise.git - joblib - interpolation + - git+https://github.com/QuantEcon/sphinx-tojupyter.git diff --git a/lectures/_config.yml b/lectures/_config.yml index 8aac2930..1b9d9d96 100644 --- a/lectures/_config.yml +++ b/lectures/_config.yml @@ -44,4 +44,4 @@ sphinx: tojupyter_images_markdown: true tojupyter_template_path: ../templates/ tojupyter_latex_template: latex.tpl - tojupyter_latex_template_book: latex_book.tpl \ No newline at end of file + tojupyter_latex_template_book: latex_book.tpl From ce81b2fe3eef83b64cb380e5fd86f6c44bede7e9 Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 26 Nov 2020 12:43:05 +1100 Subject: [PATCH 4/9] update anaconda --- .github/workflows/ci.yml | 4 ++-- environment.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 805dfea0..b7591f0c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,14 +7,14 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup Anaconda - uses: goanpeca/setup-miniconda@v1 + uses: conda-incubator/setup-miniconda@v2 with: auto-update-conda: true auto-activate-base: true miniconda-version: 'latest' python-version: 3.8 environment-file: environment.yml - activate-environment: qe-lectures + activate-environment: lecture-python-programming - name: Display Conda Environment Versions shell: bash -l {0} run: conda list diff --git a/environment.yml b/environment.yml index 4ea32d56..3f7282ef 100644 --- a/environment.yml +++ b/environment.yml @@ -1,4 +1,4 @@ -name: qe-lectures +name: lecture-python-programming channels: - default dependencies: From 49aac7594349100d617c54f5c6724b10a06f6b2f Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 27 Nov 2020 09:33:33 +1100 Subject: [PATCH 5/9] migrate to use jupyter raw directives --- lectures/_config.yml | 1 - lectures/about_py.md | 2 +- lectures/debugging.md | 2 +- lectures/functions.md | 2 +- lectures/getting_started.md | 2 +- lectures/matplotlib.md | 2 +- lectures/need_for_speed.md | 2 +- lectures/numba.md | 2 +- lectures/numpy.md | 2 +- lectures/oop_intro.md | 2 +- lectures/pandas.md | 2 +- lectures/parallelization.md | 2 +- lectures/python_advanced_features.md | 2 +- lectures/python_by_example.md | 2 +- lectures/python_essentials.md | 2 +- lectures/python_oop.md | 2 +- lectures/scipy.md | 2 +- lectures/troubleshooting.md | 2 +- lectures/writing_good_code.md | 2 +- 19 files changed, 18 insertions(+), 19 deletions(-) diff --git a/lectures/_config.yml b/lectures/_config.yml index 1b9d9d96..cd99382b 100644 --- a/lectures/_config.yml +++ b/lectures/_config.yml @@ -33,7 +33,6 @@ sphinx: tojupyter_urlpath: "https://python-programming.quantecon.org/" tojupyter_image_urlpath: "https://python-programming.quantecon.org/_static/" tojupyter_lang_synonyms: ["ipython", "ipython3", "python"] - tojupyter_allow_html_only: true tojupyter_kernels: python3: kernelspec: diff --git a/lectures/about_py.md b/lectures/about_py.md index 7988d5af..cfd17c6a 100644 --- a/lectures/about_py.md +++ b/lectures/about_py.md @@ -10,7 +10,7 @@ kernelspec: --- (about_py)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/debugging.md b/lectures/debugging.md index fcff099e..162d4720 100644 --- a/lectures/debugging.md +++ b/lectures/debugging.md @@ -10,7 +10,7 @@ kernelspec: --- (debugging)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/functions.md b/lectures/functions.md index 9ebe170b..9a8459cc 100644 --- a/lectures/functions.md +++ b/lectures/functions.md @@ -10,7 +10,7 @@ kernelspec: --- (functions)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/getting_started.md b/lectures/getting_started.md index b7dede3e..c83d393b 100644 --- a/lectures/getting_started.md +++ b/lectures/getting_started.md @@ -10,7 +10,7 @@ kernelspec: --- (getting_started)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/matplotlib.md b/lectures/matplotlib.md index 9e7fcdb8..cdd00b58 100644 --- a/lectures/matplotlib.md +++ b/lectures/matplotlib.md @@ -10,7 +10,7 @@ kernelspec: --- (matplotlib)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/need_for_speed.md b/lectures/need_for_speed.md index 55c53d20..602762b8 100644 --- a/lectures/need_for_speed.md +++ b/lectures/need_for_speed.md @@ -10,7 +10,7 @@ kernelspec: --- (speed)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/numba.md b/lectures/numba.md index 4d7dfceb..dd90e086 100644 --- a/lectures/numba.md +++ b/lectures/numba.md @@ -10,7 +10,7 @@ kernelspec: --- (speed)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/numpy.md b/lectures/numpy.md index de4c38df..015f7f50 100644 --- a/lectures/numpy.md +++ b/lectures/numpy.md @@ -10,7 +10,7 @@ kernelspec: --- (np)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/oop_intro.md b/lectures/oop_intro.md index 44b7ed76..c83c6987 100644 --- a/lectures/oop_intro.md +++ b/lectures/oop_intro.md @@ -10,7 +10,7 @@ kernelspec: --- (oop_intro)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/pandas.md b/lectures/pandas.md index e6ec472c..baf87644 100644 --- a/lectures/pandas.md +++ b/lectures/pandas.md @@ -10,7 +10,7 @@ kernelspec: --- (pd)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/parallelization.md b/lectures/parallelization.md index 7f9e1fd8..e5c9cff3 100644 --- a/lectures/parallelization.md +++ b/lectures/parallelization.md @@ -10,7 +10,7 @@ kernelspec: --- (parallel)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/python_advanced_features.md b/lectures/python_advanced_features.md index f7d86d16..ab93552b 100644 --- a/lectures/python_advanced_features.md +++ b/lectures/python_advanced_features.md @@ -10,7 +10,7 @@ kernelspec: --- (python_advanced_features)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/python_by_example.md b/lectures/python_by_example.md index 2ed6a8e9..44958ef5 100644 --- a/lectures/python_by_example.md +++ b/lectures/python_by_example.md @@ -10,7 +10,7 @@ kernelspec: --- (python_by_example)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/python_essentials.md b/lectures/python_essentials.md index 1452803e..954e59d8 100644 --- a/lectures/python_essentials.md +++ b/lectures/python_essentials.md @@ -10,7 +10,7 @@ kernelspec: --- (python_done_right)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/python_oop.md b/lectures/python_oop.md index 7cbe0d90..3c0a778c 100644 --- a/lectures/python_oop.md +++ b/lectures/python_oop.md @@ -10,7 +10,7 @@ kernelspec: --- (python_oop)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/scipy.md b/lectures/scipy.md index b5eafdf8..06d95f79 100644 --- a/lectures/scipy.md +++ b/lectures/scipy.md @@ -10,7 +10,7 @@ kernelspec: --- (sp)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/troubleshooting.md b/lectures/troubleshooting.md index d3268bf5..dd836652 100644 --- a/lectures/troubleshooting.md +++ b/lectures/troubleshooting.md @@ -10,7 +10,7 @@ kernelspec: --- (troubleshooting)= -```{raw} html +```{raw} jupyter
QuantEcon diff --git a/lectures/writing_good_code.md b/lectures/writing_good_code.md index 42b4ee3e..f6bd5f40 100644 --- a/lectures/writing_good_code.md +++ b/lectures/writing_good_code.md @@ -10,7 +10,7 @@ kernelspec: --- (writing_good_code)= -```{raw} html +```{raw} jupyter
QuantEcon From 8757c214116f71ecf8948532b5b0f0e066f077d2 Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 27 Nov 2020 10:25:21 +1100 Subject: [PATCH 6/9] add test run for theme branch --- .github/workflows/ci.yml | 6 ++++++ environment.yml | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7591f0c..927d9fbb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,12 @@ jobs: python-version: 3.8 environment-file: environment.yml activate-environment: lecture-python-programming + - name: Install QuantEcon Book Theme + shell: bash -l {0} + run: | + git clone https://github.com/quantecon/quantecon-book-theme + cd quantecon-book-theme && git checkout download-nb && cd .. + python setup.py install - name: Display Conda Environment Versions shell: bash -l {0} run: conda list diff --git a/environment.yml b/environment.yml index 3f7282ef..b8a2122b 100644 --- a/environment.yml +++ b/environment.yml @@ -9,7 +9,6 @@ dependencies: - git+https://github.com/executablebooks/jupyter-book.git - sphinxext-rediraffe - git+https://github.com/executablebooks/sphinx-multitoc-numbering - - git+https://github.com/quantecon/quantecon-book-theme - git+https://github.com/executablebooks/sphinx-exercise.git - joblib - interpolation From 1ecf66afb123eb6b0a284a37ebc99b50aea7403b Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 27 Nov 2020 10:29:53 +1100 Subject: [PATCH 7/9] fix test run of branch --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 927d9fbb..ae26b70c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,8 +19,9 @@ jobs: shell: bash -l {0} run: | git clone https://github.com/quantecon/quantecon-book-theme - cd quantecon-book-theme && git checkout download-nb && cd .. + cd quantecon-book-theme && git checkout download-nb python setup.py install + cd .. && rm -r quantecon-book-theme - name: Display Conda Environment Versions shell: bash -l {0} run: conda list From 41f55965290b9eae7b6fbd6489771047bed1a42b Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 27 Nov 2020 11:08:09 +1100 Subject: [PATCH 8/9] enable html targetting --- lectures/_config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/lectures/_config.yml b/lectures/_config.yml index cd99382b..33acc117 100644 --- a/lectures/_config.yml +++ b/lectures/_config.yml @@ -30,6 +30,7 @@ sphinx: rediraffe_redirects: index_toc.md: intro.md tojupyter_static_file_path: ["source/_static", "_static"] + tojupyter_target_html: true tojupyter_urlpath: "https://python-programming.quantecon.org/" tojupyter_image_urlpath: "https://python-programming.quantecon.org/_static/" tojupyter_lang_synonyms: ["ipython", "ipython3", "python"] From 21ac09670e093361cadc2cf0d19df07b4d81d6d7 Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 27 Nov 2020 11:59:13 +1100 Subject: [PATCH 9/9] remove pdf templates and settings for now and deploy in a different PR --- lectures/_config.yml | 3 - templates/latex.tpl | 323 --------------------------------------- templates/latex_book.tpl | 319 -------------------------------------- 3 files changed, 645 deletions(-) delete mode 100644 templates/latex.tpl delete mode 100644 templates/latex_book.tpl diff --git a/lectures/_config.yml b/lectures/_config.yml index 33acc117..6db4582a 100644 --- a/lectures/_config.yml +++ b/lectures/_config.yml @@ -42,6 +42,3 @@ sphinx: name: python3 file_extension: ".py" tojupyter_images_markdown: true - tojupyter_template_path: ../templates/ - tojupyter_latex_template: latex.tpl - tojupyter_latex_template_book: latex_book.tpl diff --git a/templates/latex.tpl b/templates/latex.tpl deleted file mode 100644 index 86405eff..00000000 --- a/templates/latex.tpl +++ /dev/null @@ -1,323 +0,0 @@ -((*- extends 'article.tplx' -*)) - -% See http://blog.juliusschulz.de/blog/ultimate-ipython-notebook#templates -% for some useful tips - -%=============================================================================== -% Document class -%=============================================================================== - -((* block docclass *)) -\documentclass[11pt, twoside, a4paper]{article} -((* endblock docclass *)) - -%=============================================================================== -% Packages -%=============================================================================== - -((* block packages *)) -\usepackage[T1]{fontenc} -\usepackage{graphicx} -\usepackage[breakable]{tcolorbox} -% We will generate all images so they have a width \maxwidth. This means -% that they will get their normal width if they fit onto the page, but -% are scaled down if they would overflow the margins. -\makeatletter -\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth -\else\Gin@nat@width\fi} -\makeatother -\let\Oldincludegraphics\includegraphics - -% propose delete% -% 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} -% \DeclareCaptionLabelFormat{empty}{} -%\captionsetup{format=empty,aboveskip=0pt,belowskip=0pt} -% end - propose delete% - -% float figure settings% -\usepackage{float} -\floatplacement{figure}{H} % used to force figures for placement in text - -\usepackage{adjustbox} % Used to constrain images to a maximum size -\usepackage{xcolor} % Allow colors to be defined -\usepackage{enumerate} % Needed for markdown enumerations to work -\usepackage{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[mathletters]{ucs} % Extended unicode (utf-8) support -\usepackage[utf8x]{inputenc} % Allow utf-8 characters in the tex document -\usepackage{fancyvrb} % verbatim replacement that allows latex -\usepackage{xcolor} -\usepackage{listings} -\lstset{escapeinside={<@}{@>}} -\usepackage{grffile} % extends the file name processing of package graphics - % to support a larger range -% 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} -\usepackage{longtable} % longtable support required by pandoc >1.10 -\usepackage{booktabs} % table support for pandoc > 1.12.2 -\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{braket} -\usepackage{mathrsfs} -\usepackage{natbib} -\usepackage[document]{ragged2e} -\usepackage{fontspec, unicode-math} -\usepackage[greek,english]{babel} -\usepackage{xunicode} -\usepackage{letltxmacro} -\newcommand{\argmax}{\operatornamewithlimits{argmax}} -\newcommand{\argmin}{\operatornamewithlimits{argmin}} -\DeclareMathOperator{\col}{col} -\setlength{\parskip}{1.5ex plus0.5ex minus0.5ex} -\setlength{\parindent}{0pt} - -\usepackage{letltxmacro} -% https://tex.stackexchange.com/q/88001/5764 -\LetLtxMacro\oldttfamily\ttfamily -\DeclareRobustCommand{\ttfamily}{\oldttfamily\csname ttsize\endcsname} -\newcommand{\setttsize}[1]{\def\ttsize{#1}}% - -\DeclareTextFontCommand{\texttt}{\ttfamily} - -% Enable Unicode characters in `Out` code-blocks within verbatim -\usepackage{pmboxdraw} - -% renew commands % -% Set max figure width to be 80% of text width, for now hardcoded. -\renewcommand{\includegraphics}[1]{\begin{center}\Oldincludegraphics[width=.8\maxwidth]{#1}\end{center}} -\renewcommand \caption [2][]{} % removes captions from all figures -\setlist[itemize]{nosep} - -% using CMU Serif for greek and latin letters in code blocks and Liberation Mono for rest% -\setmonofont{Liberation Mono} -\usepackage[Latin,Greek]{ucharclasses} -\newfontfamily\substitutefont{CMU Serif} -\setTransitionsForGreek{\begingroup\substitutefont}{\endgroup} -((* endblock packages *)) - -% 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} - - -% 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} - -%=============================================================================== -% Title Page -%=============================================================================== - -((* block maketitle *)) -\setttsize{\footnotesize} - -\title{((( nb.metadata.get("latex_metadata", {}).get("title", "") | escape_latex )))} - -((*- if nb.metadata.get("latex_metadata", {}).get("author", ""): -*)) -\author{((( nb.metadata["latex_metadata"]["author"] )))} -((*- endif *)) - -((*- if nb.metadata.get("latex_metadata", {}).get("affiliation", ""): -*)) -\affiliation{((( nb.metadata["latex_metadata"]["affiliation"] )))} -((*- endif *)) - -\date{\today} -\maketitle - -((*- if nb.metadata.get("latex_metadata", {}).get("logo", ""): -*)) -\begin{center} - \adjustimage{max size={0.6\linewidth}{0.6\paperheight}}{((( nb.metadata["latex_metadata"]["logo"] )))} -\end{center} -((*- endif -*)) - -% delete-till-here-book % -((* endblock maketitle *)) - - -%=============================================================================== -% Input -%=============================================================================== - -% Input cells can be hidden using the "Hide input" and "Hide input all" -% nbextensions (which set the hide_input metadata flags) - -((* block input scoped *)) -((( cell.metadata.get("hide_input", "") ))) -((*- if cell.metadata.hide_input or nb.metadata.hide_input or cell.metadata.get("hide_input", ""): -*)) -((*- else -*)) - ((( custom_add_prompt(cell.source | wrap_text(88) | highlight_code(strip_verbatim=True), cell, 'In ', 'incolor', 'plain') ))) -((*- endif *)) -((* endblock input *)) - - -%=============================================================================== -% Output -%=============================================================================== - -((* block output_group -*)) -((*- if cell.metadata.hide_output: -*)) -((*- else -*)) - ((( super() ))) -((*- endif -*)) -((* endblock output_group *)) - -((* block execute_result scoped *)) - ((*- for type in output.data | filter_data_type -*)) - ((*- if type in ['text/plain']*)) - ((( custom_add_prompt(output.data['text/plain'] | wrap_text(88) | escape_latex | ansi2latex, cell, 'Out', 'outcolor', 'plain') ))) - ((*- elif type in ['text/latex']*)) - ((( custom_add_prompt(output.data['text/latex'] | wrap_text(88) | ansi2latex, cell, 'Out', 'outcolor', 'latex') ))) - ((* else -*)) - ((( custom_add_prompt( '' | wrap_text(88)| escape_latex | ansi2latex, cell, 'Out', 'outcolor', 'plain') ))) - ((*- endif -*)) - ((*- endfor -*)) -((* endblock execute_result *)) - -% Display stream ouput with coloring -((* block stream *)) -\begin{Verbatim}[commandchars=\\\{\}, fontsize=\footnotesize] - ((( output.text | wrap_text(86) | escape_latex | ansi2latex ))) -\end{Verbatim} -%((* endblock stream *)) - -%============================================================================== -% Define macro custom_add_prompt() (derived from add_prompt() macro in style_ipython.tplx) -%============================================================================== - -((* macro custom_add_prompt(text, cell, prompt, prompt_color, type) -*)) - ((*- if cell.execution_count is defined -*)) - ((*- set execution_count = "" ~ (cell.execution_count | replace(None, " ")) -*)) - ((*- else -*)) - ((*- set execution_count = "" -*)) - ((*- endif -*)) - ((*- set indention = " " * (execution_count | length + 7) -*)) -((*- if type == 'plain' -*)) -\begin{Verbatim}[commandchars=\\\{\}, fontsize=\small, xleftmargin=-3.9em] -((( text.replace('$$','').replace('$\\',"\\(\\").replace('$','\)') | add_prompts(first='{\color{' ~ prompt_color ~ '}' ~ prompt ~ '[{\\color{' ~ prompt_color ~ '}' ~ execution_count ~ '}]:} ', cont=indention) ))) -\end{Verbatim} -((*- else -*)) -\begin{lstlisting}[mathescape, basicstyle=\small\ttfamily\color{black}, keywordstyle={\color{red}}, xleftmargin=-4.8em] -((( text | add_prompts(first='<@\\textcolor{red}{' ~ prompt ~ '[' ~ execution_count ~ ']: }@>', cont=indention) ))) -\end{lstlisting} -((*- endif -*)) -((*- endmacro *)) - -%============================================================================== -% Support Macros -%============================================================================== - -% 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 *)) - - -%============================================================================== -% Bibliography -%============================================================================== - -% Insert citations in markdown as e.g. -% [DevoretS2013] -% requires file references.bib in current directory (or the file set as "bib" in the latex_metadata) - - -((* block bibliography *)) -% delete-from-here-book % -((*- if nb.metadata.get("latex_metadata", {}).get("bib_include", ""): -*)) -% Add a bibliography block to the postdoc -\bibliographystyle{plain} -\bibliography{((( nb.metadata.get("latex_metadata", {}).get("bib", "quant-econ") )))} -((*- endif -*)) -((* endblock bibliography *)) diff --git a/templates/latex_book.tpl b/templates/latex_book.tpl deleted file mode 100644 index 23813f14..00000000 --- a/templates/latex_book.tpl +++ /dev/null @@ -1,319 +0,0 @@ -((*- extends 'article.tplx' -*)) - -% See http://blog.juliusschulz.de/blog/ultimate-ipython-notebook#templates -% for some useful tips - -%=============================================================================== -% Document class -%=============================================================================== - -((* block docclass *)) -\documentclass[a4paper,11pt, twoside]{book} -((* endblock docclass *)) - -%=============================================================================== -% Packages -%=============================================================================== - -((* block packages *)) -\usepackage[T1]{fontenc} -\usepackage{graphicx} -\usepackage[breakable]{tcolorbox} -% We will generate all images so they have a width \maxwidth. This means -% that they will get their normal width if they fit onto the page, but -% are scaled down if they would overflow the margins. -\makeatletter -\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth -\else\Gin@nat@width\fi} -\makeatother -\let\Oldincludegraphics\includegraphics - -% propose delete% -% 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} -% \DeclareCaptionLabelFormat{empty}{} -%\captionsetup{format=empty,aboveskip=0pt,belowskip=0pt} -% end - propose delete% - -% float figure settings% -\usepackage{float} -\floatplacement{figure}{H} % used to force figures for placement in text - -\usepackage{adjustbox} % Used to constrain images to a maximum size -\usepackage{xcolor} % Allow colors to be defined -\usepackage{enumerate} % Needed for markdown enumerations to work -\usepackage{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[mathletters]{ucs} % Extended unicode (utf-8) support -\usepackage[utf8x]{inputenc} % Allow utf-8 characters in the tex document -\usepackage{fancyvrb} % verbatim replacement that allows latex -\usepackage{listings} -\lstset{escapeinside={<@}{@>}} -\usepackage{grffile} % extends the file name processing of package graphics - % to support a larger range -% 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} -\usepackage{longtable} % longtable support required by pandoc >1.10 -\usepackage{booktabs} % table support for pandoc > 1.12.2 -\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{braket} -\usepackage{mathrsfs} -\usepackage{natbib} -\usepackage[document]{ragged2e} -\usepackage{fontspec, unicode-math} -\usepackage[greek,english]{babel} -\usepackage{xunicode} -\usepackage{letltxmacro} -\newcommand{\argmax}{\operatornamewithlimits{argmax}} -\newcommand{\argmin}{\operatornamewithlimits{argmin}} -\DeclareMathOperator{\col}{col} -\setlength{\parskip}{1.5ex plus0.5ex minus0.5ex} -\setlength{\parindent}{0pt} - -\usepackage{letltxmacro} -% https://tex.stackexchange.com/q/88001/5764 -\LetLtxMacro\oldttfamily\ttfamily -\DeclareRobustCommand{\ttfamily}{\oldttfamily\csname ttsize\endcsname} -\newcommand{\setttsize}[1]{\def\ttsize{#1}}% - -\DeclareTextFontCommand{\texttt}{\ttfamily} - -% Enable Unicode characters in `Out` code-blocks within verbatim -\usepackage{pmboxdraw} - -% renew commands % -% Set max figure width to be 80% of text width, for now hardcoded. -\renewcommand{\includegraphics}[1]{\begin{center}\Oldincludegraphics[width=.8\maxwidth]{#1}\end{center}} -\renewcommand \caption [2][]{} % removes captions from all figures -\setlist[itemize]{nosep} - -% using CMU Serif for greek and latin letters in code blocks and Liberation Mono for rest% -\setmonofont{Liberation Mono} -\usepackage[Latin,Greek]{ucharclasses} -\newfontfamily\substitutefont{CMU Serif} -\setTransitionsForGreek{\begingroup\substitutefont}{\endgroup} -((* endblock packages *)) - -% 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} - - -% 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} - -%=============================================================================== -% Title Page -%=============================================================================== - -((* block maketitle *)) -\setttsize{\footnotesize} - -((*- if nb.metadata.get("latex_metadata", {}).get("jupyter_pdf_book_title", ""): -*)) -\title{\Huge \textbf{((( nb.metadata["latex_metadata"]["jupyter_pdf_book_title"] )))}} -((*- endif *)) - -((*- if nb.metadata.get("latex_metadata", {}).get("author", ""): -*)) -\author{\textsc{((( nb.metadata["latex_metadata"]["author"] )))}} -((*- endif *)) - -((*- if nb.metadata.get("latex_metadata", {}).get("affiliation", ""): -*)) -\affiliation{((( nb.metadata["latex_metadata"]["affiliation"] )))} -((*- endif *)) - -\date{\today} -\maketitle - -\setcounter{tocdepth}{0} -\tableofcontents - - -\parskip 0.09in - -\mainmatter - -((* endblock maketitle *)) - -%=============================================================================== -% Input -%=============================================================================== - -% Input cells can be hidden using the "Hide input" and "Hide input all" -% nbextensions (which set the hide_input metadata flags) - -((* block input scoped *)) -((( cell.metadata.get("hide_input", "") ))) -((*- if cell.metadata.hide_input or nb.metadata.hide_input or cell.metadata.get("hide_input", ""): -*)) -((*- else -*)) - ((( custom_add_prompt(cell.source | wrap_text(88) | highlight_code(strip_verbatim=True), cell, 'In ', 'incolor', 'plain') ))) -((*- endif *)) -((* endblock input *)) - - -%=============================================================================== -% Output -%=============================================================================== - -((* block output_group -*)) -((*- if cell.metadata.hide_output: -*)) -((*- else -*)) - ((( super() ))) -((*- endif -*)) -((* endblock output_group *)) - -((* block execute_result scoped *)) - ((*- for type in output.data | filter_data_type -*)) - ((*- if type in ['text/plain']*)) - ((( custom_add_prompt(output.data['text/plain'] | wrap_text(88) | escape_latex | ansi2latex, cell, 'Out', 'outcolor', 'plain') ))) - ((*- elif type in ['text/latex']*)) - ((( custom_add_prompt(output.data['text/latex'] | wrap_text(88) | ansi2latex, cell, 'Out', 'outcolor', 'latex') ))) - ((* else -*)) - ((( custom_add_prompt( '' | wrap_text(88)| escape_latex | ansi2latex, cell, 'Out', 'outcolor', 'plain') ))) - ((*- endif -*)) - ((*- endfor -*)) -((* endblock execute_result *)) - -% Display stream ouput with coloring -((* block stream *)) -\begin{Verbatim}[commandchars=\\\{\}, fontsize=\footnotesize] - ((( output.text | wrap_text(86) | escape_latex | ansi2latex ))) -\end{Verbatim} -%((* endblock stream *)) - -%============================================================================== -% Define macro custom_add_prompt() (derived from add_prompt() macro in style_ipython.tplx) -%============================================================================== - -((* macro custom_add_prompt(text, cell, prompt, prompt_color, type) -*)) - ((*- if cell.execution_count is defined -*)) - ((*- set execution_count = "" ~ (cell.execution_count | replace(None, " ")) -*)) - ((*- else -*)) - ((*- set execution_count = "" -*)) - ((*- endif -*)) - ((*- set indention = " " * (execution_count | length + 7) -*)) -((*- if type == 'plain' -*)) -\begin{Verbatim}[commandchars=\\\{\}, fontsize=\small, xleftmargin=-3.9em] -((( text.replace('$$','').replace('$\\',"\\(\\").replace('$','\)') | add_prompts(first='{\color{' ~ prompt_color ~ '}' ~ prompt ~ '[{\\color{' ~ prompt_color ~ '}' ~ execution_count ~ '}]:} ', cont=indention) ))) -\end{Verbatim} -((*- else -*)) -\begin{lstlisting}[mathescape, basicstyle=\small\ttfamily\color{black}, xleftmargin=-3.9em] -((( text | add_prompts(first='<@\\textcolor{red}{' ~ prompt ~ '[' ~ execution_count ~ ']: }@>', cont=indention) ))) -\end{lstlisting} -((*- endif -*)) -((*- endmacro *)) - -%============================================================================== -% Support Macros -%============================================================================== - -% 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 *)) - - -%============================================================================== -% Bibliography -%============================================================================== - -% Insert citations in markdown as e.g. -% [DevoretS2013] -% requires file references.bib in current directory (or the file set as "bib" in the latex_metadata) - - -((* block bibliography *)) -% Add a bibliography block to the postdoc -((* endblock bibliography *))