From a63e03e3019dfebee070f63286ec9ff7332bd9d1 Mon Sep 17 00:00:00 2001 From: Roger Labbe Date: Tue, 8 May 2018 17:36:56 -0700 Subject: [PATCH] Added in/out back to cell output It was too hard to tell what was embedded sample code and what was true cell input/output. --- pdf/book.tplx | 80 ++++++--------------------------------------------- 1 file changed, 9 insertions(+), 71 deletions(-) diff --git a/pdf/book.tplx b/pdf/book.tplx index 1df4aa0..eab07cc 100644 --- a/pdf/book.tplx +++ b/pdf/book.tplx @@ -1,10 +1,15 @@ -% Inherit from report -((= IPython input/output style =)) +% Default to the notebook output style +((* if not cell_style is defined *)) + ((* set cell_style = 'style_ipython.tplx' *)) +((* endif *)) + +% Inherit from the specified cell style. +((* extends cell_style *)) + + -((*- extends 'report.tplx' -*)) - ((* block docclass *)) \documentclass{book} \setcounter{chapter}{0} @@ -25,72 +30,5 @@ ((* block tableofcontents *))\tableofcontents((* endblock tableofcontents *)) ((* endblock predoc *)) -((* block markdowncell scoped *)) -\normalem -\setlength{\parindent}{0em} -\setlength{\parskip}{0.5em} - ((( cell.source | citation2latex | strip_files_prefix | markdown2latex(extra_args=["--top-level-division=chapter"]) ))) -((* endblock markdowncell *)) -% Custom definitions -((* block definitions *)) - ((( super() ))) - - % Pygments definitions - ((( resources.latex.pygments_definitions ))) - - % Exact colors from NB - \definecolor{incolor}{rgb}{0.0, 0.0, 0.5} - \definecolor{outcolor}{rgb}{0.545, 0.0, 0.0} - -((* endblock definitions *)) - -%=============================================================================== -% Input -%=============================================================================== - -((* block input scoped *)) -%\noindent\rule[0.5ex]{\linewidth}{1pt} -((*- if resources.global_content_filter.include_input_prompt *)) - ((( add_prompt(cell.source | highlight_code(strip_verbatim=True, metadata=cell.metadata), cell, 'in :', 'incolor') ))) -((* endif *)) -((* endblock input *)) - - -%=============================================================================== -% Output -%=============================================================================== - -((* block execute_result scoped *)) -%\noindent\rule[1.0ex]{\linewidth}{1pt} -% Output: - ((*- for type in output.data | filter_data_type -*)) - ((*- if resources.global_content_filter.include_output_prompt -*)) - ((*- if type in ['text/plain'] *)) -((( add_prompt(output.data['text/plain'] | escape_latex, cell, 'out:', 'outcolor') ))) - ((* else -*)) -\texttt{\color{outcolor}out:[{\color{outcolor}((( cell.execution_count )))}]:}((( super() ))) - ((*- endif -*)) - ((*- endif -*)) - ((*- endfor -*)) -((* endblock execute_result *)) - - -%============================================================================== -% Support Macros -%============================================================================== - -% Name: draw_prompt -% Purpose: Renders an output/input prompt -((* macro add_prompt(text, cell, prompt, prompt_color) -*)) - ((*- if cell.execution_count is defined -*)) - ((*- set execution_count = "" ~ (cell.execution_count | replace(None, " ")) -*)) - ((*- else -*)) - ((*- set execution_count = " " -*)) - ((*- endif -*)) - ((*- set indention = " " -*)) -\begin{Verbatim}[commandchars=\\\{\}] -((( text ))) -\end{Verbatim} -((*- endmacro *))