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