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