Show More
@@ -1,163 +1,268 b'' | |||||
1 | ((============================================================================ |
|
1 | ((============================================================================ | |
2 | NBConvert Sphinx-Latex Template |
|
2 | NBConvert Sphinx-Latex Template | |
3 |
|
3 | |||
4 | Purpose: Allow export of PDF friendly Latex inspired by Sphinx. Most of the |
|
4 | Purpose: Allow export of PDF friendly Latex inspired by Sphinx. Most of the | |
5 | template is derived directly from Sphinx source. |
|
5 | template is derived directly from Sphinx source. | |
6 |
|
6 | |||
7 | Inheritance: null>display_priority>latex_base |
|
7 | Inheritance: null>display_priority>latex_base | |
8 |
|
8 | |||
9 | ==========================================================================)) |
|
9 | ==========================================================================)) | |
10 |
|
10 | |||
11 | ((*- extends 'latex_base.tplx' -*)) |
|
11 | ((*- extends 'latex_base.tplx' -*)) | |
12 |
|
12 | |||
13 | ((* block header *)) |
|
13 | ((* block header *)) | |
14 |
|
14 | |||
15 | % Header, overrides base |
|
15 | % Header, overrides base | |
16 |
|
16 | |||
17 | % Make sure that the sphinx doc style knows who it inherits from. |
|
17 | % Make sure that the sphinx doc style knows who it inherits from. | |
18 | \def\sphinxdocclass{(((parentdocumentclass)))} |
|
18 | \def\sphinxdocclass{(((parentdocumentclass)))} | |
19 |
|
19 | |||
20 | % Declare the document class |
|
20 | % Declare the document class | |
21 | \documentclass[letterpaper,10pt,english]{((( resources.sphinx_texinputs )))/sphinx(((documentclass)))} |
|
21 | \documentclass[letterpaper,10pt,english]{((( resources.sphinx_texinputs )))/sphinx(((documentclass)))} | |
22 |
|
22 | |||
23 | % Imports |
|
23 | % Imports | |
24 | \usepackage[utf8]{inputenc} |
|
24 | \usepackage[utf8]{inputenc} | |
25 | \DeclareUnicodeCharacter{00A0}{\\nobreakspace} |
|
25 | \DeclareUnicodeCharacter{00A0}{\\nobreakspace} | |
26 | \usepackage[T1]{fontenc} |
|
26 | \usepackage[T1]{fontenc} | |
27 | \usepackage{babel} |
|
27 | \usepackage{babel} | |
28 | \usepackage{times} |
|
28 | \usepackage{times} | |
29 | \usepackage{import} |
|
29 | \usepackage{import} | |
30 | \usepackage[((( resources.sphinx_chapterstyle )))]{((( resources.sphinx_texinputs )))/fncychap} |
|
30 | \usepackage[((( resources.sphinx_chapterstyle )))]{((( resources.sphinx_texinputs )))/fncychap} | |
31 | \usepackage{longtable} |
|
31 | \usepackage{longtable} | |
32 | \usepackage{((( resources.sphinx_texinputs )))/sphinx} |
|
32 | \usepackage{((( resources.sphinx_texinputs )))/sphinx} | |
33 | \usepackage{multirow} |
|
33 | \usepackage{multirow} | |
34 |
|
34 | |||
|
35 | \usepackage{amsmath} | |||
|
36 | \usepackage{amssymb} | |||
|
37 | \usepackage{graphicx} | |||
|
38 | \usepackage{ucs} | |||
|
39 | \usepackage{enumerate} | |||
|
40 | ||||
|
41 | % Define a few colors for use in code, links and cell shading | |||
|
42 | \usepackage{color} | |||
|
43 | \definecolor{orange}{cmyk}{0,0.4,0.8,0.2} | |||
|
44 | \definecolor{darkorange}{rgb}{.71,0.21,0.01} | |||
|
45 | \definecolor{darkgreen}{rgb}{.12,.54,.11} | |||
|
46 | \definecolor{myteal}{rgb}{.26, .44, .56} | |||
|
47 | \definecolor{gray}{gray}{0.45} | |||
|
48 | \definecolor{lightgray}{gray}{.95} | |||
|
49 | \definecolor{mediumgray}{gray}{.8} | |||
|
50 | \definecolor{inputbackground}{rgb}{.95, .95, .85} | |||
|
51 | \definecolor{outputbackground}{rgb}{.95, .95, .95} | |||
|
52 | \definecolor{traceback}{rgb}{1, .95, .95} | |||
|
53 | ||||
|
54 | % Framed environments for code cells (inputs, outputs, errors, ...). The | |||
|
55 | % various uses of \unskip (or not) at the end were fine-tuned by hand, so don't | |||
|
56 | % randomly change them unless you're sure of the effect it will have. | |||
|
57 | \usepackage{framed} | |||
|
58 | ||||
|
59 | % remove extraneous vertical space in boxes | |||
|
60 | \setlength\fboxsep{0pt} | |||
|
61 | ||||
|
62 | % codecell is the whole input+output set of blocks that a Code cell can | |||
|
63 | % generate. | |||
|
64 | ||||
|
65 | % TODO: unfortunately, it seems that using a framed codecell environment breaks | |||
|
66 | % the ability of the frames inside of it to be broken across pages. This | |||
|
67 | % causes at least the problem of having lots of empty space at the bottom of | |||
|
68 | % pages as new frames are moved to the next page, and if a single frame is too | |||
|
69 | % long to fit on a page, will completely stop latex from compiling the | |||
|
70 | % document. So unless we figure out a solution to this, we'll have to instead | |||
|
71 | % leave the codecell env. as empty. I'm keeping the original codecell | |||
|
72 | % definition here (a thin vertical bar) for reference, in case we find a | |||
|
73 | % solution to the page break issue. | |||
|
74 | ||||
|
75 | %% \newenvironment{codecell}{% | |||
|
76 | %% \def\FrameCommand{\color{mediumgray} \vrule width 1pt \hspace{5pt}}% | |||
|
77 | %% \MakeFramed{\vspace{-0.5em}}} | |||
|
78 | %% {\unskip\endMakeFramed} | |||
|
79 | ||||
|
80 | % For now, make this a no-op... | |||
|
81 | \newenvironment{codecell}{} | |||
|
82 | ||||
|
83 | \newenvironment{codeinput}{% | |||
|
84 | \def\FrameCommand{\colorbox{inputbackground}}% | |||
|
85 | \MakeFramed{\advance\hsize-\width \FrameRestore}} | |||
|
86 | {\unskip\endMakeFramed} | |||
|
87 | ||||
|
88 | \newenvironment{codeoutput}{% | |||
|
89 | \def\FrameCommand{\colorbox{outputbackground}}% | |||
|
90 | \vspace{-1.4em} | |||
|
91 | \MakeFramed{\advance\hsize-\width \FrameRestore}} | |||
|
92 | {\unskip\medskip\endMakeFramed} | |||
|
93 | ||||
|
94 | \newenvironment{traceback}{% | |||
|
95 | \def\FrameCommand{\colorbox{traceback}}% | |||
|
96 | \MakeFramed{\advance\hsize-\width \FrameRestore}} | |||
|
97 | {\endMakeFramed} | |||
|
98 | ||||
|
99 | % Use and configure listings package for nicely formatted code | |||
|
100 | \usepackage{listingsutf8} | |||
|
101 | \lstset{ | |||
|
102 | language=python, | |||
|
103 | inputencoding=utf8x, | |||
|
104 | extendedchars=\true, | |||
|
105 | aboveskip=\smallskipamount, | |||
|
106 | belowskip=\smallskipamount, | |||
|
107 | xleftmargin=2mm, | |||
|
108 | breaklines=true, | |||
|
109 | basicstyle=\small \ttfamily, | |||
|
110 | showstringspaces=false, | |||
|
111 | keywordstyle=\color{blue}\bfseries, | |||
|
112 | commentstyle=\color{myteal}, | |||
|
113 | stringstyle=\color{darkgreen}, | |||
|
114 | identifierstyle=\color{darkorange}, | |||
|
115 | columns=fullflexible, % tighter character kerning, like verb | |||
|
116 | } | |||
|
117 | ||||
|
118 | % The hyperref package gives us a pdf with properly built | |||
|
119 | % internal navigation ('pdf bookmarks' for the table of contents, | |||
|
120 | % internal cross-reference links, web links for URLs, etc.) | |||
|
121 | \usepackage{hyperref} | |||
|
122 | \hypersetup{ | |||
|
123 | breaklinks=true, % so long urls are correctly broken across lines | |||
|
124 | colorlinks=true, | |||
|
125 | urlcolor=blue, | |||
|
126 | linkcolor=darkorange, | |||
|
127 | citecolor=darkgreen, | |||
|
128 | } | |||
|
129 | ||||
|
130 | % hardcode size of all verbatim environments to be a bit smaller | |||
|
131 | \makeatletter | |||
|
132 | \g@addto@macro\@verbatim\small\topsep=0.5em\partopsep=0pt | |||
|
133 | \makeatother | |||
|
134 | ||||
|
135 | % Prevent overflowing lines due to urls and other hard-to-break entities. | |||
|
136 | \sloppy | |||
|
137 | ||||
35 | % Document level variables |
|
138 | % Document level variables | |
36 | \title{((( nb.metadata.name )))} |
|
139 | \title{((( filterOutLatex(nb.metadata.name) )))} | |
37 | \date{((( nb.metadata.date )))} |
|
140 | \date{((( filterOutLatex(nb.metadata.date) )))} | |
38 | \release{((( nb.metadata.version )))} |
|
141 | \release{((( filterOutLatex(nb.metadata.version) )))} | |
39 | \author{((( nb.metadata.author )))} |
|
142 | \author{((( filterOutLatex(nb.metadata.author) )))} | |
40 | \newcommand{\sphinxlogo}{} |
|
143 | \newcommand{\sphinxlogo}{} | |
41 | \renewcommand{\releasename}{((( nb.metadata.release )))} |
|
144 | \renewcommand{\releasename}{((( filterOutLatex(nb.metadata.release) )))} | |
42 | \makeindex |
|
145 | \makeindex | |
43 |
|
146 | |||
44 |
|
147 | |||
45 | ((* block sphinxheader *))((* endblock sphinxheader *)) |
|
148 | ((* block sphinxheader *))((* endblock sphinxheader *)) | |
46 |
|
149 | |||
47 | ((* endblock header *)) |
|
150 | ((* endblock header *)) | |
48 |
|
151 | |||
49 | ((* block bodyBegin *)) |
|
152 | ((* block bodyBegin *)) | |
50 | % Body |
|
153 | % Body | |
51 |
|
154 | |||
52 | % Start of the document |
|
155 | % Start of the document | |
53 | \begin{document} |
|
156 | \begin{document} | |
54 | \maketitle |
|
157 | \maketitle | |
55 | \tableofcontents |
|
158 | \tableofcontents | |
56 |
|
159 | |||
57 | ((* endblock bodyBegin *))((* block bodyEnd *)) |
|
160 | ((* endblock bodyBegin *))((* block bodyEnd *)) | |
58 |
|
161 | |||
59 | \renewcommand{\indexname}{Index} |
|
162 | \renewcommand{\indexname}{Index} | |
60 | \printindex |
|
163 | \printindex | |
61 |
|
164 | |||
62 | % End of document |
|
165 | % End of document | |
63 | \end{document} |
|
166 | \end{document} | |
64 | ((* endblock bodyEnd *)) |
|
167 | ((* endblock bodyEnd *)) | |
65 |
|
168 | |||
66 | % Footer |
|
169 | % Footer | |
67 | ((* block footer *)) |
|
170 | ((* block footer *)) | |
68 | ((* endblock footer *)) |
|
171 | ((* endblock footer *)) | |
69 |
|
172 | |||
70 | ((* block headingcell -*)) |
|
173 | ((* block headingcell -*)) | |
71 | \ |
|
174 | \ | |
72 | ((*- if cell.level == 1 -*)) |
|
175 | ((*- if cell.level == 1 -*)) | |
73 | ((* block h1 -*))part((* endblock h1 -*)) |
|
176 | ((* block h1 -*))part((* endblock h1 -*)) | |
74 | ((*- elif cell.level == 2 -*)) |
|
177 | ((*- elif cell.level == 2 -*)) | |
75 | ((* block h2 -*))chapter((* endblock h2 -*)) |
|
178 | ((* block h2 -*))chapter((* endblock h2 -*)) | |
76 | ((*- elif cell.level == 3 -*)) |
|
179 | ((*- elif cell.level == 3 -*)) | |
77 | ((* block h3 -*))section((* endblock h3 -*)) |
|
180 | ((* block h3 -*))section((* endblock h3 -*)) | |
78 | ((*- elif cell.level == 4 -*)) |
|
181 | ((*- elif cell.level == 4 -*)) | |
79 | ((* block h4 -*))subsection((* endblock h4 -*)) |
|
182 | ((* block h4 -*))subsection((* endblock h4 -*)) | |
80 | ((*- elif cell.level == 5 -*)) |
|
183 | ((*- elif cell.level == 5 -*)) | |
81 | ((* block h5 -*))subsubsection((* endblock h5 -*)) |
|
184 | ((* block h5 -*))subsubsection((* endblock h5 -*)) | |
82 | ((*- elif cell.level == 6 -*)) |
|
185 | ((*- elif cell.level == 6 -*)) | |
83 | ((* block h6 -*))paragraph((* endblock h6 -*)) |
|
186 | ((* block h6 -*))paragraph((* endblock h6 -*)) | |
84 |
((*- endif -*)){((( cell.source | markdown2latex |
|
187 | ((*- endif -*)){((( filterOutLatex(cell.source) )))} ((= | markdown2latex =)) | |
85 | ((*- endblock headingcell *)) |
|
188 | ((*- endblock headingcell *)) | |
86 |
|
189 | |||
87 | ((* block unknowncell scoped*)) |
|
190 | ((* block unknowncell scoped*)) | |
88 |
|
191 | |||
89 | % Unsupported cell type, no formatting |
|
192 | % Unsupported cell type, no formatting | |
90 | ((( filterOutLatex(cell.source) ))) |
|
193 | ((( filterOutLatex(cell.source) ))) | |
91 | ((* endblock unknowncell *)) |
|
194 | ((* endblock unknowncell *)) | |
92 |
|
195 | |||
93 | ((*- block markdowncell scoped-*)) |
|
196 | ((*- block markdowncell scoped-*)) | |
94 | ((( super() ))) |
|
197 | ((( super() ))) | |
95 | ((*- endblock markdowncell -*)) |
|
198 | ((*- endblock markdowncell -*)) | |
96 |
|
199 | |||
97 | ((= Raw text cells allow the user to manually inject document code that will |
|
200 | ((= Raw text cells allow the user to manually inject document code that will | |
98 | not get touched by the templating system. =)) |
|
201 | not get touched by the templating system. =)) | |
99 | ((*- block rawcell *)) |
|
202 | ((*- block rawcell *)) | |
100 | ((( cell.source ))) |
|
203 | ((( cell.source ))) | |
101 | ((* endblock rawcell -*)) |
|
204 | ((* endblock rawcell -*)) | |
102 |
|
205 | |||
103 | ((* macro filterOutLatex(text) -*)) |
|
206 | ((* macro filterOutLatex(text) -*)) | |
104 | ((*- set text = text|replace("\\","\\backslash") -*)) |
|
207 | ((*- set text = text|replace("\\","\\backslash") -*)) | |
|
208 | ((*- set text = text|replace("_","\\_") -*)) | |||
105 | ((*- set text = text|replace("{","\\{") -*)) |
|
209 | ((*- set text = text|replace("{","\\{") -*)) | |
106 | ((*- set text = text|replace("}","\\}") -*)) |
|
210 | ((*- set text = text|replace("}","\\}") -*)) | |
107 | ((*- set text = text|replace("|","\\vert") -*)) |
|
211 | ((*- set text = text|replace("|","\\vert") -*)) | |
108 | ((( text ))) |
|
212 | ((( text ))) | |
109 | ((*- endmacro *)) |
|
213 | ((*- endmacro *)) | |
110 |
|
214 | |||
111 | % Useful to block TODO: Remove/move this block below |
|
215 | % Useful to block TODO: Remove/move this block below | |
112 |
|
216 | |||
113 | \setbox0\vbox{ |
|
217 | \setbox0\vbox{ | |
114 | \begin{minipage}{0.95\linewidth} |
|
218 | \begin{minipage}{0.95\linewidth} | |
115 |
|
219 | |||
116 | \end{minipage}} |
|
220 | \end{minipage}} | |
117 | \begin{center}\setlength{\fboxsep}{5pt} |
|
221 | \begin{center}\setlength{\fboxsep}{5pt} | |
118 | \shadowbox{\box0}\end{center} |
|
222 | \shadowbox{\box0}\end{center} | |
119 |
|
223 | |||
120 |
|
||||
121 | ((======================================================================== |
|
224 | ((======================================================================== | |
122 | EVERYTHING BELOW HERE STILL NEEDS TO BE FILLED IN! |
|
225 | EVERYTHING BELOW HERE STILL NEEDS TO BE FILLED IN! | |
123 | ========================================================================)) |
|
226 | ========================================================================)) | |
124 |
|
227 | ((= | ||
125 | ((*- block codecell scoped -*)) |
|
228 | ((*- block codecell scoped -*)) | |
126 | ((*- block input_group -*)) |
|
229 | ((*- block input_group -*)) | |
127 | ((*- block in_prompt -*))((*- endblock in_prompt -*)) |
|
230 | ((*- block in_prompt -*))((*- endblock in_prompt -*)) | |
128 | ((*- block input -*))((*- endblock input -*)) |
|
231 | ((*- block input -*))((*- endblock input -*)) | |
129 | ((*- endblock input_group -*)) |
|
232 | ((*- endblock input_group -*)) | |
130 | ((*- if cell.outputs -*)) |
|
233 | ((*- if cell.outputs -*)) | |
131 | ((*- block output_group -*)) |
|
234 | ((*- block output_group -*)) | |
132 | ((*- block output_prompt -*))((*- endblock output_prompt -*)) |
|
235 | ((*- block output_prompt -*))((*- endblock output_prompt -*)) | |
133 | ((*- block outputs -*)) |
|
236 | ((*- block outputs -*)) | |
134 | ((*- for output in cell.outputs -*)) |
|
237 | ((*- for output in cell.outputs -*)) | |
135 | ((*- if output.output_type in ['pyout'] -*)) |
|
238 | ((*- if output.output_type in ['pyout'] -*)) | |
136 | ((*- block pyout scoped -*))((*- endblock pyout -*)) |
|
239 | ((*- block pyout scoped -*))((*- endblock pyout -*)) | |
137 | ((*- elif output.output_type in ['stream'] -*)) |
|
240 | ((*- elif output.output_type in ['stream'] -*)) | |
138 | ((*- block stream scoped -*)) |
|
241 | ((*- block stream scoped -*)) | |
139 | ((*- if output.stream in ['stdout'] -*)) |
|
242 | ((*- if output.stream in ['stdout'] -*)) | |
140 | ((*- block stream_stdout scoped -*)) |
|
243 | ((*- block stream_stdout scoped -*)) | |
141 | ((*- endblock stream_stdout -*)) |
|
244 | ((*- endblock stream_stdout -*)) | |
142 | ((*- elif output.stream in ['stderr'] -*)) |
|
245 | ((*- elif output.stream in ['stderr'] -*)) | |
143 | ((*- block stream_stderr scoped -*)) |
|
246 | ((*- block stream_stderr scoped -*)) | |
144 | ((*- endblock stream_stderr -*)) |
|
247 | ((*- endblock stream_stderr -*)) | |
145 | ((*- endif -*)) |
|
248 | ((*- endif -*)) | |
146 | ((*- endblock stream -*)) |
|
249 | ((*- endblock stream -*)) | |
147 | ((*- elif output.output_type in ['display_data'] -*)) |
|
250 | ((*- elif output.output_type in ['display_data'] -*)) | |
148 | ((*- block display_data scoped -*)) |
|
251 | ((*- block display_data scoped -*)) | |
149 | ((*- block data_priority scoped -*)) |
|
252 | ((*- block data_priority scoped -*)) | |
150 | ((*- endblock data_priority -*)) |
|
253 | ((*- endblock data_priority -*)) | |
151 | ((*- endblock display_data -*)) |
|
254 | ((*- endblock display_data -*)) | |
152 | ((*- elif output.output_type in ['pyerr'] -*)) |
|
255 | ((*- elif output.output_type in ['pyerr'] -*)) | |
153 | ((*- block pyerr scoped -*)) |
|
256 | ((*- block pyerr scoped -*)) | |
154 | ((*- for line in output.traceback -*)) |
|
257 | ((*- for line in output.traceback -*)) | |
155 | ((*- block traceback_line scoped -*))((*- endblock traceback_line -*)) |
|
258 | ((*- block traceback_line scoped -*))((*- endblock traceback_line -*)) | |
156 | ((*- endfor -*)) |
|
259 | ((*- endfor -*)) | |
157 | ((*- endblock pyerr -*)) |
|
260 | ((*- endblock pyerr -*)) | |
158 | ((*- endif -*)) |
|
261 | ((*- endif -*)) | |
159 | ((*- endfor -*)) |
|
262 | ((*- endfor -*)) | |
160 | ((*- endblock outputs -*)) |
|
263 | ((*- endblock outputs -*)) | |
161 | ((*- endblock output_group -*)) |
|
264 | ((*- endblock output_group -*)) | |
162 | ((*- endif -*)) |
|
265 | ((*- endif -*)) | |
163 | ((*- endblock codecell -*)) |
|
266 | ((*- endblock codecell -*)) | |
|
267 | =)) | |||
|
268 |
General Comments 0
You need to be logged in to leave comments.
Login now