Show More
@@ -1,356 +1,371 b'' | |||||
1 | ((= NBConvert Sphinx-Latex Template |
|
1 | ((= NBConvert Sphinx-Latex Template | |
2 |
|
2 | |||
3 | Purpose: Allow export of PDF friendly Latex inspired by Sphinx. Most of the |
|
3 | Purpose: Allow export of PDF friendly Latex inspired by Sphinx. Most of the | |
4 | template is derived directly from Sphinx source. |
|
4 | template is derived directly from Sphinx source. | |
5 |
|
5 | |||
6 | Inheritance: null>display_priority>latex_base |
|
6 | Inheritance: null>display_priority>latex_base | |
7 |
|
7 | |||
8 | Note: For best display, use latex syntax highlighting. =)) |
|
8 | Note: For best display, use latex syntax highlighting. =)) | |
9 |
|
9 | |||
10 | ((*- extends 'display_priority.tplx' -*)) |
|
10 | ((*- extends 'display_priority.tplx' -*)) | |
11 |
|
11 | |||
12 | %============================================================================== |
|
12 | %============================================================================== | |
13 | % Declarations |
|
13 | % Declarations | |
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, the needspace package is used to request that a certain |
|
17 | % preceeds, the needspace package is used to request that a certain | |
18 | % amount of lines (specified by this variable) are reserved. If those |
|
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 |
|
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 |
|
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 |
|
21 | % rendered together. This value specifies the number of lines that | |
22 | % the header will be forced to group with without a page break. |
|
22 | % the header will be forced to group with without a page break. | |
23 | ((*- set min_header_lines = 4 -*)) |
|
23 | ((*- set min_header_lines = 4 -*)) | |
24 |
|
24 | |||
25 | % 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 | |
26 | % 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 | |
27 | % 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 | |
28 | % to prevent this in some cases.) This is only applied to textual output |
|
28 | % to prevent this in some cases.) This is only applied to textual output | |
29 | ((*- set wrap_size = 85 -*)) |
|
29 | ((* if resources.sphinx.outputstyle == 'simple' *)) | |
|
30 | ((*- set wrap_size = 85 -*)) | |||
|
31 | ((* elif resources.sphinx.outputstyle == 'notebook' *)) | |||
|
32 | ((*- set wrap_size = 70 -*)) | |||
|
33 | ((* endif *)) | |||
30 |
|
34 | |||
31 | %============================================================================== |
|
35 | %============================================================================== | |
32 | % Header |
|
36 | % Header | |
33 | %============================================================================== |
|
37 | %============================================================================== | |
34 | ((* block header *)) |
|
38 | ((* block header *)) | |
35 |
|
39 | |||
36 | % Header, overrides base |
|
40 | % Header, overrides base | |
37 |
|
41 | |||
38 | % Make sure that the sphinx doc style knows who it inherits from. |
|
42 | % Make sure that the sphinx doc style knows who it inherits from. | |
39 | \def\sphinxdocclass{(((parentdocumentclass)))} |
|
43 | \def\sphinxdocclass{(((parentdocumentclass)))} | |
40 |
|
44 | |||
41 | % Declare the document class |
|
45 | % Declare the document class | |
42 | \documentclass[letterpaper,10pt,english]{((( resources.sphinx.texinputs )))/sphinx(((documentclass)))} |
|
46 | \documentclass[letterpaper,10pt,english]{((( resources.sphinx.texinputs )))/sphinx(((documentclass)))} | |
43 |
|
47 | |||
44 | % Imports |
|
48 | % Imports | |
45 | \usepackage[utf8]{inputenc} |
|
49 | \usepackage[utf8]{inputenc} | |
46 | \DeclareUnicodeCharacter{00A0}{\\nobreakspace} |
|
50 | \DeclareUnicodeCharacter{00A0}{\\nobreakspace} | |
47 | \usepackage[T1]{fontenc} |
|
51 | \usepackage[T1]{fontenc} | |
48 | \usepackage{babel} |
|
52 | \usepackage{babel} | |
49 | \usepackage{times} |
|
53 | \usepackage{times} | |
50 | \usepackage{import} |
|
54 | \usepackage{import} | |
51 | \usepackage[((( resources.sphinx.chapterstyle )))]{((( resources.sphinx.texinputs )))/fncychap} |
|
55 | \usepackage[((( resources.sphinx.chapterstyle )))]{((( resources.sphinx.texinputs )))/fncychap} | |
52 | \usepackage{longtable} |
|
56 | \usepackage{longtable} | |
53 | \usepackage{((( resources.sphinx.texinputs )))/sphinx} |
|
57 | \usepackage{((( resources.sphinx.texinputs )))/sphinx} | |
54 | \usepackage{multirow} |
|
58 | \usepackage{multirow} | |
55 |
|
59 | |||
56 | \usepackage{amsmath} |
|
60 | \usepackage{amsmath} | |
57 | \usepackage{amssymb} |
|
61 | \usepackage{amssymb} | |
58 | \usepackage{ucs} |
|
62 | \usepackage{ucs} | |
59 | \usepackage{enumerate} |
|
63 | \usepackage{enumerate} | |
60 |
|
64 | |||
61 | % Used to make the Input/Output rules follow around the contents. |
|
65 | % Used to make the Input/Output rules follow around the contents. | |
62 | \usepackage{needspace} |
|
66 | \usepackage{needspace} | |
63 |
|
67 | |||
64 | % Pygments requirements |
|
68 | % Pygments requirements | |
65 | \usepackage{fancyvrb} |
|
69 | \usepackage{fancyvrb} | |
66 | \usepackage{color} |
|
70 | \usepackage{color} | |
67 |
|
71 | |||
68 | % Needed to box output/input |
|
72 | % Needed to box output/input | |
69 | \usepackage{mdframed} |
|
73 | \usepackage{mdframed} | |
70 | \usepackage{alltt} |
|
74 | \usepackage{alltt} | |
71 |
|
75 | |||
72 | % Used to load and display graphics |
|
76 | % Used to load and display graphics | |
73 | \usepackage{graphicx} |
|
77 | \usepackage{graphicx} | |
74 | \graphicspath{ {figs/} } |
|
78 | \graphicspath{ {figs/} } | |
75 |
|
79 | |||
76 | % For formatting output while also word wrapping. |
|
80 | % For formatting output while also word wrapping. | |
77 | \usepackage{listings} |
|
81 | \usepackage{listings} | |
78 | \lstset{breaklines=true} |
|
82 | \lstset{breaklines=true} | |
79 | \lstset{basicstyle=\small\ttfamily} |
|
83 | \lstset{basicstyle=\small\ttfamily} | |
80 |
|
84 | |||
81 | %Pygments definitions |
|
85 | %Pygments definitions | |
82 | ((( resources.sphinx.pygment_definitions ))) |
|
86 | ((( resources.sphinx.pygment_definitions ))) | |
83 |
|
87 | |||
84 | %Set pygments styles if needed... |
|
88 | %Set pygments styles if needed... | |
85 | ((* if resources.sphinx.outputstyle == 'notebook' *)) |
|
89 | ((* if resources.sphinx.outputstyle == 'notebook' *)) | |
86 | \definecolor{nbframe-border}{rgb}{0.8,0.8,0.8} |
|
90 | \definecolor{nbframe-border}{rgb}{0.8,0.8,0.8} | |
87 | \definecolor{nbframe-bg}{rgb}{0.95,0.95,0.95} |
|
91 | \definecolor{nbframe-bg}{rgb}{0.95,0.95,0.95} | |
88 |
|
92 | |||
89 |
\newenvironment{ColorVerbatim} |
|
93 | \newenvironment{ColorVerbatim} | |
90 |
{ |
|
94 | {\begin{mdframed}[backgroundcolor=nbframe-bg, userdefinedwidth=1\linewidth, leftmargin=0.08\linewidth, linecolor=nbframe-border, linewidth=1pt, usetwoside=false]} | |
91 | {\end{mdframed}} |
|
95 | {\end{mdframed}} | |
92 |
|
96 | |||
93 | \renewenvironment{Verbatim}[1][\unskip] |
|
97 | \renewenvironment{Verbatim}[1][\unskip] | |
94 | {\begin{alltt}} |
|
98 | {\begin{alltt}} | |
95 | {\end{alltt}} |
|
99 | {\end{alltt}} | |
96 | ((* endif *)) |
|
100 | ((* endif *)) | |
97 |
|
101 | |||
98 | % Help prevent overflowing lines due to urls and other hard-to-break |
|
102 | % Help prevent overflowing lines due to urls and other hard-to-break | |
99 | % entities. This doesn't catch everything... |
|
103 | % entities. This doesn't catch everything... | |
100 | \sloppy |
|
104 | \sloppy | |
101 |
|
105 | |||
102 | % Document level variables |
|
106 | % Document level variables | |
103 | \title{((( nb.metadata.name | escape_tex )))} |
|
107 | \title{((( nb.metadata.name | escape_tex )))} | |
104 | \date{((( nb.metadata._draft.date | escape_tex )))} |
|
108 | \date{((( nb.metadata._draft.date | escape_tex )))} | |
105 | \release{((( nb.metadata._draft.version | escape_tex )))} |
|
109 | \release{((( nb.metadata._draft.version | escape_tex )))} | |
106 | \author{((( nb.metadata._draft.author | escape_tex )))} |
|
110 | \author{((( nb.metadata._draft.author | escape_tex )))} | |
107 | \renewcommand{\releasename}{((( nb.metadata._draft.release | escape_tex )))} |
|
111 | \renewcommand{\releasename}{((( nb.metadata._draft.release | escape_tex )))} | |
108 |
|
112 | |||
109 | % TODO: Add option for the user to specify a logo for his/her export. |
|
113 | % TODO: Add option for the user to specify a logo for his/her export. | |
110 | \newcommand{\sphinxlogo}{} |
|
114 | \newcommand{\sphinxlogo}{} | |
111 |
|
115 | |||
112 | % Make the index page of the document. |
|
116 | % Make the index page of the document. | |
113 | \makeindex |
|
117 | \makeindex | |
114 |
|
118 | |||
115 | % Import sphinx document type specifics. |
|
119 | % Import sphinx document type specifics. | |
116 | ((* block sphinxheader *))((* endblock sphinxheader *)) |
|
120 | ((* block sphinxheader *))((* endblock sphinxheader *)) | |
117 | ((* endblock header *)) |
|
121 | ((* endblock header *)) | |
118 |
|
122 | |||
119 | %============================================================================== |
|
123 | %============================================================================== | |
120 | % Body |
|
124 | % Body | |
121 | %============================================================================== |
|
125 | %============================================================================== | |
122 | ((* block body *)) |
|
126 | ((* block body *)) | |
123 | ((* block bodyBegin *)) |
|
127 | ((* block bodyBegin *)) | |
124 | % Body |
|
128 | % Body | |
125 |
|
129 | |||
126 | % Start of the document |
|
130 | % Start of the document | |
127 | \begin{document} |
|
131 | \begin{document} | |
128 | \maketitle |
|
132 | \maketitle | |
129 | \tableofcontents |
|
133 | \tableofcontents | |
130 |
|
134 | |||
131 | ((* endblock bodyBegin *))((( super() )))((* block bodyEnd *)) |
|
135 | ((* endblock bodyBegin *))((( super() )))((* block bodyEnd *)) | |
132 |
|
136 | |||
133 | \renewcommand{\indexname}{Index} |
|
137 | \renewcommand{\indexname}{Index} | |
134 | \printindex |
|
138 | \printindex | |
135 |
|
139 | |||
136 | % End of document |
|
140 | % End of document | |
137 | \end{document} |
|
141 | \end{document} | |
138 | ((* endblock bodyEnd *)) |
|
142 | ((* endblock bodyEnd *)) | |
139 | ((* endblock body *)) |
|
143 | ((* endblock body *)) | |
140 |
|
144 | |||
141 | %============================================================================== |
|
145 | %============================================================================== | |
142 | % Footer |
|
146 | % Footer | |
143 | %============================================================================== |
|
147 | %============================================================================== | |
144 | ((* block footer *)) |
|
148 | ((* block footer *)) | |
145 | ((* endblock footer *)) |
|
149 | ((* endblock footer *)) | |
146 |
|
150 | |||
147 | %============================================================================== |
|
151 | %============================================================================== | |
148 | % Headings |
|
152 | % Headings | |
149 | % |
|
153 | % | |
150 | % Purpose: Format pynb headers as sphinx headers. Depending on the Sphinx |
|
154 | % Purpose: Format pynb headers as sphinx headers. Depending on the Sphinx | |
151 | % style that is active, this will change. Thus sphinx styles will |
|
155 | % style that is active, this will change. Thus sphinx styles will | |
152 | % override the values here. |
|
156 | % override the values here. | |
153 | %============================================================================== |
|
157 | %============================================================================== | |
154 | ((* block headingcell -*)) |
|
158 | ((* block headingcell -*)) | |
155 | \ |
|
159 | \ | |
156 | ((*- if cell.level == 1 -*)) |
|
160 | ((*- if cell.level == 1 -*)) | |
157 | ((* block h1 -*))part((* endblock h1 -*)) |
|
161 | ((* block h1 -*))part((* endblock h1 -*)) | |
158 | ((*- elif cell.level == 2 -*)) |
|
162 | ((*- elif cell.level == 2 -*)) | |
159 | ((* block h2 -*))chapter((* endblock h2 -*)) |
|
163 | ((* block h2 -*))chapter((* endblock h2 -*)) | |
160 | ((*- elif cell.level == 3 -*)) |
|
164 | ((*- elif cell.level == 3 -*)) | |
161 | ((* block h3 -*))section((* endblock h3 -*)) |
|
165 | ((* block h3 -*))section((* endblock h3 -*)) | |
162 | ((*- elif cell.level == 4 -*)) |
|
166 | ((*- elif cell.level == 4 -*)) | |
163 | ((* block h4 -*))subsection((* endblock h4 -*)) |
|
167 | ((* block h4 -*))subsection((* endblock h4 -*)) | |
164 | ((*- elif cell.level == 5 -*)) |
|
168 | ((*- elif cell.level == 5 -*)) | |
165 | ((* block h5 -*))subsubsection((* endblock h5 -*)) |
|
169 | ((* block h5 -*))subsubsection((* endblock h5 -*)) | |
166 | ((*- elif cell.level == 6 -*)) |
|
170 | ((*- elif cell.level == 6 -*)) | |
167 | ((* block h6 -*))paragraph((* endblock h6 -*)) |
|
171 | ((* block h6 -*))paragraph((* endblock h6 -*)) | |
168 |
|
172 | |||
169 | ((= It's important to make sure that underscores (which tend to be common |
|
173 | ((= It's important to make sure that underscores (which tend to be common | |
170 | in IPYNB file titles) do not make their way into latex. Sometimes this |
|
174 | in IPYNB file titles) do not make their way into latex. Sometimes this | |
171 | causes latex to barf. =)) |
|
175 | causes latex to barf. =)) | |
172 | ((*- endif -*)){((( escape_underscores(cell.source | markdown2latex ) )))} |
|
176 | ((*- endif -*)){((( escape_underscores(cell.source | markdown2latex ) )))} | |
173 | ((*- endblock headingcell *)) |
|
177 | ((*- endblock headingcell *)) | |
174 |
|
178 | |||
175 | %============================================================================== |
|
179 | %============================================================================== | |
176 | % Markdown |
|
180 | % Markdown | |
177 | % |
|
181 | % | |
178 | % Purpose: Convert markdown to latex. Here markdown2latex is explicitly |
|
182 | % Purpose: Convert markdown to latex. Here markdown2latex is explicitly | |
179 | % called since we know we want latex output. |
|
183 | % called since we know we want latex output. | |
180 | %============================================================================== |
|
184 | %============================================================================== | |
181 | ((*- block markdowncell scoped-*)) |
|
185 | ((*- block markdowncell scoped-*)) | |
182 | ((( cell.source | markdown2latex ))) |
|
186 | ((( cell.source | markdown2latex ))) | |
183 | ((*- endblock markdowncell -*)) |
|
187 | ((*- endblock markdowncell -*)) | |
184 |
|
188 | |||
185 | %============================================================================== |
|
189 | %============================================================================== | |
186 | % Rawcell |
|
190 | % Rawcell | |
187 | % |
|
191 | % | |
188 | % Purpose: Raw text cells allow the user to manually inject document code that |
|
192 | % Purpose: Raw text cells allow the user to manually inject document code that | |
189 | % will not get touched by the templating system. |
|
193 | % will not get touched by the templating system. | |
190 | %============================================================================== |
|
194 | %============================================================================== | |
191 | ((*- block rawcell *)) |
|
195 | ((*- block rawcell *)) | |
192 | ((( cell.source | wrap(wrap_size) ))) |
|
196 | ((( cell.source | wrap(wrap_size) ))) | |
193 | ((* endblock rawcell -*)) |
|
197 | ((* endblock rawcell -*)) | |
194 |
|
198 | |||
195 | %============================================================================== |
|
199 | %============================================================================== | |
196 | % Unknowncell |
|
200 | % Unknowncell | |
197 | % |
|
201 | % | |
198 | % Purpose: This is the catch anything unhandled. To display this data, we |
|
202 | % Purpose: This is the catch anything unhandled. To display this data, we | |
199 | % remove all possible latex conflicts and wrap the characters so they |
|
203 | % remove all possible latex conflicts and wrap the characters so they | |
200 | % can't flow off of the page. |
|
204 | % can't flow off of the page. | |
201 | %============================================================================== |
|
205 | %============================================================================== | |
202 | ((* block unknowncell scoped*)) |
|
206 | ((* block unknowncell scoped*)) | |
203 |
|
207 | |||
204 | % Unsupported cell type, no formatting |
|
208 | % Unsupported cell type, no formatting | |
205 | ((( cell.source | wrap | escape_tex ))) |
|
209 | ((( cell.source | wrap | escape_tex ))) | |
206 | ((* endblock unknowncell *)) |
|
210 | ((* endblock unknowncell *)) | |
207 |
|
211 | |||
208 | %============================================================================== |
|
212 | %============================================================================== | |
209 | % Input |
|
213 | % Input | |
210 | %============================================================================== |
|
214 | %============================================================================== | |
211 | ((* block input *)) |
|
215 | ((* block input *)) | |
212 | ((* if resources.sphinx.outputstyle == 'simple' *)) |
|
216 | ((* if resources.sphinx.outputstyle == 'simple' *)) | |
213 | % Make sure that atleast 4 lines are below the HR |
|
217 | % Make sure that atleast 4 lines are below the HR | |
214 | \needspace{((( min_header_lines )))\baselineskip} |
|
218 | \needspace{((( min_header_lines )))\baselineskip} | |
215 |
|
219 | |||
216 | % Add a horizantal break, along with break title. |
|
220 | % Add a horizantal break, along with break title. | |
217 | \vspace{10pt} |
|
221 | \vspace{10pt} | |
218 | {\scriptsize Input}\\* |
|
222 | {\scriptsize Input}\\* | |
219 | \rule[10pt]{\linewidth}{0.5pt} |
|
223 | \rule[10pt]{\linewidth}{0.5pt} | |
220 | \vspace{-25pt} |
|
224 | \vspace{-25pt} | |
221 |
|
225 | |||
222 | % Add contents below. |
|
226 | % Add contents below. | |
223 | ((( cell.input | highlight ))) |
|
227 | ((( cell.input | highlight ))) | |
224 |
|
228 | |||
225 | ((* elif resources.sphinx.outputstyle == 'notebook' *)) |
|
229 | ((* elif resources.sphinx.outputstyle == 'notebook' *)) | |
226 |
\ |
|
230 | \textbf{In {[}((( cell.prompt_number ))){]}:}\\* | |
|
231 | \vspace{-2.4\baselineskip} | |||
|
232 | \begin{ColorVerbatim} | |||
227 | ((( cell.input | highlight ))) |
|
233 | ((( cell.input | highlight ))) | |
228 | \end{ColorVerbatim} |
|
234 | \end{ColorVerbatim} | |
229 | ((* endif *)) |
|
235 | ((* endif *)) | |
230 | ((* endblock input *)) |
|
236 | ((* endblock input *)) | |
231 |
|
237 | |||
232 | %============================================================================== |
|
238 | %============================================================================== | |
233 | % Output_Group |
|
239 | % Output_Group | |
234 | % |
|
240 | % | |
235 | % Purpose: Make sure that only one header bar only attaches to the output |
|
241 | % Purpose: Make sure that only one header bar only attaches to the output | |
236 | % once. By keeping track of when an input group is started |
|
242 | % once. By keeping track of when an input group is started | |
237 | %============================================================================== |
|
243 | %============================================================================== | |
238 | ((* block output_group *)) |
|
244 | ((* block output_group *)) | |
239 | ((* if resources.sphinx.outputstyle == 'simple' *)) |
|
245 | ((* if resources.sphinx.outputstyle == 'simple' *)) | |
240 |
|
246 | |||
241 | % If the first block is an image, minipage the image. Else |
|
247 | % If the first block is an image, minipage the image. Else | |
242 | % request a certain amount of space for the input text. |
|
248 | % request a certain amount of space for the input text. | |
243 | ((( iff_figure(cell.outputs[0], "\\begin{minipage}{1.0\\textwidth}", "\\needspace{" ~ min_header_lines ~ "\\baselineskip}") ))) |
|
249 | ((( iff_figure(cell.outputs[0], "\\begin{minipage}{1.0\\textwidth}", "\\needspace{" ~ min_header_lines ~ "\\baselineskip}") ))) | |
244 |
|
250 | |||
245 | % Add a horizantal break, along with break title. |
|
251 | % Add a horizantal break, along with break title. | |
246 | \vspace{10pt} |
|
252 | \vspace{10pt} | |
247 | {\scriptsize Output}\\* |
|
253 | {\scriptsize Output}\\* | |
248 | \rule[10pt]{\linewidth}{0.5pt} |
|
254 | \rule[10pt]{\linewidth}{0.5pt} | |
249 | \vspace{-20pt} |
|
255 | \vspace{-20pt} | |
250 |
|
256 | |||
251 | % Add the contents of the first block. |
|
257 | % Add the contents of the first block. | |
252 | ((( render_output(cell.outputs[0]) ))) |
|
258 | ((( render_output(cell.outputs[0]) ))) | |
253 |
|
259 | |||
254 | % Close the minipage. |
|
260 | % Close the minipage. | |
255 | ((( iff_figure(cell.outputs[0], "\\end{minipage}", "") ))) |
|
261 | ((( iff_figure(cell.outputs[0], "\\end{minipage}", "") ))) | |
256 |
|
262 | |||
257 | % Add remainer of the document contents below. |
|
263 | % Add remainer of the document contents below. | |
258 | ((* for output in cell.outputs[1:] *)) |
|
264 | ((* for output in cell.outputs[1:] *)) | |
259 | ((( render_output(output) ))) |
|
265 | ((( render_output(output) ))) | |
260 | ((* endfor *)) |
|
266 | ((* endfor *)) | |
261 | ((* elif resources.sphinx.outputstyle == 'notebook' *)) |
|
267 | ((* elif resources.sphinx.outputstyle == 'notebook' *)) | |
262 |
|
268 | |||
263 | % Add remainer of the document contents below. |
|
269 | %Skip one line down. | |
264 | ((* for output in cell.outputs *)) |
|
270 | \vspace{1\baselineskip} | |
265 | ((( render_output(output) ))) |
|
271 | ||
266 | ((* endfor *)) |
|
272 | % Add document contents. | |
|
273 | \begin{ColorVerbatim} | |||
|
274 | ((* for output in cell.outputs *)) | |||
|
275 | ((( render_output(output) ))) | |||
|
276 | ((* endfor *)) | |||
|
277 | \end{ColorVerbatim} | |||
267 | ((* endif *)) |
|
278 | ((* endif *)) | |
268 | ((* endblock *)) |
|
279 | ((* endblock *)) | |
269 |
|
280 | |||
270 | %============================================================================== |
|
281 | %============================================================================== | |
271 | % Additional formating |
|
282 | % Additional formating | |
272 | %============================================================================== |
|
283 | %============================================================================== | |
273 | ((* block data_text *)) |
|
284 | ((* block data_text *)) | |
274 | ((( custom_verbatim(output.text) ))) |
|
285 | ((( custom_verbatim(output.text) ))) | |
275 | ((* endblock *)) |
|
286 | ((* endblock *)) | |
276 |
|
287 | |||
277 | ((* block traceback_line *)) |
|
288 | ((* block traceback_line *)) | |
278 | ((( line | indent| rm_ansi ))) |
|
289 | ((( line | indent| rm_ansi ))) | |
279 | ((* endblock traceback_line *)) |
|
290 | ((* endblock traceback_line *)) | |
280 |
|
291 | |||
281 | %============================================================================== |
|
292 | %============================================================================== | |
282 | % Supported image formats |
|
293 | % Supported image formats | |
283 | %============================================================================== |
|
294 | %============================================================================== | |
284 | ((*- block data_png -*)) |
|
295 | ((*- block data_png -*)) | |
285 | ((( insert_graphics(output.key_png) ))) |
|
296 | ((( insert_graphics(output.key_png) ))) | |
286 | ((*- endblock -*)) |
|
297 | ((*- endblock -*)) | |
287 |
|
298 | |||
288 | ((*- block data_svg -*)) |
|
299 | ((*- block data_svg -*)) | |
289 | ((( insert_graphics(output.key_svg) ))) |
|
300 | ((( insert_graphics(output.key_svg) ))) | |
290 | ((*- endblock -*)) |
|
301 | ((*- endblock -*)) | |
291 |
|
302 | |||
292 | %============================================================================== |
|
303 | %============================================================================== | |
293 | % Support Macros |
|
304 | % Support Macros | |
294 | %============================================================================== |
|
305 | %============================================================================== | |
295 |
|
306 | |||
296 | % Name: render_output |
|
307 | % Name: render_output | |
297 | % Purpose: Renders an output block appropriately. |
|
308 | % Purpose: Renders an output block appropriately. | |
298 | ((* macro render_output(output) -*)) |
|
309 | ((* macro render_output(output) -*)) | |
299 | ((*- if output.output_type == 'pyout' -*)) |
|
310 | ((*- if output.output_type == 'pyout' -*)) | |
300 | ((*- block pyout scoped -*)) |
|
311 | ((*- block pyout scoped -*)) | |
301 | ((( custom_verbatim(super()) ))) |
|
312 | ((( custom_verbatim(super()) ))) | |
302 | ((*- endblock pyout -*)) |
|
313 | ((*- endblock pyout -*)) | |
303 | ((*- elif output.output_type == 'stream' -*)) |
|
314 | ((*- elif output.output_type == 'stream' -*)) | |
304 | ((*- block stream scoped -*)) |
|
315 | ((*- block stream scoped -*)) | |
305 | ((( custom_verbatim(output.text) ))) |
|
316 | ((( custom_verbatim(output.text) ))) | |
306 | ((*- endblock stream -*)) |
|
317 | ((*- endblock stream -*)) | |
307 | ((*- elif output.output_type == 'display_data' -*)) |
|
318 | ((*- elif output.output_type == 'display_data' -*)) | |
308 | ((*- block display_data scoped -*)) |
|
319 | ((*- block display_data scoped -*)) | |
309 | ((( super() ))) |
|
320 | ((( super() ))) | |
310 | ((*- endblock display_data -*)) |
|
321 | ((*- endblock display_data -*)) | |
311 | ((*- elif output.output_type == 'pyerr' -*)) |
|
322 | ((*- elif output.output_type == 'pyerr' -*)) | |
312 | ((*- block pyerr scoped -*)) |
|
323 | ((*- block pyerr scoped -*)) | |
313 | ((( custom_verbatim(super()) ))) |
|
324 | ((( custom_verbatim(super()) ))) | |
314 | ((*- endblock pyerr -*)) |
|
325 | ((*- endblock pyerr -*)) | |
315 | ((*- endif -*)) |
|
326 | ((*- endif -*)) | |
316 | ((*- endmacro *)) |
|
327 | ((*- endmacro *)) | |
317 |
|
328 | |||
318 | % Name: iff_figure |
|
329 | % Name: iff_figure | |
319 | % Purpose: If the output block provided is a figure type, the 'true_content' |
|
330 | % Purpose: If the output block provided is a figure type, the 'true_content' | |
320 | % parameter will be returned. Else, the 'false_content'. |
|
331 | % parameter will be returned. Else, the 'false_content'. | |
321 | ((* macro iff_figure(output, true_content, false_content) -*)) |
|
332 | ((* macro iff_figure(output, true_content, false_content) -*)) | |
322 | ((* if output.output_type in ['display_data'] -*)) |
|
333 | ((* if output.output_type in ['display_data'] -*)) | |
323 | ((( true_content ))) |
|
334 | ((( true_content ))) | |
324 | ((*- else -*)) |
|
335 | ((*- else -*)) | |
325 | ((( false_content ))) |
|
336 | ((( false_content ))) | |
326 | ((*- endif *)) |
|
337 | ((*- endif *)) | |
327 | ((*- endmacro *)) |
|
338 | ((*- endmacro *)) | |
328 |
|
339 | |||
329 | % Name: custom_verbatim |
|
340 | % Name: custom_verbatim | |
330 | % Purpose: This macro creates a verbatim style block that fits the existing |
|
341 | % Purpose: This macro creates a verbatim style block that fits the existing | |
331 | % sphinx style more readily than standard verbatim blocks. |
|
342 | % sphinx style more readily than standard verbatim blocks. | |
332 | ((* macro custom_verbatim(text) -*)) |
|
343 | ((* macro custom_verbatim(text) -*)) | |
333 |
|
344 | ((* if resources.sphinx.outputstyle == 'simple' *)) | ||
334 | \begin{lstlisting} |
|
345 | \begin{lstlisting} | |
335 | ((( text | wrap(wrap_size) ))) |
|
346 | ((( text | wrap(wrap_size) ))) | |
336 | \end{lstlisting} |
|
347 | \end{lstlisting} | |
337 |
|
348 | ((* elif resources.sphinx.outputstyle == 'notebook' *)) | ||
|
349 | \begin{alltt} | |||
|
350 | ((( text | wrap(wrap_size) ))) | |||
|
351 | \end{alltt} | |||
|
352 | ((* endif *)) | |||
338 | ((*- endmacro *)) |
|
353 | ((*- endmacro *)) | |
339 |
|
354 | |||
340 | % Name: insert_graphics |
|
355 | % Name: insert_graphics | |
341 | % Purpose: This macro will insert an image in the latex document given a path. |
|
356 | % Purpose: This macro will insert an image in the latex document given a path. | |
342 | ((* macro insert_graphics(path) -*)) |
|
357 | ((* macro insert_graphics(path) -*)) | |
343 | \begin{center} |
|
358 | \begin{center} | |
344 | \includegraphics[width=0.7\textwidth]{(((path)))} |
|
359 | \includegraphics[width=0.7\textwidth]{(((path)))} | |
345 | \par |
|
360 | \par | |
346 | \end{center} |
|
361 | \end{center} | |
347 | ((*- endmacro *)) |
|
362 | ((*- endmacro *)) | |
348 |
|
363 | |||
349 | % Name: escape_underscores |
|
364 | % Name: escape_underscores | |
350 | % Purpose: Underscores cause a problem in latex. It's important that we |
|
365 | % Purpose: Underscores cause a problem in latex. It's important that we | |
351 | % escape any underscores that appear. |
|
366 | % escape any underscores that appear. | |
352 | ((* macro escape_underscores(text) -*)) |
|
367 | ((* macro escape_underscores(text) -*)) | |
353 | ((*- set text = text|replace("_","\\_") -*)) |
|
368 | ((*- set text = text|replace("_","\\_") -*)) | |
354 | ((( text ))) |
|
369 | ((( text ))) | |
355 | ((*- endmacro *)) |
|
370 | ((*- endmacro *)) | |
356 |
|
371 |
General Comments 0
You need to be logged in to leave comments.
Login now