##// END OF EJS Templates
Re-arrange imports, added some comments, general cleaning.
Jonathan Frederic -
Show More
@@ -1,217 +1,228 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 'display_priority.tplx' -*))
11 ((*- extends 'display_priority.tplx' -*))
12
12
13 ((*- set wrap_size = 87 -*))
14
15 % In order to make sure that the input/output header follows the code it
13 % In order to make sure that the input/output header follows the code it
16 % preceeds, we have to use a minipage environment. This causes problems
14 % preceeds, we have to use a minipage environment. This causes problems
17 % for large blocks of input and output. If there is a large input/output
15 % for large blocks of input and output. If there is a large input/output
18 % block, we don't want to minipage the whole thing since it will break
16 % block, we don't want to minipage the whole thing since it will break
19 % the line wrapping. The solution is to split the input/output line by
17 % the line wrapping. The solution is to split the input/output line by
20 % line before we minipage which allows us to minipage the first X lines
18 % line before we minipage which allows us to minipage the first X lines
21 % preceeding the input/output bar. That way, a select amount of lines
19 % preceeding the input/output bar. That way, a select amount of lines
22 % force the input/output bar to follow it around.
20 % force the input/output bar to follow it around.
23 ((*- set min_header_lines = 3 -*))
21 ((*- set min_header_lines = 3 -*))
24
22
23 % This is the number of characters that are permitted per line. It's
24 % important that this limit is set so characters do not run off the
25 % edges of latex pages (since latex does not always seem smart enough
26 % to prevent this.)
27 ((*- set wrap_size = 87 -*))
28
25 ((* block header *))
29 ((* block header *))
26
30
27 % Header, overrides base
31 % Header, overrides base
28
32
29 % Make sure that the sphinx doc style knows who it inherits from.
33 % Make sure that the sphinx doc style knows who it inherits from.
30 \def\sphinxdocclass{(((parentdocumentclass)))}
34 \def\sphinxdocclass{(((parentdocumentclass)))}
31
35
32 % Declare the document class
36 % Declare the document class
33 \documentclass[letterpaper,10pt,english]{((( resources.sphinx_texinputs )))/sphinx(((documentclass)))}
37 \documentclass[letterpaper,10pt,english]{((( resources.sphinx_texinputs )))/sphinx(((documentclass)))}
34
38
35 % Imports
39 % Imports
36 \usepackage[utf8]{inputenc}
40 \usepackage[utf8]{inputenc}
37 \DeclareUnicodeCharacter{00A0}{\\nobreakspace}
41 \DeclareUnicodeCharacter{00A0}{\\nobreakspace}
38 \usepackage[T1]{fontenc}
42 \usepackage[T1]{fontenc}
39 \usepackage{babel}
43 \usepackage{babel}
40 \usepackage{times}
44 \usepackage{times}
41 \usepackage{import}
45 \usepackage{import}
42 \usepackage[((( resources.sphinx_chapterstyle )))]{((( resources.sphinx_texinputs )))/fncychap}
46 \usepackage[((( resources.sphinx_chapterstyle )))]{((( resources.sphinx_texinputs )))/fncychap}
43 \usepackage{longtable}
47 \usepackage{longtable}
44 \usepackage{((( resources.sphinx_texinputs )))/sphinx}
48 \usepackage{((( resources.sphinx_texinputs )))/sphinx}
45 \usepackage{multirow}
49 \usepackage{multirow}
46
50
47 \usepackage{amsmath}
51 \usepackage{amsmath}
48 \usepackage{amssymb}
52 \usepackage{amssymb}
49 \usepackage{graphicx}
50 \graphicspath{ {figs/} }
51 \usepackage{ucs}
53 \usepackage{ucs}
52 \usepackage{enumerate}
54 \usepackage{enumerate}
53
55
54 % Pygments requirements
56 % Pygments requirements
55 \usepackage{fancyvrb}
57 \usepackage{fancyvrb}
56 \usepackage{color}
58 \usepackage{color}
57
59
60 % Used to load and display graphics
61 \usepackage{graphicx}
62 \graphicspath{ {figs/} }
63
58 % For formatting output while also word wrapping.
64 % For formatting output while also word wrapping.
59 \usepackage{listings}
65 \usepackage{listings}
60 \lstset{breaklines=true}
66 \lstset{breaklines=true}
61 \lstset{basicstyle=\small\ttfamily}
67 \lstset{basicstyle=\small\ttfamily}
68
62 %Pygments definitions
69 %Pygments definitions
63 ((( resources.pygment_definitions )))
70 ((( resources.pygment_definitions )))
64
71
65 % Prevent overflowing lines due to urls and other hard-to-break entities.
72 % Help prevent overflowing lines due to urls and other hard-to-break
73 % entities. This doesn't catch everything...
66 \sloppy
74 \sloppy
67
75
68 % Document level variables
76 % Document level variables
69 \title{((( nb.metadata.name | escape_tex )))}
77 \title{((( nb.metadata.name | escape_tex )))}
70 \date{((( nb.metadata._draft.date | escape_tex )))}
78 \date{((( nb.metadata._draft.date | escape_tex )))}
71 \release{((( nb.metadata._draft.version | escape_tex )))}
79 \release{((( nb.metadata._draft.version | escape_tex )))}
72 \author{((( nb.metadata._draft.author | escape_tex )))}
80 \author{((( nb.metadata._draft.author | escape_tex )))}
73 \newcommand{\sphinxlogo}{}
74 \renewcommand{\releasename}{((( nb.metadata._draft.release | escape_tex )))}
81 \renewcommand{\releasename}{((( nb.metadata._draft.release | escape_tex )))}
82
83 % TODO: Add option for the user to specify a logo for his/her export.
84 \newcommand{\sphinxlogo}{}
85
86 % Make the index page of the document.
75 \makeindex
87 \makeindex
76
88
77 ((* block sphinxheader *))((* endblock sphinxheader *))
89 ((* block sphinxheader *))((* endblock sphinxheader *))
78
79 ((* endblock header *))
90 ((* endblock header *))
80
91
81 ((* block body *))
92 ((* block body *))
82 ((* block bodyBegin *))
93 ((* block bodyBegin *))
83 % Body
94 % Body
84
95
85 % Start of the document
96 % Start of the document
86 \begin{document}
97 \begin{document}
87 \maketitle
98 \maketitle
88 \tableofcontents
99 \tableofcontents
89
100
90 ((* endblock bodyBegin *))((( super() )))((* block bodyEnd *))
101 ((* endblock bodyBegin *))((( super() )))((* block bodyEnd *))
91
102
92 \renewcommand{\indexname}{Index}
103 \renewcommand{\indexname}{Index}
93 \printindex
104 \printindex
94
105
95 % End of document
106 % End of document
96 \end{document}
107 \end{document}
97 ((* endblock bodyEnd *))
108 ((* endblock bodyEnd *))
98 ((* endblock body *))
109 ((* endblock body *))
99
110
100 % Footer
111 % Footer
101 ((* block footer *))
112 ((* block footer *))
102 ((* endblock footer *))
113 ((* endblock footer *))
103
114
104 ((* block headingcell -*))
115 ((* block headingcell -*))
105 \
116 \
106 ((*- if cell.level == 1 -*))
117 ((*- if cell.level == 1 -*))
107 ((* block h1 -*))part((* endblock h1 -*))
118 ((* block h1 -*))part((* endblock h1 -*))
108 ((*- elif cell.level == 2 -*))
119 ((*- elif cell.level == 2 -*))
109 ((* block h2 -*))chapter((* endblock h2 -*))
120 ((* block h2 -*))chapter((* endblock h2 -*))
110 ((*- elif cell.level == 3 -*))
121 ((*- elif cell.level == 3 -*))
111 ((* block h3 -*))section((* endblock h3 -*))
122 ((* block h3 -*))section((* endblock h3 -*))
112 ((*- elif cell.level == 4 -*))
123 ((*- elif cell.level == 4 -*))
113 ((* block h4 -*))subsection((* endblock h4 -*))
124 ((* block h4 -*))subsection((* endblock h4 -*))
114 ((*- elif cell.level == 5 -*))
125 ((*- elif cell.level == 5 -*))
115 ((* block h5 -*))subsubsection((* endblock h5 -*))
126 ((* block h5 -*))subsubsection((* endblock h5 -*))
116 ((*- elif cell.level == 6 -*))
127 ((*- elif cell.level == 6 -*))
117 ((* block h6 -*))paragraph((* endblock h6 -*))
128 ((* block h6 -*))paragraph((* endblock h6 -*))
118 ((*- endif -*)){((( escapeUnderscores(cell.source | markdown2latex ) )))}
129 ((*- endif -*)){((( escapeUnderscores(cell.source | markdown2latex ) )))}
119 ((*- endblock headingcell *))
130 ((*- endblock headingcell *))
120
131
121 ((* block unknowncell scoped*))
132 ((* block unknowncell scoped*))
122
133
123 % Unsupported cell type, no formatting
134 % Unsupported cell type, no formatting
124 ((( cell.source | wrap | escape_tex )))
135 ((( cell.source | wrap | escape_tex )))
125 ((* endblock unknowncell *))
136 ((* endblock unknowncell *))
126
137
127 ((*- block markdowncell scoped-*))
138 ((*- block markdowncell scoped-*))
128 ((( cell.source | markdown2latex )))
139 ((( cell.source | markdown2latex )))
129 ((*- endblock markdowncell -*))
140 ((*- endblock markdowncell -*))
130
141
131 ((= Raw text cells allow the user to manually inject document code that will
142 ((= Raw text cells allow the user to manually inject document code that will
132 not get touched by the templating system. =))
143 not get touched by the templating system. =))
133 ((*- block rawcell *))
144 ((*- block rawcell *))
134 ((( cell.source | wrap(wrap_size) )))
145 ((( cell.source | wrap(wrap_size) )))
135 ((* endblock rawcell -*))
146 ((* endblock rawcell -*))
136
147
137 ((* block input *))
148 ((* block input *))
138 \vspace{10pt}
149 \vspace{10pt}
139 \begin{minipage}{\textwidth}
150 \begin{minipage}{\textwidth}
140 {\scriptsize Input}\\*
151 {\scriptsize Input}\\*
141 \rule[10pt]{\linewidth}{0.5pt}
152 \rule[10pt]{\linewidth}{0.5pt}
142 \vspace{-25pt}
153 \vspace{-25pt}
143 ((( cell.input | wrap(wrap_size) | get_lines(end=min_header_lines) | highlight )))
154 ((( cell.input | wrap(wrap_size) | get_lines(end=min_header_lines) | highlight )))
144 \end{minipage}((( cell.input | wrap(wrap_size) | get_lines(start=min_header_lines) | highlight )))
155 \end{minipage}((( cell.input | wrap(wrap_size) | get_lines(start=min_header_lines) | highlight )))
145 ((* endblock input *))
156 ((* endblock input *))
146
157
147 ((* block pyerr *))
158 ((* block pyerr *))
148 \vspace{10pt}
159 \vspace{10pt}
149 \begin{minipage}{\textwidth}
160 \begin{minipage}{\textwidth}
150 {\scriptsize Output}\\*
161 {\scriptsize Output}\\*
151 \rule[10pt]{\linewidth}{0.5pt}
162 \rule[10pt]{\linewidth}{0.5pt}
152 \vspace{-25pt}
163 \vspace{-25pt}
153 \begin{lstlisting}
164 \begin{lstlisting}
154 ((( super() | wrap(wrap_size) | get_lines(end=min_header_lines) )))
165 ((( super() | wrap(wrap_size) | get_lines(end=min_header_lines) )))
155 \end{lstlisting}
166 \end{lstlisting}
156 \end{minipage} \begin{lstlisting}
167 \end{minipage} \begin{lstlisting}
157 ((( super() | wrap(wrap_size) | get_lines(start=min_header_lines) )))
168 ((( super() | wrap(wrap_size) | get_lines(start=min_header_lines) )))
158 \end{lstlisting}
169 \end{lstlisting}
159 ((* endblock pyerr *))
170 ((* endblock pyerr *))
160
171
161 ((*- block display_data -*))
172 ((*- block display_data -*))
162 \vspace{10pt}
173 \vspace{10pt}
163 \begin{minipage}{\textwidth}
174 \begin{minipage}{\textwidth}
164 {\scriptsize Output}\\*
175 {\scriptsize Output}\\*
165 \rule[10pt]{\linewidth}{0.5pt}
176 \rule[10pt]{\linewidth}{0.5pt}
166 \vspace{-20pt}
177 \vspace{-20pt}
167 ((( super() )))
178 ((( super() )))
168 \end{minipage} \\
179 \end{minipage} \\
169 ((*- endblock display_data -*))
180 ((*- endblock display_data -*))
170
181
171 ((* block stream *))
182 ((* block stream *))
172 \vspace{10pt}
183 \vspace{10pt}
173 \begin{minipage}{\textwidth}
184 \begin{minipage}{\textwidth}
174 {\scriptsize Output}\\*
185 {\scriptsize Output}\\*
175 \rule[10pt]{\linewidth}{0.5pt}
186 \rule[10pt]{\linewidth}{0.5pt}
176 \vspace{-25pt}
187 \vspace{-25pt}
177 \begin{lstlisting}
188 \begin{lstlisting}
178 ((( output.text | wrap(wrap_size) | get_lines(end=min_header_lines) )))
189 ((( output.text | wrap(wrap_size) | get_lines(end=min_header_lines) )))
179 \end{lstlisting}
190 \end{lstlisting}
180 \end{minipage} \begin{lstlisting}
191 \end{minipage} \begin{lstlisting}
181 ((( output.text | wrap(wrap_size) | get_lines(start=min_header_lines) )))
192 ((( output.text | wrap(wrap_size) | get_lines(start=min_header_lines) )))
182 \end{lstlisting}
193 \end{lstlisting}
183 ((* endblock stream *))
194 ((* endblock stream *))
184
195
185 ((* block pyout *))
196 ((* block pyout *))
186 ((* block data_priority scoped *))((( super() )))((* endblock *))
197 ((* block data_priority scoped *))((( super() )))((* endblock *))
187 ((* endblock pyout *))
198 ((* endblock pyout *))
188
199
189 ((* block traceback_line *))
200 ((* block traceback_line *))
190 ((( line | wrap(wrap_size) |indent| rm_ansi )))((* endblock traceback_line *))
201 ((( line | wrap(wrap_size) |indent| rm_ansi )))((* endblock traceback_line *))
191 ((= .... =))
202 ((= .... =))
192
203
193 ((* block data_text *))
204 ((* block data_text *))
194 \begin{lstlisting}
205 \begin{lstlisting}
195 ((( output.text | wrap(wrap_size) )))
206 ((( output.text | wrap(wrap_size) )))
196 \end{lstlisting}
207 \end{lstlisting}
197 ((* endblock *))
208 ((* endblock *))
198
209
199 ((*- block data_png -*))
210 ((*- block data_png -*))
200 \begin{center}
211 \begin{center}
201 \includegraphics[width=0.7\textwidth]{(((output.key_png)))}
212 \includegraphics[width=0.7\textwidth]{(((output.key_png)))}
202 \par
213 \par
203 \end{center}
214 \end{center}
204 ((*- endblock -*))
215 ((*- endblock -*))
205
216
206 ((*- block data_svg -*))
217 ((*- block data_svg -*))
207 \begin{center}
218 \begin{center}
208 \includegraphics[width=0.7\textwidth]{(((output.key_svg)))}
219 \includegraphics[width=0.7\textwidth]{(((output.key_svg)))}
209 \par
220 \par
210 \end{center}
221 \end{center}
211 ((*- endblock -*))
222 ((*- endblock -*))
212
223
213 ((* macro escapeUnderscores(text) -*))
224 ((* macro escapeUnderscores(text) -*))
214 ((*- set text = text|replace("_","\\_") -*))
225 ((*- set text = text|replace("_","\\_") -*))
215 ((( text )))
226 ((( text )))
216 ((*- endmacro *))
227 ((*- endmacro *))
217
228
General Comments 0
You need to be logged in to leave comments. Login now