Show More
@@ -59,6 +59,9 b' Note: For best display, use latex syntax highlighting. =))' | |||
|
59 | 59 | \usepackage{ucs} |
|
60 | 60 | \usepackage{enumerate} |
|
61 | 61 | |
|
62 | % Used to make the Input/Output rules follow around the contents. | |
|
63 | \usepackage{needspace} | |
|
64 | ||
|
62 | 65 | % Pygments requirements |
|
63 | 66 | \usepackage{fancyvrb} |
|
64 | 67 | \usepackage{color} |
@@ -132,7 +135,7 b' Note: For best display, use latex syntax highlighting. =))' | |||
|
132 | 135 | % override the values here. |
|
133 | 136 | %============================================================================== |
|
134 | 137 | ((* block headingcell -*)) |
|
135 | \ ((= This backslash IS significant, do not delete =)) | |
|
138 | \ | |
|
136 | 139 | ((*- if cell.level == 1 -*)) |
|
137 | 140 | ((* block h1 -*))part((* endblock h1 -*)) |
|
138 | 141 | ((*- elif cell.level == 2 -*)) |
@@ -149,7 +152,7 b' Note: For best display, use latex syntax highlighting. =))' | |||
|
149 | 152 | ((= It's important to make sure that underscores (which tend to be common |
|
150 | 153 | in IPYNB file titles) do not make their way into latex. Sometimes this |
|
151 | 154 | causes latex to barf. =)) |
|
152 |
((*- endif -*)){((( escape |
|
|
155 | ((*- endif -*)){((( escape_underscores(cell.source | markdown2latex ) )))} | |
|
153 | 156 | ((*- endblock headingcell *)) |
|
154 | 157 | |
|
155 | 158 | %============================================================================== |
@@ -190,14 +193,17 b' Note: For best display, use latex syntax highlighting. =))' | |||
|
190 | 193 | %============================================================================== |
|
191 | 194 | ((* block input *)) |
|
192 | 195 | |
|
193 | ((= Global variable used to determine whether or not a header bar has been | |
|
194 | applied to the group of output blocks already. We still need to set | |
|
195 | it to true to make sure that the block bar gets rendered.=)) | |
|
196 | ((*- set needs_header = true -*)) | |
|
196 | % Make sure that atleast 4 lines are below the HR | |
|
197 | \needspace{4\baselineskip} | |
|
198 | ||
|
199 | % Add a horizantal break, along with break title. | |
|
200 | \vspace{10pt} | |
|
201 | {\scriptsize Input}\\* | |
|
202 | \rule[10pt]{\linewidth}{0.5pt} | |
|
203 | \vspace{-25pt} | |
|
197 | 204 | |
|
198 | ((* set text_begining = cell.input | wrap(wrap_size) | get_lines(end=min_header_lines) | highlight *)) | |
|
199 | ((* set text_remainer = cell.input | wrap(wrap_size) | get_lines(start=min_header_lines) | highlight *)) | |
|
200 | ((( inputBlock(text_begining, text_remainer) ))) | |
|
205 | % Add contents below. | |
|
206 | ((( cell.input | highlight ))) | |
|
201 | 207 | ((* endblock input *)) |
|
202 | 208 | |
|
203 | 209 | %============================================================================== |
@@ -206,103 +212,97 b' Note: For best display, use latex syntax highlighting. =))' | |||
|
206 | 212 | % Purpose: Make sure that only one header bar only attaches to the output |
|
207 | 213 | % once. By keeping track of when an input group is started |
|
208 | 214 | %============================================================================== |
|
209 |
((* |
|
|
210 | ||
|
211 | ((= Global variable used to determine whether or not a header bar has been | |
|
212 | applied to the group of output blocks already. =)) | |
|
213 | ((*- set needs_header = true -*)) | |
|
214 | ||
|
215 |
(( |
|
|
215 | ((* block output_group *)) | |
|
216 | ||
|
217 | % If the first block is an image, minipage the image. Else | |
|
218 | % request a certain amount of space for the input text. | |
|
219 | ((* if cell.outputs[0].output_type in ['display_data'] -*)) | |
|
220 | \begin{minipage}{1.0\textwidth} | |
|
221 | ((*- else -*)) | |
|
222 | \needspace{4\baselineskip} | |
|
223 | ((*- endif *)) | |
|
224 | ||
|
225 | % Add a horizantal break, along with break title. | |
|
226 | \vspace{10pt} | |
|
227 | {\scriptsize Output}\\* | |
|
228 | \rule[10pt]{\linewidth}{0.5pt} | |
|
229 | \vspace{-20pt} | |
|
230 | ||
|
231 | % Add the contents of the first block. | |
|
232 | ((( render_output(cell.outputs[0]) ))) | |
|
233 | ||
|
234 | % Close the minipage. | |
|
235 | ((* if cell.outputs[0].output_type in ['display_data'] -*)) | |
|
236 | \end{minipage} | |
|
237 | ((*- endif *)) | |
|
238 | ||
|
239 | % Add remainer of the document contents below. | |
|
240 | ((* for output in cell.outputs[1:] *)) | |
|
241 | ((( render_output(output) ))) | |
|
242 | ((* endfor *)) | |
|
216 | 243 | ((* endblock *)) |
|
217 | 244 | |
|
218 | 245 | %============================================================================== |
|
219 | % Output types | |
|
220 | %============================================================================== | |
|
221 | ((* block pyout *)) | |
|
222 | ((* block data_priority scoped -*)) | |
|
223 | ((( inputBlock(super(),"") ))) | |
|
224 | ((*- endblock *)) | |
|
225 | ((* endblock pyout *)) | |
|
226 | ||
|
227 | ((* block stream *)) | |
|
228 | ((* set text_begining = output.text | wrap(wrap_size) | get_lines(end=min_header_lines) *)) | |
|
229 | ((* set text_remainer = output.text | wrap(wrap_size) | get_lines(start=min_header_lines) *)) | |
|
230 | ((( inputBlock(customVerbatim(text_begining), customVerbatim(text_remainer)) ))) | |
|
231 | ((* endblock stream *)) | |
|
232 | ||
|
233 | ((*- block display_data -*)) | |
|
234 | ((( inputBlock(super(), "") ))) | |
|
235 | ((*- endblock display_data -*)) | |
|
236 | ||
|
237 | ((* block pyerr *)) | |
|
238 | ((* set text_begining = super() | wrap(wrap_size) | get_lines(end=min_header_lines) *)) | |
|
239 | ((* set text_remainer = super() | wrap(wrap_size) | get_lines(start=min_header_lines) *)) | |
|
240 | ((( inputBlock(customVerbatim(text_begining), customVerbatim(text_remainer)) ))) | |
|
241 | ((* endblock pyerr *)) | |
|
242 | ||
|
243 | %============================================================================== | |
|
244 | 246 | % Additional formating |
|
245 | 247 | %============================================================================== |
|
246 | 248 | ((* block data_text *)) |
|
247 |
((( custom |
|
|
249 | ((( custom_verbatim(output.text) ))) | |
|
248 | 250 | ((* endblock *)) |
|
249 | 251 | |
|
250 | 252 | ((* block traceback_line *)) |
|
251 |
((( line | |
|
|
253 | ((( line | indent| rm_ansi ))) | |
|
252 | 254 | ((* endblock traceback_line *)) |
|
253 | 255 | |
|
254 | 256 | %============================================================================== |
|
255 | 257 | % Supported image formats |
|
256 | 258 | %============================================================================== |
|
257 | 259 | ((*- block data_png -*)) |
|
258 |
((( insert |
|
|
260 | ((( insert_graphics(output.key_png) ))) | |
|
259 | 261 | ((*- endblock -*)) |
|
260 | 262 | |
|
261 | 263 | ((*- block data_svg -*)) |
|
262 |
((( insert |
|
|
264 | ((( insert_graphics(output.key_svg) ))) | |
|
263 | 265 | ((*- endblock -*)) |
|
264 | 266 | |
|
265 | 267 | %============================================================================== |
|
266 | 268 | % Support Macros |
|
267 | 269 | %============================================================================== |
|
268 | ((* macro outputBlock(text_begining, text_remainer) -*)) | |
|
269 | ((( nbconvertBlock("Output", text_begining, text_remainer) ))) | |
|
270 | ((* macro render_output(output) -*)) | |
|
271 | ((*- if output.output_type in ['pyout'] -*)) | |
|
272 | ((*- block pyout scoped -*)) | |
|
273 | ((( custom_verbatim(super()) ))) | |
|
274 | ((*- endblock pyout -*)) | |
|
275 | ((*- elif output.output_type in ['stream'] -*)) | |
|
276 | ((*- block stream scoped -*)) | |
|
277 | ((( custom_verbatim(output.text) ))) | |
|
278 | ((*- endblock stream -*)) | |
|
279 | ((*- elif output.output_type in ['display_data'] -*)) | |
|
280 | ((*- block display_data scoped -*)) | |
|
281 | ((( super() ))) | |
|
282 | ((*- endblock display_data -*)) | |
|
283 | ((*- elif output.output_type in ['pyerr'] -*)) | |
|
284 | ((*- block pyerr scoped -*)) | |
|
285 | ((( custom_verbatim(super()) ))) | |
|
286 | ((*- endblock pyerr -*)) | |
|
287 | ((*- endif -*)) | |
|
270 | 288 | ((*- endmacro *)) |
|
271 | 289 | |
|
272 | ((* macro inputBlock(text_begining, text_remainer) -*)) | |
|
273 | ((( nbconvertBlock("Input", text_begining, text_remainer) ))) | |
|
274 | ((*- endmacro *)) | |
|
275 | ||
|
276 | ((* macro nbconvertBlock(blockTitle, text_begining, text_remainer) -*)) | |
|
277 | ((*- if needs_header -*)) | |
|
278 | \vspace{10pt} | |
|
279 | \begin{minipage}{\textwidth} | |
|
280 | {\scriptsize (((blockTitle)))}\\* | |
|
281 | \rule[10pt]{\linewidth}{0.5pt} | |
|
282 | \vspace{-25pt} | |
|
283 | ((( text_begining ))) | |
|
284 | \end{minipage}((( text_remainer ))) | |
|
285 | ((*- set needs_header = false -*)) | |
|
286 | ((*- else -*)) | |
|
287 | ((( text_begining ))) | |
|
288 | ((( text_remainer ))) | |
|
289 | ((*- endif -*)) | |
|
290 | ((*- endmacro *)) | |
|
290 | ((* macro custom_verbatim(text) -*)) | |
|
291 | \lstset{postbreak=\space, breakindent=5pt, escapebegin = \\, breaklines} | |
|
291 | 292 | |
|
292 | ((* macro customVerbatim(text) -*)) | |
|
293 | 293 | \begin{lstlisting} |
|
294 | 294 | ((( text ))) |
|
295 | 295 | \end{lstlisting} |
|
296 | 296 | ((*- endmacro *)) |
|
297 | 297 | |
|
298 |
((* macro insert |
|
|
298 | ((* macro insert_graphics(path) -*)) | |
|
299 | 299 | \begin{center} |
|
300 | 300 | \includegraphics[width=0.7\textwidth]{(((path)))} |
|
301 | 301 | \par |
|
302 | 302 | \end{center} |
|
303 | 303 | ((*- endmacro *)) |
|
304 | 304 | |
|
305 |
((* macro escape |
|
|
305 | ((* macro escape_underscores(text) -*)) | |
|
306 | 306 | ((*- set text = text|replace("_","\\_") -*)) |
|
307 | 307 | ((( text ))) |
|
308 | 308 | ((*- endmacro *)) |
General Comments 0
You need to be logged in to leave comments.
Login now