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