Show More
@@ -8,7 +8,7 b'' | |||
|
8 | 8 | |
|
9 | 9 | ==========================================================================)) |
|
10 | 10 | |
|
11 |
((*- extends ' |
|
|
11 | ((*- extends 'display_priority.tplx' -*)) | |
|
12 | 12 | |
|
13 | 13 | ((* block header *)) |
|
14 | 14 | |
@@ -38,99 +38,16 b'' | |||
|
38 | 38 | \usepackage{ucs} |
|
39 | 39 | \usepackage{enumerate} |
|
40 | 40 | |
|
41 | % Define a few colors for use in code, links and cell shading | |
|
41 | % Pygments requirements | |
|
42 | \usepackage{fancyvrb} | |
|
42 | 43 | \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 | |
|
44 | ||
|
45 | % For formatting output while also word wrapping. | |
|
46 | \usepackage{listings} | |
|
47 | \lstset{breaklines=true} | |
|
48 | \lstset{basicstyle=\small\ttfamily} | |
|
49 | %Pygments definitions | |
|
50 | ((( resources.pygment_definitions ))) | |
|
134 | 51 | |
|
135 | 52 | % Prevent overflowing lines due to urls and other hard-to-break entities. |
|
136 | 53 | \sloppy |
@@ -149,6 +66,7 b'' | |||
|
149 | 66 | |
|
150 | 67 | ((* endblock header *)) |
|
151 | 68 | |
|
69 | ((* block body *)) | |
|
152 | 70 | ((* block bodyBegin *)) |
|
153 | 71 | % Body |
|
154 | 72 | |
@@ -157,7 +75,7 b'' | |||
|
157 | 75 | \maketitle |
|
158 | 76 | \tableofcontents |
|
159 | 77 | |
|
160 | ((* endblock bodyBegin *))((* block bodyEnd *)) | |
|
78 | ((* endblock bodyBegin *))((( super() )))((* block bodyEnd *)) | |
|
161 | 79 | |
|
162 | 80 | \renewcommand{\indexname}{Index} |
|
163 | 81 | \printindex |
@@ -165,6 +83,7 b'' | |||
|
165 | 83 | % End of document |
|
166 | 84 | \end{document} |
|
167 | 85 | ((* endblock bodyEnd *)) |
|
86 | ((* endblock body *)) | |
|
168 | 87 | |
|
169 | 88 | % Footer |
|
170 | 89 | ((* block footer *)) |
@@ -184,7 +103,7 b'' | |||
|
184 | 103 | ((* block h5 -*))subsubsection((* endblock h5 -*)) |
|
185 | 104 | ((*- elif cell.level == 6 -*)) |
|
186 | 105 | ((* block h6 -*))paragraph((* endblock h6 -*)) |
|
187 |
((*- endif -*)){((( |
|
|
106 | ((*- endif -*)){((( escapeUnderscores(cell.source | markdown2latex ) )))} | |
|
188 | 107 | ((*- endblock headingcell *)) |
|
189 | 108 | |
|
190 | 109 | ((* block unknowncell scoped*)) |
@@ -194,7 +113,7 b'' | |||
|
194 | 113 | ((* endblock unknowncell *)) |
|
195 | 114 | |
|
196 | 115 | ((*- block markdowncell scoped-*)) |
|
197 | ((( super() ))) | |
|
116 | ((( cell.source | markdown2latex ))) | |
|
198 | 117 | ((*- endblock markdowncell -*)) |
|
199 | 118 | |
|
200 | 119 | ((= Raw text cells allow the user to manually inject document code that will |
@@ -203,6 +122,96 b' not get touched by the templating system. =))' | |||
|
203 | 122 | ((( cell.source ))) |
|
204 | 123 | ((* endblock rawcell -*)) |
|
205 | 124 | |
|
125 | ((* block input *)) | |
|
126 | \vspace{10pt} | |
|
127 | \begin{minipage}{\textwidth} | |
|
128 | {\scriptsize Input}\\* | |
|
129 | \rule[10pt]{\linewidth}{0.5pt} | |
|
130 | \vspace{-25pt} | |
|
131 | ((( cell.input | get_lines(end=3) | highlight2latex ))) | |
|
132 | \end{minipage} | |
|
133 | ((( cell.input | get_lines(start=3) | highlight2latex ))) | |
|
134 | ((* endblock input *)) | |
|
135 | ||
|
136 | ((* block pyerr *)) | |
|
137 | \vspace{10pt} | |
|
138 | \begin{minipage}{\textwidth} | |
|
139 | {\scriptsize Output}\\* | |
|
140 | \rule[10pt]{\linewidth}{0.5pt} | |
|
141 | \vspace{-25pt} | |
|
142 | \begin{lstlisting} | |
|
143 | ((( super() | get_lines(end=3) ))) | |
|
144 | \end{lstlisting} | |
|
145 | \end{minipage} | |
|
146 | \begin{lstlisting} | |
|
147 | ((( super() | get_lines(start=3) ))) | |
|
148 | \end{lstlisting} | |
|
149 | ((* endblock pyerr *)) | |
|
150 | ||
|
151 | ((*- block display_data -*)) | |
|
152 | \vspace{10pt} | |
|
153 | \begin{minipage}{\textwidth} | |
|
154 | {\scriptsize Output}\\* | |
|
155 | \rule[10pt]{\linewidth}{0.5pt} | |
|
156 | \vspace{-20pt} | |
|
157 | ((( super() ))) | |
|
158 | \end{minipage} \\ | |
|
159 | ((*- endblock display_data -*)) | |
|
160 | ||
|
161 | ((* block stream *)) | |
|
162 | \vspace{10pt} | |
|
163 | \begin{minipage}{\textwidth} | |
|
164 | {\scriptsize Output}\\* | |
|
165 | \rule[10pt]{\linewidth}{0.5pt} | |
|
166 | \vspace{-25pt} | |
|
167 | \begin{lstlisting} | |
|
168 | ((( output.text | get_lines(end=3) ))) | |
|
169 | \end{lstlisting} | |
|
170 | \end{minipage} | |
|
171 | \begin{lstlisting} | |
|
172 | ((( output.text | get_lines(start=3) ))) | |
|
173 | \end{lstlisting} | |
|
174 | ((* endblock stream *)) | |
|
175 | ||
|
176 | ((* block pyout *)) | |
|
177 | \vspace{10pt} | |
|
178 | \begin{minipage}{\textwidth} | |
|
179 | {\scriptsize Output}\\* | |
|
180 | \rule[10pt]{\linewidth}{0.5pt} | |
|
181 | \vspace{-25pt} | |
|
182 | \begin{lstlisting} | |
|
183 | ((( output.text | get_lines(end=3) ))) | |
|
184 | \end{lstlisting} | |
|
185 | \end{minipage} | |
|
186 | \begin{lstlisting} | |
|
187 | ((( output.text | get_lines(start=3) ))) | |
|
188 | \end{lstlisting} | |
|
189 | ((* endblock pyout *)) | |
|
190 | ||
|
191 | ((* block traceback_line *)) | |
|
192 | ((( line |indent| rm_ansi )))((* endblock traceback_line *)) | |
|
193 | ((= .... =)) | |
|
194 | ||
|
195 | ((* block data_text *)) | |
|
196 | \begin{lstlisting} | |
|
197 | ((( output.text ))) | |
|
198 | \end{lstlisting} | |
|
199 | ((* endblock *)) | |
|
200 | ||
|
201 | ((*- block data_png -*)) | |
|
202 | \begin{center} | |
|
203 | \includegraphics[width=0.7\textwidth]{(((output.key_png)))} | |
|
204 | \par | |
|
205 | \end{center} | |
|
206 | ((*- endblock -*)) | |
|
207 | ||
|
208 | ((*- block data_svg -*)) | |
|
209 | \begin{center} | |
|
210 | \includegraphics[width=0.7\textwidth]{(((output.key_svg)))} | |
|
211 | \par | |
|
212 | \end{center} | |
|
213 | ((*- endblock -*)) | |
|
214 | ||
|
206 | 215 | ((* macro filterOutLatex(text) -*)) |
|
207 | 216 | ((*- set text = text|replace("\\","\\backslash") -*)) |
|
208 | 217 | ((*- set text = text|replace("_","\\_") -*)) |
@@ -212,57 +221,8 b' not get touched by the templating system. =))' | |||
|
212 | 221 | ((( text ))) |
|
213 | 222 | ((*- endmacro *)) |
|
214 | 223 | |
|
215 | % Useful to block TODO: Remove/move this block below | |
|
216 | ||
|
217 | \setbox0\vbox{ | |
|
218 | \begin{minipage}{0.95\linewidth} | |
|
219 | ||
|
220 | \end{minipage}} | |
|
221 | \begin{center}\setlength{\fboxsep}{5pt} | |
|
222 | \shadowbox{\box0}\end{center} | |
|
223 | ||
|
224 | ((======================================================================== | |
|
225 | EVERYTHING BELOW HERE STILL NEEDS TO BE FILLED IN! | |
|
226 | ========================================================================)) | |
|
227 | ((= | |
|
228 | ((*- block codecell scoped -*)) | |
|
229 | ((*- block input_group -*)) | |
|
230 | ((*- block in_prompt -*))((*- endblock in_prompt -*)) | |
|
231 | ((*- block input -*))((*- endblock input -*)) | |
|
232 | ((*- endblock input_group -*)) | |
|
233 | ((*- if cell.outputs -*)) | |
|
234 | ((*- block output_group -*)) | |
|
235 | ((*- block output_prompt -*))((*- endblock output_prompt -*)) | |
|
236 | ((*- block outputs -*)) | |
|
237 | ((*- for output in cell.outputs -*)) | |
|
238 | ((*- if output.output_type in ['pyout'] -*)) | |
|
239 | ((*- block pyout scoped -*))((*- endblock pyout -*)) | |
|
240 | ((*- elif output.output_type in ['stream'] -*)) | |
|
241 | ((*- block stream scoped -*)) | |
|
242 | ((*- if output.stream in ['stdout'] -*)) | |
|
243 | ((*- block stream_stdout scoped -*)) | |
|
244 | ((*- endblock stream_stdout -*)) | |
|
245 | ((*- elif output.stream in ['stderr'] -*)) | |
|
246 | ((*- block stream_stderr scoped -*)) | |
|
247 | ((*- endblock stream_stderr -*)) | |
|
248 | ((*- endif -*)) | |
|
249 | ((*- endblock stream -*)) | |
|
250 | ((*- elif output.output_type in ['display_data'] -*)) | |
|
251 | ((*- block display_data scoped -*)) | |
|
252 | ((*- block data_priority scoped -*)) | |
|
253 | ((*- endblock data_priority -*)) | |
|
254 | ((*- endblock display_data -*)) | |
|
255 | ((*- elif output.output_type in ['pyerr'] -*)) | |
|
256 | ((*- block pyerr scoped -*)) | |
|
257 | ((*- for line in output.traceback -*)) | |
|
258 | ((*- block traceback_line scoped -*))((*- endblock traceback_line -*)) | |
|
259 | ((*- endfor -*)) | |
|
260 | ((*- endblock pyerr -*)) | |
|
261 | ((*- endif -*)) | |
|
262 | ((*- endfor -*)) | |
|
263 | ((*- endblock outputs -*)) | |
|
264 | ((*- endblock output_group -*)) | |
|
265 | ((*- endif -*)) | |
|
266 | ((*- endblock codecell -*)) | |
|
267 | =)) | |
|
224 | ((* macro escapeUnderscores(text) -*)) | |
|
225 | ((*- set text = text|replace("_","\\_") -*)) | |
|
226 | ((( text ))) | |
|
227 | ((*- endmacro *)) | |
|
268 | 228 |
General Comments 0
You need to be logged in to leave comments.
Login now