From 930d72c697f4e61ee2c43feb60dfe9d27b46dab5 2013-09-23 17:57:21 From: Jonathan Frederic Date: 2013-09-23 17:57:21 Subject: [PATCH] Post review with Min, Fernando, and Brian. Simplification deleted: latex/abstract.tplx deleted: latex/latex_sphinx_article.tplx deleted: latex/latex_sphinx_report.tplx deleted: latex/style_notebook.tplx deleted: latex/style_simple.tplx --- diff --git a/IPython/nbconvert/templates/latex/abstract.tplx b/IPython/nbconvert/templates/latex/abstract.tplx deleted file mode 100644 index ae4b274..0000000 --- a/IPython/nbconvert/templates/latex/abstract.tplx +++ /dev/null @@ -1,19 +0,0 @@ -((= Latex abstract template (must inherit) -This template is the basic structure of all latex documents. =)) - -((*- extends 'display_priority.tplx' -*)) - -((* block header *)) - ((* block docclass *))((* endblock docclass *)) - ((* block packages *))((* endblock packages *)) - ((* block definitions *))((* endblock definitions *)) - ((* block commands *))((* endblock commands *)) -((* endblock header *)) - -((* block body *)) - \begin{document} - ((* block predoc *))((* endblock predoc *)) - ((( super() ))) - ((* block postdoc *))((* endblock postdoc *)) - \end{document} -((* endblock body *)) diff --git a/IPython/nbconvert/templates/latex/latex_article.tplx b/IPython/nbconvert/templates/latex/latex_article.tplx index b148515..be59552 100644 --- a/IPython/nbconvert/templates/latex/latex_article.tplx +++ b/IPython/nbconvert/templates/latex/latex_article.tplx @@ -1,7 +1,7 @@ % Default to the notebook output style ((* if not cell_style is defined *)) - ((* set cell_style = 'style_bw_ipython.tplx' *)) + ((* set cell_style = 'style_ipython.tplx' *)) ((* endif *)) % Inherit from the specified cell style. diff --git a/IPython/nbconvert/templates/latex/latex_base.tplx b/IPython/nbconvert/templates/latex/latex_base.tplx index ef51596..337eaef 100644 --- a/IPython/nbconvert/templates/latex/latex_base.tplx +++ b/IPython/nbconvert/templates/latex/latex_base.tplx @@ -3,13 +3,16 @@ This template builds upon the abstract template, adding common latex output functions. Figures, data_text, This template does not define a docclass, the inheriting class must define this.=)) -((*- extends 'abstract.tplx' -*)) +((*- extends 'display_priority.tplx' -*)) %=============================================================================== % Abstract overrides %=============================================================================== -((* block packages *)) +((* block header *)) + ((* block docclass *))((* endblock docclass *)) + + ((* block packages *)) \usepackage{graphicx} % Used to insert images \usepackage{adjustbox} % Used to constrain images to a maximum size \usepackage{color} % Allow colors to be defined @@ -21,16 +24,14 @@ This template does not define a docclass, the inheriting class must define this. \usepackage{ucs} % Extended unicode (utf-8) support \usepackage{fancyvrb} % verbatim replacement that allows latex \usepackage{grffile} % extends the file name processing of package graphics - %to support a larger range - + % 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} -((* endblock packages *)) - -((* block definitions *)) + ((* endblock packages *)) + ((* block definitions *)) \definecolor{orange}{cmyk}{0,0.4,0.8,0.2} \definecolor{darkorange}{rgb}{.71,0.21,0.01} \definecolor{darkgreen}{rgb}{.12,.54,.11} @@ -41,7 +42,6 @@ This template does not define a docclass, the inheriting class must define this. \definecolor{inputbackground}{rgb}{.95, .95, .85} \definecolor{outputbackground}{rgb}{.95, .95, .95} \definecolor{traceback}{rgb}{1, .95, .95} - % new ansi colors \definecolor{brown}{rgb}{0.54,0.27,0.07} \definecolor{purple}{rgb}{0.5,0.0,0.5} @@ -51,24 +51,21 @@ This template does not define a docclass, the inheriting class must define this. \definecolor{lightblue}{rgb}{0.53,0.81,0.92} \definecolor{lightpurple}{rgb}{0.87,0.63,0.87} \definecolor{lightcyan}{rgb}{0.5,1.0,0.83} - % Define a nice break command that doesn't care if a line doesn't already % exist. \def\br{\hspace*{\fill} \\* } - % Math Jax compatability definitions \def\gt{>} \def\lt{<} - % Document parameters ((* block title *))\title{((( resources.metadata.name | escape_latex )))}((* endblock title *)) ((* block date *))((* endblock date *)) ((* block author *))((* endblock author *)) -((* endblock definitions *)) - -((* block commands *)) - \sloppy % Prevent overflowing lines due to hard-to-break entities + ((* 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 @@ -77,17 +74,29 @@ This template does not define a docclass, the inheriting class must define this. linkcolor=darkorange, citecolor=darkgreen, } - % Slightly bigger margins than the latex defaults ((* block margins *)) \geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in} ((* endblock margins *)) -((* endblock commands *)) + ((* endblock commands *)) +((* endblock header *)) -((* block predoc *)) +((* block body *)) + \begin{document} + + ((* block predoc *)) ((* block maketitle *))\maketitle((* endblock maketitle *)) ((* block abstract *))((* endblock abstract *)) -((* endblock predoc *)) + ((* endblock predoc *)) + + ((( super() ))) + + % Add a bibliography block to the postdoc + ((* block postdoc *)) + ((* block bibliography *))((* endblock bibliography *)) + ((* endblock postdoc *)) + \end{document} +((* endblock body *)) %=============================================================================== % Support blocks @@ -186,8 +195,3 @@ This template does not define a docclass, the inheriting class must define this. % Don't display unknown types ((* block unknowncell scoped *)) ((* endblock unknowncell *)) - -% Add a bibliography block to the postdoc -((* block postdoc *)) - ((* block bibliography *))((* endblock bibliography *)) -((* endblock postdoc *)) \ No newline at end of file diff --git a/IPython/nbconvert/templates/latex/latex_report.tplx b/IPython/nbconvert/templates/latex/latex_report.tplx index c38cffa..3bab0d5 100644 --- a/IPython/nbconvert/templates/latex/latex_report.tplx +++ b/IPython/nbconvert/templates/latex/latex_report.tplx @@ -26,4 +26,4 @@ ((* block h3 -*))\section((* endblock h3 -*)) ((* block h4 -*))\subsection((* endblock h4 -*)) ((* block h5 -*))\subsubsection((* endblock h5 -*)) -((* block h6 -*))\paragraph((* endblock h6 -*)) \ No newline at end of file +((* block h6 -*))\paragraph((* endblock h6 -*)) diff --git a/IPython/nbconvert/templates/latex/latex_sphinx_article.tplx b/IPython/nbconvert/templates/latex/latex_sphinx_article.tplx deleted file mode 100644 index 203a1c1..0000000 --- a/IPython/nbconvert/templates/latex/latex_sphinx_article.tplx +++ /dev/null @@ -1,38 +0,0 @@ -((* extends 'latex_article.tplx' *)) - -%=============================================================================== -% Latex Sphinx Article -%=============================================================================== - -((* block docclass *)) - % Make sure that the sphinx doc style knows who it inherits from. - \def\sphinxdocclass{article} - - % Declare the document class - \documentclass[letterpaper,10pt,english]{((( resources.sphinx.texinputs | posix_path )))/sphinxhowto} -((* endblock docclass *)) - -((* block packages *)) - ((* block chstyle *)) - \usepackage[Bjarne]{((( resources.sphinx.texinputs | posix_path )))/fncychap} - ((* endblock chstyle *)) - - \usepackage{((( resources.sphinx.texinputs | posix_path )))/sphinx} - - ((( super() ))) -((* endblock packages *)) - -((* block commands *)) - ((( super() ))) - - % Override to specify your own logo - ((* block logo *))\newcommand{\sphinxlogo}{}((* endblock logo *)) - - % Make the index page of the document. - \makeindex - -((* endblock commands *)) - -% Work around to fix vertical spacing issues with the notebook style. -((* block extra_input_spacing *))\vspace{-1\baselineskip}((* endblock extra_input_spacing *)) -((* block extra_output_spacing *))\vspace{-0.6\baselineskip}((* endblock extra_output_spacing *)) diff --git a/IPython/nbconvert/templates/latex/latex_sphinx_report.tplx b/IPython/nbconvert/templates/latex/latex_sphinx_report.tplx deleted file mode 100644 index c00b602..0000000 --- a/IPython/nbconvert/templates/latex/latex_sphinx_report.tplx +++ /dev/null @@ -1,38 +0,0 @@ -((* extends 'latex_report.tplx' *)) - -%=============================================================================== -% Latex Sphinx Book -%=============================================================================== - -((* block docclass *)) - % Make sure that the sphinx doc style knows who it inherits from. - \def\sphinxdocclass{report} - - % Declare the document class - \documentclass[letterpaper,10pt,english]{((( resources.sphinx.texinputs | posix_path )))/sphinxmanual} -((* endblock docclass *)) - -((* block packages *)) - ((* block chstyle *)) - \usepackage[Bjarne]{((( resources.sphinx.texinputs | posix_path )))/fncychap} - ((* endblock chstyle *)) - - \usepackage{((( resources.sphinx.texinputs | posix_path )))/sphinx} - - ((( super() ))) -((* endblock packages *)) - -((* block commands *)) - ((( super() ))) - - % Override to specify your own logo - ((* block logo *))\newcommand{\sphinxlogo}{}((* endblock logo *)) - - % Make the index page of the document. - \makeindex - -((* endblock commands *)) - -% Work around to fix vertical spacing issues with the notebook style. -((* block extra_input_spacing *))\vspace{-1\baselineskip}((* endblock extra_input_spacing *)) -((* block extra_output_spacing *))\vspace{-0.6\baselineskip}((* endblock extra_output_spacing *)) diff --git a/IPython/nbconvert/templates/latex/style_notebook.tplx b/IPython/nbconvert/templates/latex/style_notebook.tplx deleted file mode 100644 index 2ef9633..0000000 --- a/IPython/nbconvert/templates/latex/style_notebook.tplx +++ /dev/null @@ -1,188 +0,0 @@ -((= Notebook input/output style =)) - -((* extends 'latex_base.tplx' *)) - -% Custom packages -((* block packages *)) - ((( super() ))) - - \usepackage{tikz} % Needed to box output/input - \usepackage{scrextend} % Used to indent output - \usepackage{needspace} % Make prompts follow contents - \usepackage{framed} % Used to draw output that spans multiple pages -((* endblock packages *)) - -% Custom definitions -((* block definitions *)) - ((( super() ))) - - % Pygments definitions - ((( resources.latex.pygments_definitions ))) - - % NB prompt colors - \definecolor{nbframe-border}{rgb}{0.867,0.867,0.867} - \definecolor{nbframe-bg}{rgb}{0.969,0.969,0.969} - \definecolor{nbframe-in-prompt}{rgb}{0.0,0.0,0.502} - \definecolor{nbframe-out-prompt}{rgb}{0.545,0.0,0.0} - - % NB prompt lengths - \newlength{\inputpadding} - \setlength{\inputpadding}{0.5em} - \newlength{\cellleftmargin} - \setlength{\cellleftmargin}{0.15\linewidth} - \newlength{\borderthickness} - \setlength{\borderthickness}{0.4pt} - \newlength{\smallerfontscale} - \setlength{\smallerfontscale}{9.5pt} - - % NB prompt font size - \def\smaller{\fontsize{\smallerfontscale}{\smallerfontscale}\selectfont} - - % Define a background layer, in which the nb prompt shape is drawn - \pgfdeclarelayer{background} - \pgfsetlayers{background,main} - \usetikzlibrary{calc} - - % define styles for the normal border and the torn border - \tikzset{ - normal border/.style={draw=nbframe-border, fill=nbframe-bg, - rectangle, rounded corners=2.5pt, line width=\borderthickness}, - torn border/.style={draw=white, fill=white, line width=\borderthickness}} - - % Macro to draw the shape behind the text, when it fits completly in the - % page - \def\notebookcellframe#1{% - \tikz{% - \node[inner sep=\inputpadding] (A) {#1};% Draw the text of the node - \begin{pgfonlayer}{background}% Draw the shape behind - \fill[normal border]% - (A.south east) -- ($(A.south west)+(\cellleftmargin,0)$) -- - ($(A.north west)+(\cellleftmargin,0)$) -- (A.north east) -- cycle; - \end{pgfonlayer}}}% - - % Macro to draw the shape, when the text will continue in next page - \def\notebookcellframetop#1{% - \tikz{% - \node[inner sep=\inputpadding] (A) {#1}; % Draw the text of the node - \begin{pgfonlayer}{background} - \fill[normal border] % Draw the ``complete shape'' behind - (A.south east) -- ($(A.south west)+(\cellleftmargin,0)$) -- - ($(A.north west)+(\cellleftmargin,0)$) -- (A.north east) -- cycle; - \fill[torn border] % Add the torn lower border - ($(A.south east)-(0,.1)$) -- ($(A.south west)+(\cellleftmargin,-.1)$) -- - ($(A.south west)+(\cellleftmargin,.1)$) -- ($(A.south east)+(0,.1)$) -- cycle; - \end{pgfonlayer}}} - - % Macro to draw the shape, when the text continues from previous page - \def\notebookcellframebottom#1{% - \tikz{% - \node[inner sep=\inputpadding] (A) {#1}; % Draw the text of the node - \begin{pgfonlayer}{background} - \fill[normal border] % Draw the ``complete shape'' behind - (A.south east) -- ($(A.south west)+(\cellleftmargin,0)$) -- - ($(A.north west)+(\cellleftmargin,0)$) -- (A.north east) -- cycle; - \fill[torn border] % Add the torn upper border - ($(A.north east)-(0,.1)$) -- ($(A.north west)+(\cellleftmargin,-.1)$) -- - ($(A.north west)+(\cellleftmargin,.1)$) -- ($(A.north east)+(0,.1)$) -- cycle; - \end{pgfonlayer}}} - - % Macro to draw the shape, when both the text continues from previous page - % and it will continue in next page - \def\notebookcellframemiddle#1{% - \tikz{% - \node[inner sep=\inputpadding] (A) {#1}; % Draw the text of the node - \begin{pgfonlayer}{background} - \fill[normal border] % Draw the ``complete shape'' behind - (A.south east) -- ($(A.south west)+(\cellleftmargin,0)$) -- - ($(A.north west)+(\cellleftmargin,0)$) -- (A.north east) -- cycle; - \fill[torn border] % Add the torn lower border - ($(A.south east)-(0,.1)$) -- ($(A.south west)+(\cellleftmargin,-.1)$) -- - ($(A.south west)+(\cellleftmargin,.1)$) -- ($(A.south east)+(0,.1)$) -- cycle; - \fill[torn border] % Add the torn upper border - ($(A.north east)-(0,.1)$) -- ($(A.north west)+(\cellleftmargin,-.1)$) -- - ($(A.north west)+(\cellleftmargin,.1)$) -- ($(A.north east)+(0,.1)$) -- cycle; - \end{pgfonlayer}}} - - % Define the environment which puts the frame - \newenvironment{notebookcell}[1][0]{% - \def\FrameCommand{\notebookcellframe}% - \def\FirstFrameCommand{\notebookcellframetop}% - \def\LastFrameCommand{\notebookcellframebottom}% - \def\MidFrameCommand{\notebookcellframemiddle}% - \par\vspace{1\baselineskip}% - \MakeFramed {\FrameRestore}% - \noindent\tikz\node[inner sep=0em] at ($(A.north west)-(0,0)$) {% - ((( draw_prompt("In", "#1", "nbframe-in-prompt", "2pt") )))% - }; \par}% - {\endMakeFramed} - -((* endblock definitions *)) - -%=============================================================================== -% Input -%=============================================================================== - -((* block input scoped *)) - % Add contents below. - -{\par% -\vspace{-1\baselineskip}% -\needspace{4\baselineskip}}% -\begin{notebookcell}[((( cell.prompt_number )))]% -\begin{addmargin}[\cellleftmargin]{0em}% left, right -{\smaller% -\par% -((* block extra_input_spacing *))((* endblock extra_input_spacing *))% -\vspace{-1\smallerfontscale}% -((( cell.input | highlight2latex )))% -\par% -\vspace{-1\smallerfontscale}}% -\end{addmargin} -\end{notebookcell} - -((* endblock input *)) - -%=============================================================================== -% Output -%=============================================================================== - -((* block output -*)) - \par\vspace{1\smallerfontscale}% - \needspace{4\baselineskip}% - % Only render the prompt if the cell is pyout. Note, the outputs prompt - % block isn't used since we need to check each indiviual output and only - % add prompts to the pyout ones. - ((* if output.output_type in ['pyout'] *)) - {\par% - \vspace{-1\smallerfontscale}% - \noindent% - ((( draw_prompt("Out", cell.prompt_number, "nbframe-out-prompt", "0em") )))% - ((* block extra_output_spacing *))((* endblock extra_output_spacing *))}% - ((* endif *))% - % - \begin{addmargin}[\cellleftmargin]{0em}% left, right - {\smaller% - \vspace{-1\smallerfontscale}% - ((( super() )))}% - \end{addmargin}% -((*- endblock output *)) - -%============================================================================== -% Support Macros -%============================================================================== - -% Name: draw_prompt -% Purpose: Renders an output/input prompt for notebook style pdfs -((* macro draw_prompt(prompt, number, color, space) -*)) - \begin{minipage}{\cellleftmargin}% - \hfill% - {\smaller% - \tt% - \color{(((color)))}% - (((prompt)))[(((number)))]:}% - \hspace{\inputpadding}% - \hspace{(((space)))}% - \hspace{3pt}% - \end{minipage}% -((*- endmacro *)) - diff --git a/IPython/nbconvert/templates/latex/style_simple.tplx b/IPython/nbconvert/templates/latex/style_simple.tplx deleted file mode 100644 index 371960e..0000000 --- a/IPython/nbconvert/templates/latex/style_simple.tplx +++ /dev/null @@ -1,68 +0,0 @@ -((= Simple input/output style =)) - -((*- extends 'latex_base.tplx' -*)) - -% Custom packages -((* block packages *)) - ((( super() ))) - - \usepackage{needspace} % Make prompts follow contents -((* endblock packages *)) - -% Custom definitions -((* block definitions *)) - ((( super() ))) - - % Pygments definitions - ((( resources.latex.pygments_definitions ))) - - \newlength{\promptspace} - \setlength{\promptspace}{4\baselineskip} % Space needed to start a new - % input/output -((* endblock definitions *)) -%=============================================================================== -% Input -%=============================================================================== - -((*- block in_prompt scoped -*)) - \par\vspace{-1\baselineskip} - ((( draw_prompt('Input') ))) -((*- endblock in_prompt -*)) - -((*- block input_group scoped -*)) - (((- super() ))) - \par\vspace{-2\baselineskip} -((* endblock input_group -*)) - -((* block input scoped *)) - ((( cell.input | highlight2latex ))) -((* endblock input *)) - -%=============================================================================== -% Output -%=============================================================================== - -((*- block output_prompt scoped -*)) - ((( draw_prompt('Output') ))) -((*- endblock output_prompt -*)) - -((*- block output_group scoped -*)) - (((- super() ))) - \par\vspace{-1\baselineskip} -((* endblock output_group -*)) - -%============================================================================== -% Support Macros -%============================================================================== - -% Name: draw_prompt -% Purpose: Renders an output/input prompt for notebook style pdfs -((* macro draw_prompt(prompt) *)) - % Add a horizantal break, along with break title. - \needspace{\promptspace} - \br\br - {\scriptsize ((( prompt )))} - \br - \rule[10pt]{\linewidth}{0.5pt} - \vspace{-2.5em} -((* endmacro *))