Show More
@@ -14,19 +14,18 b' Note: For best display, use latex syntax highlighting. =))' | |||
|
14 | 14 | %============================================================================== |
|
15 | 15 | |
|
16 | 16 | % In order to make sure that the input/output header follows the code it |
|
17 | % preceeds, we have to use a minipage environment. This causes problems | |
|
18 | % for large blocks of input and output. If there is a large input/output | |
|
19 | % block, we don't want to minipage the whole thing since it will break | |
|
20 | % the line wrapping. The solution is to split the input/output line by | |
|
21 | % line before we minipage which allows us to minipage the first X lines | |
|
22 | % preceeding the input/output bar. That way, a select amount of lines | |
|
23 | % force the input/output bar to follow it around. | |
|
24 | ((*- set min_header_lines = 3 -*)) | |
|
17 | % preceeds, the needspace package is used to request that a certain | |
|
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 | |
|
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 | |
|
22 | % the header will be forced to group with without a page break. | |
|
23 | ((*- set min_header_lines = 4 -*)) | |
|
25 | 24 | |
|
26 | 25 | % This is the number of characters that are permitted per line. It's |
|
27 | 26 | % important that this limit is set so characters do not run off the |
|
28 | 27 | % edges of latex pages (since latex does not always seem smart enough |
|
29 | % to prevent this.) | |
|
28 | % to prevent this in some cases.) This is only applied to textual output | |
|
30 | 29 | ((*- set wrap_size = 87 -*)) |
|
31 | 30 | |
|
32 | 31 | %============================================================================== |
@@ -194,7 +193,7 b' Note: For best display, use latex syntax highlighting. =))' | |||
|
194 | 193 | ((* block input *)) |
|
195 | 194 | |
|
196 | 195 | % Make sure that atleast 4 lines are below the HR |
|
197 |
\needspace{ |
|
|
196 | \needspace{((( min_header_lines )))\baselineskip} | |
|
198 | 197 | |
|
199 | 198 | % Add a horizantal break, along with break title. |
|
200 | 199 | \vspace{10pt} |
@@ -216,11 +215,7 b' Note: For best display, use latex syntax highlighting. =))' | |||
|
216 | 215 | |
|
217 | 216 | % If the first block is an image, minipage the image. Else |
|
218 | 217 | % 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 *)) | |
|
218 | ((( iff_figure(cell.outputs[0], "\begin{minipage}{1.0\textwidth}", "\needspace{" + min_header_lines + "\baselineskip}") ))) | |
|
224 | 219 | |
|
225 | 220 | % Add a horizantal break, along with break title. |
|
226 | 221 | \vspace{10pt} |
@@ -232,9 +227,7 b' Note: For best display, use latex syntax highlighting. =))' | |||
|
232 | 227 | ((( render_output(cell.outputs[0]) ))) |
|
233 | 228 | |
|
234 | 229 | % Close the minipage. |
|
235 | ((* if cell.outputs[0].output_type in ['display_data'] -*)) | |
|
236 | \end{minipage} | |
|
237 | ((*- endif *)) | |
|
230 | ((( iff_figure(cell.outputs[0], "\end{minipage}", "") ))) | |
|
238 | 231 | |
|
239 | 232 | % Add remainer of the document contents below. |
|
240 | 233 | ((* for output in cell.outputs[1:] *)) |
@@ -267,6 +260,9 b' Note: For best display, use latex syntax highlighting. =))' | |||
|
267 | 260 | %============================================================================== |
|
268 | 261 | % Support Macros |
|
269 | 262 | %============================================================================== |
|
263 | ||
|
264 | % Name: render_output | |
|
265 | % Purpose: Renders an output block appropriately. | |
|
270 | 266 | ((* macro render_output(output) -*)) |
|
271 | 267 | ((*- if output.output_type in ['pyout'] -*)) |
|
272 | 268 | ((*- block pyout scoped -*)) |
@@ -287,14 +283,30 b' Note: For best display, use latex syntax highlighting. =))' | |||
|
287 | 283 | ((*- endif -*)) |
|
288 | 284 | ((*- endmacro *)) |
|
289 | 285 | |
|
286 | % Name: iff_figure | |
|
287 | % Purpose: If the output block provided is a figure type, the 'true_content' | |
|
288 | % parameter will be returned. Else, the 'false_content'. | |
|
289 | ((* macro iff_figure(output, true_content, false_content) -*)) | |
|
290 | ((* if output.output_type in ['display_data'] -*)) | |
|
291 | ((( true_content ))) | |
|
292 | ((*- else -*)) | |
|
293 | ((( false_content ))) | |
|
294 | ((*- endif *)) | |
|
295 | ((*- endmacro *)) | |
|
296 | ||
|
297 | % Name: custom_verbatim | |
|
298 | % Purpose: This macro creates a verbatim style block that fits the existing | |
|
299 | % sphinx style more readily than standard verbatim blocks. | |
|
290 | 300 | ((* macro custom_verbatim(text) -*)) |
|
291 | 301 | \lstset{postbreak=\space, breakindent=5pt, escapebegin = \\, breaklines} |
|
292 | 302 | |
|
293 | 303 | \begin{lstlisting} |
|
294 | ((( text ))) | |
|
304 | ((( text | wrap(wrap_size) ))) | |
|
295 | 305 | \end{lstlisting} |
|
296 | 306 | ((*- endmacro *)) |
|
297 | 307 | |
|
308 | % Name: insert_graphics | |
|
309 | % Purpose: This macro will insert an image in the latex document given a path. | |
|
298 | 310 | ((* macro insert_graphics(path) -*)) |
|
299 | 311 | \begin{center} |
|
300 | 312 | \includegraphics[width=0.7\textwidth]{(((path)))} |
@@ -302,6 +314,9 b' Note: For best display, use latex syntax highlighting. =))' | |||
|
302 | 314 | \end{center} |
|
303 | 315 | ((*- endmacro *)) |
|
304 | 316 | |
|
317 | % Name: escape_underscores | |
|
318 | % Purpose: Underscores cause a problem in latex. It's important that we | |
|
319 | % escape any underscores that appear. | |
|
305 | 320 | ((* macro escape_underscores(text) -*)) |
|
306 | 321 | ((*- set text = text|replace("_","\\_") -*)) |
|
307 | 322 | ((( text ))) |
General Comments 0
You need to be logged in to leave comments.
Login now