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