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