##// END OF EJS Templates
my attempt to fix #3735...
Paul Ivanov -
Show More
@@ -1,450 +1,450 b''
1 ((= NBConvert Sphinx-Latex Template
1 ((= NBConvert Sphinx-Latex Template
2
2
3 Purpose: Allow export of PDF friendly Latex inspired by Sphinx. Most of the
3 Purpose: Allow export of PDF friendly Latex inspired by Sphinx. Most of the
4 template is derived directly from Sphinx source.
4 template is derived directly from Sphinx source.
5
5
6 Inheritance: null>display_priority
6 Inheritance: null>display_priority
7
7
8 Note: For best display, use latex syntax highlighting. =))
8 Note: For best display, use latex syntax highlighting. =))
9
9
10 ((*- extends 'display_priority.tplx' -*))
10 ((*- extends 'display_priority.tplx' -*))
11
11
12 %==============================================================================
12 %==============================================================================
13 % Declarations
13 % Declarations
14 %==============================================================================
14 %==============================================================================
15
15
16 % In order to make sure that the input/output header follows the code it
16 % In order to make sure that the input/output header follows the code it
17 % preceeds, the needspace package is used to request that a certain
17 % preceeds, the needspace package is used to request that a certain
18 % amount of lines (specified by this variable) are reserved. If those
18 % amount of lines (specified by this variable) are reserved. If those
19 % lines aren't available on the current page, the documenter will break
19 % lines aren't available on the current page, the documenter will break
20 % to the next page and the header along with accomanying lines will be
20 % to the next page and the header along with accomanying lines will be
21 % rendered together. This value specifies the number of lines that
21 % rendered together. This value specifies the number of lines that
22 % the header will be forced to group with without a page break.
22 % the header will be forced to group with without a page break.
23 ((*- set min_header_lines = 4 -*))
23 ((*- set min_header_lines = 4 -*))
24
24
25 % This is the number of characters that are permitted per line. It's
25 % This is the number of characters that are permitted per line. It's
26 % important that this limit is set so characters do not run off the
26 % important that this limit is set so characters do not run off the
27 % edges of latex pages (since latex does not always seem smart enough
27 % edges of latex pages (since latex does not always seem smart enough
28 % to prevent this in some cases.) This is only applied to textual output
28 % to prevent this in some cases.) This is only applied to textual output
29 ((* if resources.sphinx.outputstyle == 'simple' *))
29 ((* if resources.sphinx.outputstyle == 'simple' *))
30 ((*- set wrap_size = 85 -*))
30 ((*- set wrap_size = 85 -*))
31 ((* elif resources.sphinx.outputstyle == 'notebook' *))
31 ((* elif resources.sphinx.outputstyle == 'notebook' *))
32 ((*- set wrap_size = 70 -*))
32 ((*- set wrap_size = 70 -*))
33 ((* endif *))
33 ((* endif *))
34
34
35 %==============================================================================
35 %==============================================================================
36 % Header
36 % Header
37 %==============================================================================
37 %==============================================================================
38 ((* block header *))
38 ((* block header *))
39
39
40 % Header, overrides base
40 % Header, overrides base
41
41
42 % Make sure that the sphinx doc style knows who it inherits from.
42 % Make sure that the sphinx doc style knows who it inherits from.
43 \def\sphinxdocclass{(((parentdocumentclass)))}
43 \def\sphinxdocclass{(((parentdocumentclass)))}
44
44
45 % Declare the document class
45 % Declare the document class
46 \documentclass[letterpaper,10pt,english]{((( resources.sphinx.texinputs )))/sphinx(((documentclass)))}
46 \documentclass[letterpaper,10pt,english]{((( resources.sphinx.texinputs )))/sphinx(((documentclass)))}
47
47
48 % Imports
48 % Imports
49 \usepackage[utf8]{inputenc}
49 \usepackage[utf8]{inputenc}
50 \DeclareUnicodeCharacter{00A0}{\\nobreakspace}
50 \DeclareUnicodeCharacter{00A0}{\\nobreakspace}
51 \usepackage[T1]{fontenc}
51 \usepackage[T1]{fontenc}
52 \usepackage{babel}
52 \usepackage{babel}
53 \usepackage{times}
53 \usepackage{times}
54 \usepackage{import}
54 \usepackage{import}
55 \usepackage[((( resources.sphinx.chapterstyle )))]{((( resources.sphinx.texinputs )))/fncychap}
55 \usepackage[((( resources.sphinx.chapterstyle )))]{((( resources.sphinx.texinputs )))/fncychap}
56 \usepackage{longtable}
56 \usepackage{longtable}
57 \usepackage{((( resources.sphinx.texinputs )))/sphinx}
57 \usepackage{((( resources.sphinx.texinputs )))/sphinx}
58 \usepackage{multirow}
58 \usepackage{multirow}
59
59
60 \usepackage{amsmath}
60 \usepackage{amsmath}
61 \usepackage{amssymb}
61 \usepackage{amssymb}
62 \usepackage{ucs}
62 \usepackage{ucs}
63 \usepackage{enumerate}
63 \usepackage{enumerate}
64
64
65 % Used to make the Input/Output rules follow around the contents.
65 % Used to make the Input/Output rules follow around the contents.
66 \usepackage{needspace}
66 \usepackage{needspace}
67
67
68 % Pygments requirements
68 % Pygments requirements
69 \usepackage{fancyvrb}
69 \usepackage{fancyvrb}
70 \usepackage{color}
70 \usepackage{color}
71 % ansi colors additions
71 % ansi colors additions
72 \definecolor{darkgreen}{rgb}{.12,.54,.11}
72 \definecolor{darkgreen}{rgb}{.12,.54,.11}
73 \definecolor{lightgray}{gray}{.95}
73 \definecolor{lightgray}{gray}{.95}
74 \definecolor{brown}{rgb}{0.54,0.27,0.07}
74 \definecolor{brown}{rgb}{0.54,0.27,0.07}
75 \definecolor{purple}{rgb}{0.5,0.0,0.5}
75 \definecolor{purple}{rgb}{0.5,0.0,0.5}
76 \definecolor{darkgray}{gray}{0.25}
76 \definecolor{darkgray}{gray}{0.25}
77 \definecolor{lightred}{rgb}{1.0,0.39,0.28}
77 \definecolor{lightred}{rgb}{1.0,0.39,0.28}
78 \definecolor{lightgreen}{rgb}{0.48,0.99,0.0}
78 \definecolor{lightgreen}{rgb}{0.48,0.99,0.0}
79 \definecolor{lightblue}{rgb}{0.53,0.81,0.92}
79 \definecolor{lightblue}{rgb}{0.53,0.81,0.92}
80 \definecolor{lightpurple}{rgb}{0.87,0.63,0.87}
80 \definecolor{lightpurple}{rgb}{0.87,0.63,0.87}
81 \definecolor{lightcyan}{rgb}{0.5,1.0,0.83}
81 \definecolor{lightcyan}{rgb}{0.5,1.0,0.83}
82
82
83 % Needed to box output/input
83 % Needed to box output/input
84 \usepackage{tikz}
84 \usepackage{tikz}
85 \usetikzlibrary{calc,arrows,shadows}
85 \usetikzlibrary{calc,arrows,shadows}
86 \usepackage[framemethod=tikz]{mdframed}
86 \usepackage[framemethod=tikz]{mdframed}
87
87
88 \usepackage{alltt}
88 \usepackage{alltt}
89
89
90 % Used to load and display graphics
90 % Used to load and display graphics
91 \usepackage{graphicx}
91 \usepackage{graphicx}
92 \graphicspath{ {figs/} }
92 \graphicspath{ {figs/} }
93 \usepackage[Export]{adjustbox} % To resize
93 \usepackage[Export]{adjustbox} % To resize
94
94
95
95
96 % For formatting output while also word wrapping.
96 % For formatting output while also word wrapping.
97 \usepackage{listings}
97 \usepackage{listings}
98 \lstset{breaklines=true}
98 \lstset{breaklines=true}
99 \lstset{basicstyle=\small\ttfamily}
99 \lstset{basicstyle=\small\ttfamily}
100 \def\smaller{\fontsize{9.5pt}{9.5pt}\selectfont}
100 \def\smaller{\fontsize{9.5pt}{9.5pt}\selectfont}
101
101
102 %Pygments definitions
102 %Pygments definitions
103 ((( resources.sphinx.pygment_definitions )))
103 ((( resources.sphinx.pygment_definitions )))
104
104
105 %Set pygments styles if needed...
105 %Set pygments styles if needed...
106 ((* if resources.sphinx.outputstyle == 'notebook' *))
106 ((* if resources.sphinx.outputstyle == 'notebook' *))
107 \definecolor{nbframe-border}{rgb}{0.867,0.867,0.867}
107 \definecolor{nbframe-border}{rgb}{0.867,0.867,0.867}
108 \definecolor{nbframe-bg}{rgb}{0.969,0.969,0.969}
108 \definecolor{nbframe-bg}{rgb}{0.969,0.969,0.969}
109 \definecolor{nbframe-in-prompt}{rgb}{0.0,0.0,0.502}
109 \definecolor{nbframe-in-prompt}{rgb}{0.0,0.0,0.502}
110 \definecolor{nbframe-out-prompt}{rgb}{0.545,0.0,0.0}
110 \definecolor{nbframe-out-prompt}{rgb}{0.545,0.0,0.0}
111
111
112 \newenvironment{ColorVerbatim}
112 \newenvironment{ColorVerbatim}
113 {\begin{mdframed}[%
113 {\begin{mdframed}[%
114 roundcorner=1.0pt, %
114 roundcorner=1.0pt, %
115 backgroundcolor=nbframe-bg, %
115 backgroundcolor=nbframe-bg, %
116 userdefinedwidth=1\linewidth, %
116 userdefinedwidth=1\linewidth, %
117 leftmargin=0.1\linewidth, %
117 leftmargin=0.1\linewidth, %
118 innerleftmargin=0pt, %
118 innerleftmargin=0pt, %
119 innerrightmargin=0pt, %
119 innerrightmargin=0pt, %
120 linecolor=nbframe-border, %
120 linecolor=nbframe-border, %
121 linewidth=1pt, %
121 linewidth=1pt, %
122 usetwoside=false, %
122 usetwoside=false, %
123 everyline=true, %
123 everyline=true, %
124 innerlinewidth=3pt, %
124 innerlinewidth=3pt, %
125 innerlinecolor=nbframe-bg, %
125 innerlinecolor=nbframe-bg, %
126 middlelinewidth=1pt, %
126 middlelinewidth=1pt, %
127 middlelinecolor=nbframe-bg, %
127 middlelinecolor=nbframe-bg, %
128 outerlinewidth=0.5pt, %
128 outerlinewidth=0.5pt, %
129 outerlinecolor=nbframe-border, %
129 outerlinecolor=nbframe-border, %
130 needspace=0pt
130 needspace=0pt
131 ]}
131 ]}
132 {\end{mdframed}}
132 {\end{mdframed}}
133
133
134 \newenvironment{InvisibleVerbatim}
134 \newenvironment{InvisibleVerbatim}
135 {\begin{mdframed}[leftmargin=0.1\linewidth,innerleftmargin=3pt,innerrightmargin=3pt, userdefinedwidth=1\linewidth, linewidth=0pt, linecolor=white, usetwoside=false]}
135 {\begin{mdframed}[leftmargin=0.1\linewidth,innerleftmargin=3pt,innerrightmargin=3pt, userdefinedwidth=1\linewidth, linewidth=0pt, linecolor=white, usetwoside=false]}
136 {\end{mdframed}}
136 {\end{mdframed}}
137
137
138 \renewenvironment{Verbatim}[1][\unskip]
138 \renewenvironment{Verbatim}[1][\unskip]
139 {\begin{alltt}\smaller}
139 {\begin{alltt}\smaller}
140 {\end{alltt}}
140 {\end{alltt}}
141 ((* endif *))
141 ((* endif *))
142
142
143 % Help prevent overflowing lines due to urls and other hard-to-break
143 % Help prevent overflowing lines due to urls and other hard-to-break
144 % entities. This doesn't catch everything...
144 % entities. This doesn't catch everything...
145 \sloppy
145 \sloppy
146
146
147 % Document level variables
147 % Document level variables
148 \title{((( resources.metadata.name | escape_tex )))}
148 \title{((( resources.metadata.name | escape_tex )))}
149 \date{((( resources.sphinx.date | escape_tex )))}
149 \date{((( resources.sphinx.date | escape_tex )))}
150 \release{((( resources.sphinx.version | escape_tex )))}
150 \release{((( resources.sphinx.version | escape_tex )))}
151 \author{((( resources.sphinx.author | escape_tex )))}
151 \author{((( resources.sphinx.author | escape_tex )))}
152 \renewcommand{\releasename}{((( resources.sphinx.release | escape_tex )))}
152 \renewcommand{\releasename}{((( resources.sphinx.release | escape_tex )))}
153
153
154 % TODO: Add option for the user to specify a logo for his/her export.
154 % TODO: Add option for the user to specify a logo for his/her export.
155 \newcommand{\sphinxlogo}{}
155 \newcommand{\sphinxlogo}{}
156
156
157 % Make the index page of the document.
157 % Make the index page of the document.
158 \makeindex
158 \makeindex
159
159
160 % Import sphinx document type specifics.
160 % Import sphinx document type specifics.
161 ((* block sphinxheader *))((* endblock sphinxheader *))
161 ((* block sphinxheader *))((* endblock sphinxheader *))
162 ((* endblock header *))
162 ((* endblock header *))
163
163
164 %==============================================================================
164 %==============================================================================
165 % Body
165 % Body
166 %==============================================================================
166 %==============================================================================
167 ((* block body *))
167 ((* block body *))
168 ((* block bodyBegin *))
168 ((* block bodyBegin *))
169 % Body
169 % Body
170
170
171 % Start of the document
171 % Start of the document
172 \begin{document}
172 \begin{document}
173
173
174 ((* if resources.sphinx.header *))
174 ((* if resources.sphinx.header *))
175 \maketitle
175 \maketitle
176 ((* endif *))
176 ((* endif *))
177
177
178 ((* block toc *))
178 ((* block toc *))
179 \tableofcontents
179 \tableofcontents
180 ((* endblock toc *))
180 ((* endblock toc *))
181
181
182 ((* endblock bodyBegin *))((( super() )))((* block bodyEnd *))
182 ((* endblock bodyBegin *))((( super() )))((* block bodyEnd *))
183
183
184 \renewcommand{\indexname}{Index}
184 \renewcommand{\indexname}{Index}
185 \printindex
185 \printindex
186
186
187 % End of document
187 % End of document
188 \end{document}
188 \end{document}
189 ((* endblock bodyEnd *))
189 ((* endblock bodyEnd *))
190 ((* endblock body *))
190 ((* endblock body *))
191
191
192 %==============================================================================
192 %==============================================================================
193 % Footer
193 % Footer
194 %==============================================================================
194 %==============================================================================
195 ((* block footer *))
195 ((* block footer *))
196 ((* endblock footer *))
196 ((* endblock footer *))
197
197
198 %==============================================================================
198 %==============================================================================
199 % Headings
199 % Headings
200 %
200 %
201 % Purpose: Format pynb headers as sphinx headers. Depending on the Sphinx
201 % Purpose: Format pynb headers as sphinx headers. Depending on the Sphinx
202 % style that is active, this will change. Thus sphinx styles will
202 % style that is active, this will change. Thus sphinx styles will
203 % override the values here.
203 % override the values here.
204 %==============================================================================
204 %==============================================================================
205 ((* block headingcell -*))
205 ((* block headingcell -*))
206 \
206 \
207 ((*- if cell.level == 1 -*))
207 ((*- if cell.level == 1 -*))
208 ((* block h1 -*))part((* endblock h1 -*))
208 ((* block h1 -*))part((* endblock h1 -*))
209 ((*- elif cell.level == 2 -*))
209 ((*- elif cell.level == 2 -*))
210 ((* block h2 -*))chapter((* endblock h2 -*))
210 ((* block h2 -*))chapter((* endblock h2 -*))
211 ((*- elif cell.level == 3 -*))
211 ((*- elif cell.level == 3 -*))
212 ((* block h3 -*))section((* endblock h3 -*))
212 ((* block h3 -*))section((* endblock h3 -*))
213 ((*- elif cell.level == 4 -*))
213 ((*- elif cell.level == 4 -*))
214 ((* block h4 -*))subsection((* endblock h4 -*))
214 ((* block h4 -*))subsection((* endblock h4 -*))
215 ((*- elif cell.level == 5 -*))
215 ((*- elif cell.level == 5 -*))
216 ((* block h5 -*))subsubsection((* endblock h5 -*))
216 ((* block h5 -*))subsubsection((* endblock h5 -*))
217 ((*- elif cell.level == 6 -*))
217 ((*- elif cell.level == 6 -*))
218 ((* block h6 -*))paragraph((* endblock h6 -*))
218 ((* block h6 -*))paragraph((* endblock h6 -*))
219
219
220 ((= It's important to make sure that underscores (which tend to be common
220 ((= It's important to make sure that underscores (which tend to be common
221 in IPYNB file titles) do not make their way into latex. Sometimes this
221 in IPYNB file titles) do not make their way into latex. Sometimes this
222 causes latex to barf. =))
222 causes latex to barf. =))
223 ((*- endif -*)){((( cell.source | markdown2latex )))}
223 ((*- endif -*)){((( cell.source | markdown2latex )))}
224 ((*- endblock headingcell *))
224 ((*- endblock headingcell *))
225
225
226 %==============================================================================
226 %==============================================================================
227 % Markdown
227 % Markdown
228 %
228 %
229 % Purpose: Convert markdown to latex. Here markdown2latex is explicitly
229 % Purpose: Convert markdown to latex. Here markdown2latex is explicitly
230 % called since we know we want latex output.
230 % called since we know we want latex output.
231 %==============================================================================
231 %==============================================================================
232 ((*- block markdowncell scoped-*))
232 ((*- block markdowncell scoped-*))
233 ((( cell.source | markdown2latex )))
233 ((( cell.source | markdown2latex )))
234 ((*- endblock markdowncell -*))
234 ((*- endblock markdowncell -*))
235
235
236 %==============================================================================
236 %==============================================================================
237 % Rawcell
237 % Rawcell
238 %
238 %
239 % Purpose: Raw text cells allow the user to manually inject document code that
239 % Purpose: Raw text cells allow the user to manually inject document code that
240 % will not get touched by the templating system.
240 % will not get touched by the templating system.
241 %==============================================================================
241 %==============================================================================
242 ((*- block rawcell *))
242 ((*- block rawcell *))
243 ((( cell.source | wrap(wrap_size) )))
243 ((( cell.source | wrap(wrap_size) )))
244 ((* endblock rawcell -*))
244 ((* endblock rawcell -*))
245
245
246 %==============================================================================
246 %==============================================================================
247 % Unknowncell
247 % Unknowncell
248 %
248 %
249 % Purpose: This is the catch anything unhandled. To display this data, we
249 % Purpose: This is the catch anything unhandled. To display this data, we
250 % remove all possible latex conflicts and wrap the characters so they
250 % remove all possible latex conflicts and wrap the characters so they
251 % can't flow off of the page.
251 % can't flow off of the page.
252 %==============================================================================
252 %==============================================================================
253 ((* block unknowncell scoped*))
253 ((* block unknowncell scoped*))
254
254
255 % Unsupported cell type, no formatting
255 % Unsupported cell type, no formatting
256 ((( cell.source | wrap | escape_tex )))
256 ((( cell.source | wrap | escape_tex )))
257 ((* endblock unknowncell *))
257 ((* endblock unknowncell *))
258
258
259 %==============================================================================
259 %==============================================================================
260 % Input
260 % Input
261 %==============================================================================
261 %==============================================================================
262 ((* block input *))
262 ((* block input *))
263
263
264 % Make sure that atleast 4 lines are below the HR
264 % Make sure that atleast 4 lines are below the HR
265 \needspace{((( min_header_lines )))\baselineskip}
265 \needspace{((( min_header_lines )))\baselineskip}
266
266
267 ((* if resources.sphinx.outputstyle == 'simple' *))
267 ((* if resources.sphinx.outputstyle == 'simple' *))
268
268
269 % Add a horizantal break, along with break title.
269 % Add a horizantal break, along with break title.
270 \vspace{10pt}
270 \vspace{10pt}
271 {\scriptsize Input}\\*
271 {\scriptsize Input}\\*
272 \rule[10pt]{\linewidth}{0.5pt}
272 \rule[10pt]{\linewidth}{0.5pt}
273 \vspace{-25pt}
273 \vspace{-25pt}
274
274
275 % Add contents below.
275 % Add contents below.
276 ((( cell.input | highlight )))
276 ((( cell.input | highlight )))
277
277
278 ((* elif resources.sphinx.outputstyle == 'notebook' *))
278 ((* elif resources.sphinx.outputstyle == 'notebook' *))
279 \vspace{6pt}
279 \vspace{6pt}
280 ((( write_prompt("In", cell.prompt_number, "nbframe-in-prompt") )))
280 ((( write_prompt("In", cell.prompt_number, "nbframe-in-prompt") )))
281 \vspace{-2.65\baselineskip}
281 \vspace{-2.65\baselineskip}
282 \begin{ColorVerbatim}
282 \begin{ColorVerbatim}
283 \vspace{-0.7\baselineskip}
283 \vspace{-0.7\baselineskip}
284 ((( cell.input | highlight )))
284 ((( cell.input | highlight )))
285 ((* if cell.input == None or cell.input == '' *))
285 ((* if cell.input == None or cell.input == '' *))
286 \vspace{0.3\baselineskip}
286 \vspace{0.3\baselineskip}
287 ((* else *))
287 ((* else *))
288 \vspace{-0.2\baselineskip}
288 \vspace{-0.2\baselineskip}
289 ((* endif *))
289 ((* endif *))
290 \end{ColorVerbatim}
290 \end{ColorVerbatim}
291 ((* endif *))
291 ((* endif *))
292 ((* endblock input *))
292 ((* endblock input *))
293
293
294 %==============================================================================
294 %==============================================================================
295 % Output_Group
295 % Output_Group
296 %
296 %
297 % Purpose: Make sure that only one header bar only attaches to the output
297 % Purpose: Make sure that only one header bar only attaches to the output
298 % once. By keeping track of when an input group is started
298 % once. By keeping track of when an input group is started
299 %==============================================================================
299 %==============================================================================
300 ((* block output_group *))
300 ((* block output_group *))
301 ((* if cell.outputs.__len__() > 0 *))
301 ((* if cell.outputs.__len__() > 0 *))
302
302
303 % If the first block is an image, minipage the image. Else
303 % If the first block is an image, minipage the image. Else
304 % request a certain amount of space for the input text.
304 % request a certain amount of space for the input text.
305 ((( iff_figure(cell.outputs[0], "\\begin{minipage}{1.0\\textwidth}", "\\needspace{" ~ min_header_lines ~ "\\baselineskip}") )))
305 ((( iff_figure(cell.outputs[0], "\\begin{minipage}{1.0\\textwidth}", "\\needspace{" ~ min_header_lines ~ "\\baselineskip}") )))
306
306
307 ((* if resources.sphinx.outputstyle == 'simple' *))
307 ((* if resources.sphinx.outputstyle == 'simple' *))
308
308
309 % Add a horizantal break, along with break title.
309 % Add a horizantal break, along with break title.
310 \vspace{10pt}
310 \vspace{10pt}
311 {\scriptsize Output}\\*
311 {\scriptsize Output}\\*
312 \rule[10pt]{\linewidth}{0.5pt}
312 \rule[10pt]{\linewidth}{0.5pt}
313 \vspace{-20pt}
313 \vspace{-20pt}
314
314
315 % Add the contents of the first block.
315 % Add the contents of the first block.
316 ((( render_output(cell.outputs[0]) )))
316 ((( render_output(cell.outputs[0]) )))
317
317
318 % Close the minipage.
318 % Close the minipage.
319 ((( iff_figure(cell.outputs[0], "\\end{minipage}", "") )))
319 ((( iff_figure(cell.outputs[0], "\\end{minipage}", "") )))
320
320
321 % Add remainer of the document contents below.
321 % Add remainer of the document contents below.
322 ((* for output in cell.outputs[1:] *))
322 ((* for output in cell.outputs[1:] *))
323 ((( render_output(output, cell.prompt_number) )))
323 ((( render_output(output, cell.prompt_number) )))
324 ((* endfor *))
324 ((* endfor *))
325 ((* elif resources.sphinx.outputstyle == 'notebook' *))
325 ((* elif resources.sphinx.outputstyle == 'notebook' *))
326
326
327 % Add document contents.
327 % Add document contents.
328 ((* for output in cell.outputs *))
328 ((* for output in cell.outputs *))
329 ((( render_output(output, cell.prompt_number) )))
329 ((( render_output(output, cell.prompt_number) )))
330 ((* endfor *))
330 ((* endfor *))
331 ((* endif *))
331 ((* endif *))
332 ((* endif *))
332 ((* endif *))
333 ((* endblock *))
333 ((* endblock *))
334
334
335 %==============================================================================
335 %==============================================================================
336 % Additional formating
336 % Additional formating
337 %==============================================================================
337 %==============================================================================
338 ((* block data_text *))
338 ((* block data_text *))
339 ((( custom_verbatim(output.text) | ansi2latex)))
339 ((( custom_verbatim(output.text) | ansi2latex)))
340 ((* endblock *))
340 ((* endblock *))
341
341
342 ((* block traceback_line *))
342 ((* block traceback_line *))
343 ((( conditionally_center_output(line | indent| rm_ansi) )))
343 ((( conditionally_center_output(line | indent| rm_ansi) )))
344 ((* endblock traceback_line *))
344 ((* endblock traceback_line *))
345
345
346 %==============================================================================
346 %==============================================================================
347 % Supported image formats
347 % Supported image formats
348 %==============================================================================
348 %==============================================================================
349 ((*- block data_png -*))
349 ((*- block data_png -*))
350 ((( conditionally_center_output(insert_graphics(output.png_filename)) )))
350 ((( conditionally_center_output(insert_graphics(output.png_filename)) )))
351 ((*- endblock -*))
351 ((*- endblock -*))
352
352
353 ((*- block data_jpg -*))
353 ((*- block data_jpg -*))
354 ((( conditionally_center_output(insert_graphics(output.jpg_filename)) )))
354 ((( conditionally_center_output(insert_graphics(output.jpg_filename)) )))
355 ((*- endblock -*))
355 ((*- endblock -*))
356
356
357 ((*- block data_svg -*))
357 ((*- block data_svg -*))
358 ((( conditionally_center_output(insert_graphics(output.svg_filename)) )))
358 ((( conditionally_center_output(insert_graphics(output.svg_filename)) )))
359 ((*- endblock -*))
359 ((*- endblock -*))
360
360
361 ((*- block data_pdf -*))
361 ((*- block data_pdf -*))
362 ((( conditionally_center_output(insert_graphics(output.pdf_filename[:-4])) )))
362 ((( conditionally_center_output(insert_graphics(output.pdf_filename)) )))
363 ((*- endblock -*))
363 ((*- endblock -*))
364
364
365 ((*- block data_latex *))
365 ((*- block data_latex *))
366 ((* if resources.sphinx.centeroutput *))\begin{center}((* endif -*))((( output.latex | rm_math_space )))((*- if resources.sphinx.centeroutput *))\end{center} ((* endif -*))
366 ((* if resources.sphinx.centeroutput *))\begin{center}((* endif -*))((( output.latex | rm_math_space )))((*- if resources.sphinx.centeroutput *))\end{center} ((* endif -*))
367 ((*- endblock -*))
367 ((*- endblock -*))
368
368
369 %==============================================================================
369 %==============================================================================
370 % Support Macros
370 % Support Macros
371 %==============================================================================
371 %==============================================================================
372
372
373 % Name: write_prompt
373 % Name: write_prompt
374 % Purpose: Renders an output/input prompt for notebook style pdfs
374 % Purpose: Renders an output/input prompt for notebook style pdfs
375 ((* macro write_prompt(prompt, number, color) -*))
375 ((* macro write_prompt(prompt, number, color) -*))
376 \makebox[0.1\linewidth]{\smaller\hfill\tt\color{((( color )))}((( prompt )))\hspace{4pt}{[}((( number ))){]}:\hspace{4pt}}\\*
376 \makebox[0.1\linewidth]{\smaller\hfill\tt\color{((( color )))}((( prompt )))\hspace{4pt}{[}((( number ))){]}:\hspace{4pt}}\\*
377 ((*- endmacro *))
377 ((*- endmacro *))
378
378
379 % Name: render_output
379 % Name: render_output
380 % Purpose: Renders an output block appropriately.
380 % Purpose: Renders an output block appropriately.
381 ((* macro render_output(output, prompt_number) -*))
381 ((* macro render_output(output, prompt_number) -*))
382 ((*- if output.output_type == 'pyerr' -*))
382 ((*- if output.output_type == 'pyerr' -*))
383 ((*- block pyerr scoped *))
383 ((*- block pyerr scoped *))
384 ((( custom_verbatim(super()) )))
384 ((( custom_verbatim(super()) )))
385 ((* endblock pyerr -*))
385 ((* endblock pyerr -*))
386 ((*- else -*))
386 ((*- else -*))
387
387
388 ((* if resources.sphinx.outputstyle == 'notebook' *))
388 ((* if resources.sphinx.outputstyle == 'notebook' *))
389 ((*- if output.output_type == 'pyout' -*))
389 ((*- if output.output_type == 'pyout' -*))
390 ((( write_prompt("Out", prompt_number, "nbframe-out-prompt") )))
390 ((( write_prompt("Out", prompt_number, "nbframe-out-prompt") )))
391 \vspace{-2.55\baselineskip}
391 \vspace{-2.55\baselineskip}
392 ((*- endif -*))
392 ((*- endif -*))
393
393
394 \begin{InvisibleVerbatim}
394 \begin{InvisibleVerbatim}
395 \vspace{-0.5\baselineskip}
395 \vspace{-0.5\baselineskip}
396 ((*- endif -*))
396 ((*- endif -*))
397
397
398 ((*- block display_data scoped -*))
398 ((*- block display_data scoped -*))
399 ((( super() )))
399 ((( super() )))
400 ((*- endblock display_data -*))
400 ((*- endblock display_data -*))
401
401
402 ((* if resources.sphinx.outputstyle == 'notebook' *))
402 ((* if resources.sphinx.outputstyle == 'notebook' *))
403 \end{InvisibleVerbatim}
403 \end{InvisibleVerbatim}
404 ((*- endif -*))
404 ((*- endif -*))
405 ((*- endif -*))
405 ((*- endif -*))
406 ((*- endmacro *))
406 ((*- endmacro *))
407
407
408 % Name: iff_figure
408 % Name: iff_figure
409 % Purpose: If the output block provided is a figure type, the 'true_content'
409 % Purpose: If the output block provided is a figure type, the 'true_content'
410 % parameter will be returned. Else, the 'false_content'.
410 % parameter will be returned. Else, the 'false_content'.
411 ((* macro iff_figure(output, true_content, false_content) -*))
411 ((* macro iff_figure(output, true_content, false_content) -*))
412 ((*- set is_figure = false -*))
412 ((*- set is_figure = false -*))
413 ((*- for type in output | filter_data_type -*))
413 ((*- for type in output | filter_data_type -*))
414 ((*- if type in ['pdf', 'svg', 'png', 'jpeg','html']*))
414 ((*- if type in ['pdf', 'svg', 'png', 'jpeg','html']*))
415 ((*- set is_figure = true -*))
415 ((*- set is_figure = true -*))
416 ((*- endif -*))
416 ((*- endif -*))
417 ((*- endfor -*))
417 ((*- endfor -*))
418
418
419 ((* if is_figure -*))
419 ((* if is_figure -*))
420 ((( true_content )))
420 ((( true_content )))
421 ((*- else -*))
421 ((*- else -*))
422 ((( false_content )))
422 ((( false_content )))
423 ((*- endif *))
423 ((*- endif *))
424 ((*- endmacro *))
424 ((*- endmacro *))
425
425
426 % Name: custom_verbatim
426 % Name: custom_verbatim
427 % Purpose: This macro creates a verbatim style block that fits the existing
427 % Purpose: This macro creates a verbatim style block that fits the existing
428 % sphinx style more readily than standard verbatim blocks.
428 % sphinx style more readily than standard verbatim blocks.
429 ((* macro custom_verbatim(text) -*))
429 ((* macro custom_verbatim(text) -*))
430 \begin{alltt}
430 \begin{alltt}
431 ((*- if resources.sphinx.centeroutput *))\begin{center} ((* endif -*))
431 ((*- if resources.sphinx.centeroutput *))\begin{center} ((* endif -*))
432 ((( text | wrap(wrap_size) )))
432 ((( text | wrap(wrap_size) )))
433 ((*- if resources.sphinx.centeroutput *))\end{center}((* endif -*))
433 ((*- if resources.sphinx.centeroutput *))\end{center}((* endif -*))
434 \end{alltt}
434 \end{alltt}
435 ((*- endmacro *))
435 ((*- endmacro *))
436
436
437 % Name: conditionally_center_output
437 % Name: conditionally_center_output
438 % Purpose: This macro centers the output if the output centering is enabled.
438 % Purpose: This macro centers the output if the output centering is enabled.
439 ((* macro conditionally_center_output(text) -*))
439 ((* macro conditionally_center_output(text) -*))
440 ((* if resources.sphinx.centeroutput *)){\centering ((* endif *))((( text )))((* if resources.sphinx.centeroutput *))}((* endif *))
440 ((* if resources.sphinx.centeroutput *)){\centering ((* endif *))((( text )))((* if resources.sphinx.centeroutput *))}((* endif *))
441 ((*- endmacro *))
441 ((*- endmacro *))
442
442
443 % Name: insert_graphics
443 % Name: insert_graphics
444 % Purpose: This macro will insert an image in the latex document given a path.
444 % Purpose: This macro will insert an image in the latex document given a path.
445 ((* macro insert_graphics(path) -*))
445 ((* macro insert_graphics(path) -*))
446 \begin{center}
446 \begin{center}
447 \includegraphics[max size={\textwidth}{\textheight}]{(((path)))}
447 \includegraphics[max size={\textwidth}{\textheight}]{(((path)))}
448 \par
448 \par
449 \end{center}
449 \end{center}
450 ((*- endmacro *))
450 ((*- endmacro *))
General Comments 0
You need to be logged in to leave comments. Login now