##// END OF EJS Templates
Changed rule attachment logic....
Jonathan Frederic -
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 -*)){((( escapeUnderscores(cell.source | markdown2latex ) )))}
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.=))
196 ((*- set needs_header = true -*))
197
198
198 ((* set text_begining = cell.input | wrap(wrap_size) | get_lines(end=min_header_lines) | highlight *))
199 % Add a horizantal break, along with break title.
199 ((* set text_remainer = cell.input | wrap(wrap_size) | get_lines(start=min_header_lines) | highlight *))
200 \vspace{10pt}
200 ((( inputBlock(text_begining, text_remainer) )))
201 {\scriptsize Input}\\*
202 \rule[10pt]{\linewidth}{0.5pt}
203 \vspace{-25pt}
204
205 % Add contents below.
206 ((( cell.input | highlight )))
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 ((*- block output_group -*))
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'] -*))
220 \begin{minipage}{1.0\textwidth}
221 ((*- else -*))
222 \needspace{4\baselineskip}
223 ((*- endif *))
214
224
215 ((( super() )))
225 % Add a horizantal break, along with break title.
216 ((* endblock *))
226 \vspace{10pt}
227 {\scriptsize Output}\\*
228 \rule[10pt]{\linewidth}{0.5pt}
229 \vspace{-20pt}
217
230
218 %==============================================================================
231 % Add the contents of the first block.
219 % Output types
232 ((( render_output(cell.outputs[0]) )))
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
233
237 ((* block pyerr *))
234 % Close the minipage.
238 ((* set text_begining = super() | wrap(wrap_size) | get_lines(end=min_header_lines) *))
235 ((* if cell.outputs[0].output_type in ['display_data'] -*))
239 ((* set text_remainer = super() | wrap(wrap_size) | get_lines(start=min_header_lines) *))
236 \end{minipage}
240 ((( inputBlock(customVerbatim(text_begining), customVerbatim(text_remainer)) )))
237 ((*- endif *))
241 ((* endblock pyerr *))
238
239 % Add remainer of the document contents below.
240 ((* for output in cell.outputs[1:] *))
241 ((( render_output(output) )))
242 ((* endfor *))
243 ((* endblock *))
242
244
243 %==============================================================================
245 %==============================================================================
244 % Additional formating
246 % Additional formating
245 %==============================================================================
247 %==============================================================================
246 ((* block data_text *))
248 ((* block data_text *))
247 ((( customVerbatim(output.text | wrap(wrap_size)) )))
249 ((( custom_verbatim(output.text) )))
248 ((* endblock *))
250 ((* endblock *))
249
251
250 ((* block traceback_line *))
252 ((* block traceback_line *))
251 ((( line | wrap(wrap_size) |indent| rm_ansi )))
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 ((( insertGraphics(output.key_png) )))
260 ((( insert_graphics(output.key_png) )))
259 ((*- endblock -*))
261 ((*- endblock -*))
260
262
261 ((*- block data_svg -*))
263 ((*- block data_svg -*))
262 ((( insertGraphics(output.key_svg) )))
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'] -*))
270 ((*- endmacro *))
272 ((*- block pyout scoped -*))
271
273 ((( custom_verbatim(super()) )))
272 ((* macro inputBlock(text_begining, text_remainer) -*))
274 ((*- endblock pyout -*))
273 ((( nbconvertBlock("Input", text_begining, text_remainer) )))
275 ((*- elif output.output_type in ['stream'] -*))
274 ((*- endmacro *))
276 ((*- block stream scoped -*))
275
277 ((( custom_verbatim(output.text) )))
276 ((* macro nbconvertBlock(blockTitle, text_begining, text_remainer) -*))
278 ((*- endblock stream -*))
277 ((*- if needs_header -*))
279 ((*- elif output.output_type in ['display_data'] -*))
278 \vspace{10pt}
280 ((*- block display_data scoped -*))
279 \begin{minipage}{\textwidth}
281 ((( super() )))
280 {\scriptsize (((blockTitle)))}\\*
282 ((*- endblock display_data -*))
281 \rule[10pt]{\linewidth}{0.5pt}
283 ((*- elif output.output_type in ['pyerr'] -*))
282 \vspace{-25pt}
284 ((*- block pyerr scoped -*))
283 ((( text_begining )))
285 ((( custom_verbatim(super()) )))
284 \end{minipage}((( text_remainer )))
286 ((*- endblock pyerr -*))
285 ((*- set needs_header = false -*))
286 ((*- else -*))
287 ((( text_begining )))
288 ((( text_remainer )))
289 ((*- endif -*))
287 ((*- endif -*))
290 ((*- endmacro *))
288 ((*- endmacro *))
291
289
292 ((* macro customVerbatim(text) -*))
290 ((* macro custom_verbatim(text) -*))
291 \lstset{postbreak=\space, breakindent=5pt, escapebegin = \\, breaklines}
292
293 \begin{lstlisting}
293 \begin{lstlisting}
294 ((( text )))
294 ((( text )))
295 \end{lstlisting}
295 \end{lstlisting}
296 ((*- endmacro *))
296 ((*- endmacro *))
297
297
298 ((* macro insertGraphics(path) -*))
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 escapeUnderscores(text) -*))
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