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