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