##// END OF EJS Templates
Needspace for the output regardless of output style.
Jonathan Frederic -
Show More
@@ -1,438 +1,439 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>latex_base
6 Inheritance: null>display_priority>latex_base
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
71
72 % Needed to box output/input
72 % Needed to box output/input
73 \usepackage{tikz}
73 \usepackage{tikz}
74 \usetikzlibrary{calc,arrows,shadows}
74 \usetikzlibrary{calc,arrows,shadows}
75 \usepackage[framemethod=tikz]{mdframed}
75 \usepackage[framemethod=tikz]{mdframed}
76
76
77 \usepackage{alltt}
77 \usepackage{alltt}
78
78
79 % Used to load and display graphics
79 % Used to load and display graphics
80 \usepackage{graphicx}
80 \usepackage{graphicx}
81 \graphicspath{ {figs/} }
81 \graphicspath{ {figs/} }
82 \usepackage[Export]{adjustbox} % To resize
82 \usepackage[Export]{adjustbox} % To resize
83
83
84
84
85 % For formatting output while also word wrapping.
85 % For formatting output while also word wrapping.
86 \usepackage{listings}
86 \usepackage{listings}
87 \lstset{breaklines=true}
87 \lstset{breaklines=true}
88 \lstset{basicstyle=\small\ttfamily}
88 \lstset{basicstyle=\small\ttfamily}
89 \def\smaller{\fontsize{9.5pt}{9.5pt}\selectfont}
89 \def\smaller{\fontsize{9.5pt}{9.5pt}\selectfont}
90
90
91 %Pygments definitions
91 %Pygments definitions
92 ((( resources.sphinx.pygment_definitions )))
92 ((( resources.sphinx.pygment_definitions )))
93
93
94 %Set pygments styles if needed...
94 %Set pygments styles if needed...
95 ((* if resources.sphinx.outputstyle == 'notebook' *))
95 ((* if resources.sphinx.outputstyle == 'notebook' *))
96 \definecolor{nbframe-border}{rgb}{0.867,0.867,0.867}
96 \definecolor{nbframe-border}{rgb}{0.867,0.867,0.867}
97 \definecolor{nbframe-bg}{rgb}{0.969,0.969,0.969}
97 \definecolor{nbframe-bg}{rgb}{0.969,0.969,0.969}
98 \definecolor{nbframe-in-prompt}{rgb}{0.0,0.0,0.502}
98 \definecolor{nbframe-in-prompt}{rgb}{0.0,0.0,0.502}
99 \definecolor{nbframe-out-prompt}{rgb}{0.545,0.0,0.0}
99 \definecolor{nbframe-out-prompt}{rgb}{0.545,0.0,0.0}
100
100
101 \newenvironment{ColorVerbatim}
101 \newenvironment{ColorVerbatim}
102 {\begin{mdframed}[%
102 {\begin{mdframed}[%
103 roundcorner=1.0pt, %
103 roundcorner=1.0pt, %
104 backgroundcolor=nbframe-bg, %
104 backgroundcolor=nbframe-bg, %
105 userdefinedwidth=1\linewidth, %
105 userdefinedwidth=1\linewidth, %
106 leftmargin=0.1\linewidth, %
106 leftmargin=0.1\linewidth, %
107 innerleftmargin=0pt, %
107 innerleftmargin=0pt, %
108 innerrightmargin=0pt, %
108 innerrightmargin=0pt, %
109 linecolor=nbframe-border, %
109 linecolor=nbframe-border, %
110 linewidth=1pt, %
110 linewidth=1pt, %
111 usetwoside=false, %
111 usetwoside=false, %
112 everyline=true, %
112 everyline=true, %
113 innerlinewidth=3pt, %
113 innerlinewidth=3pt, %
114 innerlinecolor=nbframe-bg, %
114 innerlinecolor=nbframe-bg, %
115 middlelinewidth=1pt, %
115 middlelinewidth=1pt, %
116 middlelinecolor=nbframe-bg, %
116 middlelinecolor=nbframe-bg, %
117 outerlinewidth=0.5pt, %
117 outerlinewidth=0.5pt, %
118 outerlinecolor=nbframe-border, %
118 outerlinecolor=nbframe-border, %
119 needspace=0pt
119 needspace=0pt
120 ]}
120 ]}
121 {\end{mdframed}}
121 {\end{mdframed}}
122
122
123 \newenvironment{InvisibleVerbatim}
123 \newenvironment{InvisibleVerbatim}
124 {\begin{mdframed}[leftmargin=0.1\linewidth,innerleftmargin=3pt,innerrightmargin=3pt, userdefinedwidth=1\linewidth, linewidth=0pt, linecolor=white, usetwoside=false]}
124 {\begin{mdframed}[leftmargin=0.1\linewidth,innerleftmargin=3pt,innerrightmargin=3pt, userdefinedwidth=1\linewidth, linewidth=0pt, linecolor=white, usetwoside=false]}
125 {\end{mdframed}}
125 {\end{mdframed}}
126
126
127 \renewenvironment{Verbatim}[1][\unskip]
127 \renewenvironment{Verbatim}[1][\unskip]
128 {\begin{alltt}\smaller}
128 {\begin{alltt}\smaller}
129 {\end{alltt}}
129 {\end{alltt}}
130 ((* endif *))
130 ((* endif *))
131
131
132 % Help prevent overflowing lines due to urls and other hard-to-break
132 % Help prevent overflowing lines due to urls and other hard-to-break
133 % entities. This doesn't catch everything...
133 % entities. This doesn't catch everything...
134 \sloppy
134 \sloppy
135
135
136 % Document level variables
136 % Document level variables
137 \title{((( nb.metadata.name | escape_tex )))}
137 \title{((( nb.metadata.name | escape_tex )))}
138 \date{((( nb.metadata._draft.date | escape_tex )))}
138 \date{((( nb.metadata._draft.date | escape_tex )))}
139 \release{((( nb.metadata._draft.version | escape_tex )))}
139 \release{((( nb.metadata._draft.version | escape_tex )))}
140 \author{((( nb.metadata._draft.author | escape_tex )))}
140 \author{((( nb.metadata._draft.author | escape_tex )))}
141 \renewcommand{\releasename}{((( nb.metadata._draft.release | escape_tex )))}
141 \renewcommand{\releasename}{((( nb.metadata._draft.release | escape_tex )))}
142
142
143 % TODO: Add option for the user to specify a logo for his/her export.
143 % TODO: Add option for the user to specify a logo for his/her export.
144 \newcommand{\sphinxlogo}{}
144 \newcommand{\sphinxlogo}{}
145
145
146 % Make the index page of the document.
146 % Make the index page of the document.
147 \makeindex
147 \makeindex
148
148
149 % Import sphinx document type specifics.
149 % Import sphinx document type specifics.
150 ((* block sphinxheader *))((* endblock sphinxheader *))
150 ((* block sphinxheader *))((* endblock sphinxheader *))
151 ((* endblock header *))
151 ((* endblock header *))
152
152
153 %==============================================================================
153 %==============================================================================
154 % Body
154 % Body
155 %==============================================================================
155 %==============================================================================
156 ((* block body *))
156 ((* block body *))
157 ((* block bodyBegin *))
157 ((* block bodyBegin *))
158 % Body
158 % Body
159
159
160 % Start of the document
160 % Start of the document
161 \begin{document}
161 \begin{document}
162
162
163 ((* if resources.sphinx.header *))
163 ((* if resources.sphinx.header *))
164 \maketitle
164 \maketitle
165 ((* endif *))
165 ((* endif *))
166
166
167 ((* block toc *))
167 ((* block toc *))
168 \tableofcontents
168 \tableofcontents
169 ((* endblock toc *))
169 ((* endblock toc *))
170
170
171 ((* endblock bodyBegin *))((( super() )))((* block bodyEnd *))
171 ((* endblock bodyBegin *))((( super() )))((* block bodyEnd *))
172
172
173 \renewcommand{\indexname}{Index}
173 \renewcommand{\indexname}{Index}
174 \printindex
174 \printindex
175
175
176 % End of document
176 % End of document
177 \end{document}
177 \end{document}
178 ((* endblock bodyEnd *))
178 ((* endblock bodyEnd *))
179 ((* endblock body *))
179 ((* endblock body *))
180
180
181 %==============================================================================
181 %==============================================================================
182 % Footer
182 % Footer
183 %==============================================================================
183 %==============================================================================
184 ((* block footer *))
184 ((* block footer *))
185 ((* endblock footer *))
185 ((* endblock footer *))
186
186
187 %==============================================================================
187 %==============================================================================
188 % Headings
188 % Headings
189 %
189 %
190 % Purpose: Format pynb headers as sphinx headers. Depending on the Sphinx
190 % Purpose: Format pynb headers as sphinx headers. Depending on the Sphinx
191 % style that is active, this will change. Thus sphinx styles will
191 % style that is active, this will change. Thus sphinx styles will
192 % override the values here.
192 % override the values here.
193 %==============================================================================
193 %==============================================================================
194 ((* block headingcell -*))
194 ((* block headingcell -*))
195 \
195 \
196 ((*- if cell.level == 1 -*))
196 ((*- if cell.level == 1 -*))
197 ((* block h1 -*))part((* endblock h1 -*))
197 ((* block h1 -*))part((* endblock h1 -*))
198 ((*- elif cell.level == 2 -*))
198 ((*- elif cell.level == 2 -*))
199 ((* block h2 -*))chapter((* endblock h2 -*))
199 ((* block h2 -*))chapter((* endblock h2 -*))
200 ((*- elif cell.level == 3 -*))
200 ((*- elif cell.level == 3 -*))
201 ((* block h3 -*))section((* endblock h3 -*))
201 ((* block h3 -*))section((* endblock h3 -*))
202 ((*- elif cell.level == 4 -*))
202 ((*- elif cell.level == 4 -*))
203 ((* block h4 -*))subsection((* endblock h4 -*))
203 ((* block h4 -*))subsection((* endblock h4 -*))
204 ((*- elif cell.level == 5 -*))
204 ((*- elif cell.level == 5 -*))
205 ((* block h5 -*))subsubsection((* endblock h5 -*))
205 ((* block h5 -*))subsubsection((* endblock h5 -*))
206 ((*- elif cell.level == 6 -*))
206 ((*- elif cell.level == 6 -*))
207 ((* block h6 -*))paragraph((* endblock h6 -*))
207 ((* block h6 -*))paragraph((* endblock h6 -*))
208
208
209 ((= It's important to make sure that underscores (which tend to be common
209 ((= It's important to make sure that underscores (which tend to be common
210 in IPYNB file titles) do not make their way into latex. Sometimes this
210 in IPYNB file titles) do not make their way into latex. Sometimes this
211 causes latex to barf. =))
211 causes latex to barf. =))
212 ((*- endif -*)){((( escape_underscores(cell.source | markdown2latex ) )))}
212 ((*- endif -*)){((( escape_underscores(cell.source | markdown2latex ) )))}
213 ((*- endblock headingcell *))
213 ((*- endblock headingcell *))
214
214
215 %==============================================================================
215 %==============================================================================
216 % Markdown
216 % Markdown
217 %
217 %
218 % Purpose: Convert markdown to latex. Here markdown2latex is explicitly
218 % Purpose: Convert markdown to latex. Here markdown2latex is explicitly
219 % called since we know we want latex output.
219 % called since we know we want latex output.
220 %==============================================================================
220 %==============================================================================
221 ((*- block markdowncell scoped-*))
221 ((*- block markdowncell scoped-*))
222 ((( cell.source | markdown2latex )))
222 ((( cell.source | markdown2latex )))
223 ((*- endblock markdowncell -*))
223 ((*- endblock markdowncell -*))
224
224
225 %==============================================================================
225 %==============================================================================
226 % Rawcell
226 % Rawcell
227 %
227 %
228 % Purpose: Raw text cells allow the user to manually inject document code that
228 % Purpose: Raw text cells allow the user to manually inject document code that
229 % will not get touched by the templating system.
229 % will not get touched by the templating system.
230 %==============================================================================
230 %==============================================================================
231 ((*- block rawcell *))
231 ((*- block rawcell *))
232 ((( cell.source | wrap(wrap_size) )))
232 ((( cell.source | wrap(wrap_size) )))
233 ((* endblock rawcell -*))
233 ((* endblock rawcell -*))
234
234
235 %==============================================================================
235 %==============================================================================
236 % Unknowncell
236 % Unknowncell
237 %
237 %
238 % Purpose: This is the catch anything unhandled. To display this data, we
238 % Purpose: This is the catch anything unhandled. To display this data, we
239 % remove all possible latex conflicts and wrap the characters so they
239 % remove all possible latex conflicts and wrap the characters so they
240 % can't flow off of the page.
240 % can't flow off of the page.
241 %==============================================================================
241 %==============================================================================
242 ((* block unknowncell scoped*))
242 ((* block unknowncell scoped*))
243
243
244 % Unsupported cell type, no formatting
244 % Unsupported cell type, no formatting
245 ((( cell.source | wrap | escape_tex )))
245 ((( cell.source | wrap | escape_tex )))
246 ((* endblock unknowncell *))
246 ((* endblock unknowncell *))
247
247
248 %==============================================================================
248 %==============================================================================
249 % Input
249 % Input
250 %==============================================================================
250 %==============================================================================
251 ((* block input *))
251 ((* block input *))
252
252
253 % Make sure that atleast 4 lines are below the HR
253 % Make sure that atleast 4 lines are below the HR
254 \needspace{((( min_header_lines )))\baselineskip}
254 \needspace{((( min_header_lines )))\baselineskip}
255
255
256 ((* if resources.sphinx.outputstyle == 'simple' *))
256 ((* if resources.sphinx.outputstyle == 'simple' *))
257
257
258 % Add a horizantal break, along with break title.
258 % Add a horizantal break, along with break title.
259 \vspace{10pt}
259 \vspace{10pt}
260 {\scriptsize Input}\\*
260 {\scriptsize Input}\\*
261 \rule[10pt]{\linewidth}{0.5pt}
261 \rule[10pt]{\linewidth}{0.5pt}
262 \vspace{-25pt}
262 \vspace{-25pt}
263
263
264 % Add contents below.
264 % Add contents below.
265 ((( cell.input | highlight )))
265 ((( cell.input | highlight )))
266
266
267 ((* elif resources.sphinx.outputstyle == 'notebook' *))
267 ((* elif resources.sphinx.outputstyle == 'notebook' *))
268 \vspace{6pt}
268 \vspace{6pt}
269 ((( write_prompt("In", cell.prompt_number, "nbframe-in-prompt") )))
269 ((( write_prompt("In", cell.prompt_number, "nbframe-in-prompt") )))
270 \vspace{-2.65\baselineskip}
270 \vspace{-2.65\baselineskip}
271 \begin{ColorVerbatim}
271 \begin{ColorVerbatim}
272 \vspace{-0.7\baselineskip}
272 \vspace{-0.7\baselineskip}
273 ((( cell.input | highlight )))
273 ((( cell.input | highlight )))
274 ((* if cell.input == None or cell.input == '' *))
274 ((* if cell.input == None or cell.input == '' *))
275 \vspace{0.3\baselineskip}
275 \vspace{0.3\baselineskip}
276 ((* else *))
276 ((* else *))
277 \vspace{-0.2\baselineskip}
277 \vspace{-0.2\baselineskip}
278 ((* endif *))
278 ((* endif *))
279 \end{ColorVerbatim}
279 \end{ColorVerbatim}
280 ((* endif *))
280 ((* endif *))
281 ((* endblock input *))
281 ((* endblock input *))
282
282
283 %==============================================================================
283 %==============================================================================
284 % Output_Group
284 % Output_Group
285 %
285 %
286 % Purpose: Make sure that only one header bar only attaches to the output
286 % Purpose: Make sure that only one header bar only attaches to the output
287 % once. By keeping track of when an input group is started
287 % once. By keeping track of when an input group is started
288 %==============================================================================
288 %==============================================================================
289 ((* block output_group *))
289 ((* block output_group *))
290 ((* if cell.outputs.__len__() > 0 *))
290 ((* if cell.outputs.__len__() > 0 *))
291 ((* if resources.sphinx.outputstyle == 'simple' *))
292
291
293 % If the first block is an image, minipage the image. Else
292 % If the first block is an image, minipage the image. Else
294 % request a certain amount of space for the input text.
293 % request a certain amount of space for the input text.
295 ((( iff_figure(cell.outputs[0], "\\begin{minipage}{1.0\\textwidth}", "\\needspace{" ~ min_header_lines ~ "\\baselineskip}") )))
294 ((( iff_figure(cell.outputs[0], "\\begin{minipage}{1.0\\textwidth}", "\\needspace{" ~ min_header_lines ~ "\\baselineskip}") )))
295
296 ((* if resources.sphinx.outputstyle == 'simple' *))
296
297
297 % Add a horizantal break, along with break title.
298 % Add a horizantal break, along with break title.
298 \vspace{10pt}
299 \vspace{10pt}
299 {\scriptsize Output}\\*
300 {\scriptsize Output}\\*
300 \rule[10pt]{\linewidth}{0.5pt}
301 \rule[10pt]{\linewidth}{0.5pt}
301 \vspace{-20pt}
302 \vspace{-20pt}
302
303
303 % Add the contents of the first block.
304 % Add the contents of the first block.
304 ((( render_output(cell.outputs[0]) )))
305 ((( render_output(cell.outputs[0]) )))
305
306
306 % Close the minipage.
307 % Close the minipage.
307 ((( iff_figure(cell.outputs[0], "\\end{minipage}", "") )))
308 ((( iff_figure(cell.outputs[0], "\\end{minipage}", "") )))
308
309
309 % Add remainer of the document contents below.
310 % Add remainer of the document contents below.
310 ((* for output in cell.outputs[1:] *))
311 ((* for output in cell.outputs[1:] *))
311 ((( render_output(output, cell.prompt_number) )))
312 ((( render_output(output, cell.prompt_number) )))
312 ((* endfor *))
313 ((* endfor *))
313 ((* elif resources.sphinx.outputstyle == 'notebook' *))
314 ((* elif resources.sphinx.outputstyle == 'notebook' *))
314
315
315 % Add document contents.
316 % Add document contents.
316 ((* for output in cell.outputs *))
317 ((* for output in cell.outputs *))
317 ((( render_output(output, cell.prompt_number) )))
318 ((( render_output(output, cell.prompt_number) )))
318 ((* endfor *))
319 ((* endfor *))
319 ((* endif *))
320 ((* endif *))
320 ((* endif *))
321 ((* endif *))
321 ((* endblock *))
322 ((* endblock *))
322
323
323 %==============================================================================
324 %==============================================================================
324 % Additional formating
325 % Additional formating
325 %==============================================================================
326 %==============================================================================
326 ((* block data_text *))
327 ((* block data_text *))
327 ((( custom_verbatim(output.text) )))
328 ((( custom_verbatim(output.text) )))
328 ((* endblock *))
329 ((* endblock *))
329
330
330 ((* block traceback_line *))
331 ((* block traceback_line *))
331 ((( conditionally_center_output(line | indent| rm_ansi) )))
332 ((( conditionally_center_output(line | indent| rm_ansi) )))
332 ((* endblock traceback_line *))
333 ((* endblock traceback_line *))
333
334
334 %==============================================================================
335 %==============================================================================
335 % Supported image formats
336 % Supported image formats
336 %==============================================================================
337 %==============================================================================
337 ((*- block data_png -*))
338 ((*- block data_png -*))
338 ((( conditionally_center_output(insert_graphics(output.key_png)) )))
339 ((( conditionally_center_output(insert_graphics(output.key_png)) )))
339 ((*- endblock -*))
340 ((*- endblock -*))
340
341
341 ((*- block data_svg -*))
342 ((*- block data_svg -*))
342 ((( conditionally_center_output(insert_graphics(output.key_svg)) )))
343 ((( conditionally_center_output(insert_graphics(output.key_svg)) )))
343 ((*- endblock -*))
344 ((*- endblock -*))
344
345
345 ((*- block data_latex *))
346 ((*- block data_latex *))
346 ((* if resources.sphinx.centeroutput *))\begin{center}((* endif -*))((( output.latex | rm_math_space )))((*- if resources.sphinx.centeroutput *))\end{center} ((* endif -*))
347 ((* if resources.sphinx.centeroutput *))\begin{center}((* endif -*))((( output.latex | rm_math_space )))((*- if resources.sphinx.centeroutput *))\end{center} ((* endif -*))
347 ((*- endblock -*))
348 ((*- endblock -*))
348
349
349 %==============================================================================
350 %==============================================================================
350 % Support Macros
351 % Support Macros
351 %==============================================================================
352 %==============================================================================
352
353
353 % Name: write_prompt
354 % Name: write_prompt
354 % Purpose: Renders an output/input prompt for notebook style pdfs
355 % Purpose: Renders an output/input prompt for notebook style pdfs
355 ((* macro write_prompt(prompt, number, color) -*))
356 ((* macro write_prompt(prompt, number, color) -*))
356 \makebox[0.1\linewidth]{\smaller\hfill\tt\color{((( color )))}((( prompt )))\hspace{4pt}{[}((( number ))){]}:\hspace{4pt}}\\*
357 \makebox[0.1\linewidth]{\smaller\hfill\tt\color{((( color )))}((( prompt )))\hspace{4pt}{[}((( number ))){]}:\hspace{4pt}}\\*
357 ((*- endmacro *))
358 ((*- endmacro *))
358
359
359 % Name: render_output
360 % Name: render_output
360 % Purpose: Renders an output block appropriately.
361 % Purpose: Renders an output block appropriately.
361 ((* macro render_output(output, prompt_number) -*))
362 ((* macro render_output(output, prompt_number) -*))
362 ((*- if output.output_type == 'pyerr' -*))
363 ((*- if output.output_type == 'pyerr' -*))
363 ((*- block pyerr scoped *))
364 ((*- block pyerr scoped *))
364 ((( custom_verbatim(super()) )))
365 ((( custom_verbatim(super()) )))
365 ((* endblock pyerr -*))
366 ((* endblock pyerr -*))
366 ((*- else -*))
367 ((*- else -*))
367
368
368 ((* if resources.sphinx.outputstyle == 'notebook' *))
369 ((* if resources.sphinx.outputstyle == 'notebook' *))
369 ((*- if output.output_type == 'pyout' -*))
370 ((*- if output.output_type == 'pyout' -*))
370 ((( write_prompt("Out", prompt_number, "nbframe-out-prompt") )))
371 ((( write_prompt("Out", prompt_number, "nbframe-out-prompt") )))
371 \vspace{-2.55\baselineskip}
372 \vspace{-2.55\baselineskip}
372 ((*- endif -*))
373 ((*- endif -*))
373
374
374 \begin{InvisibleVerbatim}
375 \begin{InvisibleVerbatim}
375 \vspace{-0.5\baselineskip}
376 \vspace{-0.5\baselineskip}
376 ((*- endif -*))
377 ((*- endif -*))
377
378
378 ((*- block display_data scoped -*))
379 ((*- block display_data scoped -*))
379 ((( super() )))
380 ((( super() )))
380 ((*- endblock display_data -*))
381 ((*- endblock display_data -*))
381
382
382 ((* if resources.sphinx.outputstyle == 'notebook' *))
383 ((* if resources.sphinx.outputstyle == 'notebook' *))
383 \end{InvisibleVerbatim}
384 \end{InvisibleVerbatim}
384 ((*- endif -*))
385 ((*- endif -*))
385 ((*- endif -*))
386 ((*- endif -*))
386 ((*- endmacro *))
387 ((*- endmacro *))
387
388
388 % Name: iff_figure
389 % Name: iff_figure
389 % Purpose: If the output block provided is a figure type, the 'true_content'
390 % Purpose: If the output block provided is a figure type, the 'true_content'
390 % parameter will be returned. Else, the 'false_content'.
391 % parameter will be returned. Else, the 'false_content'.
391 ((* macro iff_figure(output, true_content, false_content) -*))
392 ((* macro iff_figure(output, true_content, false_content) -*))
392 ((*- set is_figure = false -*))
393 ((*- set is_figure = false -*))
393 ((*- for type in output | filter_data_type -*))
394 ((*- for type in output | filter_data_type -*))
394 ((*- if type in ['pdf', 'svg', 'png', 'jpeg','html']*))
395 ((*- if type in ['pdf', 'svg', 'png', 'jpeg','html']*))
395 ((*- set is_figure = true -*))
396 ((*- set is_figure = true -*))
396 ((*- endif -*))
397 ((*- endif -*))
397 ((*- endfor -*))
398 ((*- endfor -*))
398
399
399 ((* if is_figure -*))
400 ((* if is_figure -*))
400 ((( true_content )))
401 ((( true_content )))
401 ((*- else -*))
402 ((*- else -*))
402 ((( false_content )))
403 ((( false_content )))
403 ((*- endif *))
404 ((*- endif *))
404 ((*- endmacro *))
405 ((*- endmacro *))
405
406
406 % Name: custom_verbatim
407 % Name: custom_verbatim
407 % Purpose: This macro creates a verbatim style block that fits the existing
408 % Purpose: This macro creates a verbatim style block that fits the existing
408 % sphinx style more readily than standard verbatim blocks.
409 % sphinx style more readily than standard verbatim blocks.
409 ((* macro custom_verbatim(text) -*))
410 ((* macro custom_verbatim(text) -*))
410 \begin{alltt}
411 \begin{alltt}
411 ((*- if resources.sphinx.centeroutput *))\begin{center} ((* endif -*))
412 ((*- if resources.sphinx.centeroutput *))\begin{center} ((* endif -*))
412 ((( text | wrap(wrap_size) )))
413 ((( text | wrap(wrap_size) )))
413 ((*- if resources.sphinx.centeroutput *))\end{center}((* endif -*))
414 ((*- if resources.sphinx.centeroutput *))\end{center}((* endif -*))
414 \end{alltt}
415 \end{alltt}
415 ((*- endmacro *))
416 ((*- endmacro *))
416
417
417 % Name: conditionally_center_output
418 % Name: conditionally_center_output
418 % Purpose: This macro centers the output if the output centering is enabled.
419 % Purpose: This macro centers the output if the output centering is enabled.
419 ((* macro conditionally_center_output(text) -*))
420 ((* macro conditionally_center_output(text) -*))
420 ((* if resources.sphinx.centeroutput *)){\centering ((* endif *))((( text )))((* if resources.sphinx.centeroutput *))}((* endif *))
421 ((* if resources.sphinx.centeroutput *)){\centering ((* endif *))((( text )))((* if resources.sphinx.centeroutput *))}((* endif *))
421 ((*- endmacro *))
422 ((*- endmacro *))
422
423
423 % Name: insert_graphics
424 % Name: insert_graphics
424 % Purpose: This macro will insert an image in the latex document given a path.
425 % Purpose: This macro will insert an image in the latex document given a path.
425 ((* macro insert_graphics(path) -*))
426 ((* macro insert_graphics(path) -*))
426 \begin{center}
427 \begin{center}
427 \includegraphics[max size={\textwidth}{\textheight}]{(((path)))}
428 \includegraphics[max size={\textwidth}{\textheight}]{(((path)))}
428 \par
429 \par
429 \end{center}
430 \end{center}
430 ((*- endmacro *))
431 ((*- endmacro *))
431
432
432 % Name: escape_underscores
433 % Name: escape_underscores
433 % Purpose: Underscores cause a problem in latex. It's important that we
434 % Purpose: Underscores cause a problem in latex. It's important that we
434 % escape any underscores that appear.
435 % escape any underscores that appear.
435 ((* macro escape_underscores(text) -*))
436 ((* macro escape_underscores(text) -*))
436 ((*- set text = text|replace("_","\\_") -*))
437 ((*- set text = text|replace("_","\\_") -*))
437 ((( text )))
438 ((( text )))
438 ((*- endmacro *)) No newline at end of file
439 ((*- endmacro *))
General Comments 0
You need to be logged in to leave comments. Login now