##// END OF EJS Templates
Merge pull request #3578 from jakobgager/latex_image_handle...
Min RK -
r11252:0e65ed03 merge
parent child Browse files
Show More
@@ -1,263 +1,266 b''
1 ((*- extends 'display_priority.tplx' -*))
1 ((*- extends 'display_priority.tplx' -*))
2
2
3 ((* block in_prompt *))((* endblock in_prompt *))
3 ((* block in_prompt *))((* endblock in_prompt *))
4
4
5 ((* block output_prompt *))((* endblock output_prompt *))
5 ((* block output_prompt *))((* endblock output_prompt *))
6
6
7 ((* block codecell *))\begin{codecell}((( super() )))
7 ((* block codecell *))\begin{codecell}((( super() )))
8 \end{codecell}
8 \end{codecell}
9 ((* endblock *))
9 ((* endblock *))
10
10
11 ((* block input *))
11 ((* block input *))
12 \begin{codeinput}
12 \begin{codeinput}
13 \begin{lstlisting}
13 \begin{lstlisting}
14 ((( cell.input )))
14 ((( cell.input )))
15 \end{lstlisting}
15 \end{lstlisting}
16 \end{codeinput}
16 \end{codeinput}
17 ((* endblock input *))
17 ((* endblock input *))
18
18
19
19
20 ((= Those Two are for error displaying
20 ((= Those Two are for error displaying
21 even if the first one seem to do nothing,
21 even if the first one seem to do nothing,
22 it introduces a new line
22 it introduces a new line
23
23
24 =))
24 =))
25 ((* block pyerr *))
25 ((* block pyerr *))
26 \begin{traceback}
26 \begin{traceback}
27 \begin{verbatim}((( super() )))
27 \begin{verbatim}((( super() )))
28 \end{verbatim}
28 \end{verbatim}
29 \end{traceback}
29 \end{traceback}
30 ((* endblock pyerr *))
30 ((* endblock pyerr *))
31
31
32 ((* block traceback_line *))
32 ((* block traceback_line *))
33 ((( line |indent| rm_ansi )))((* endblock traceback_line *))
33 ((( line |indent| rm_ansi )))((* endblock traceback_line *))
34 ((= .... =))
34 ((= .... =))
35
35
36
36
37 ((*- block output_group -*))
37 ((*- block output_group -*))
38 \begin{codeoutput}
38 \begin{codeoutput}
39 ((( super() )))
39 ((( super() )))
40 \end{codeoutput}((* endblock *))
40 \end{codeoutput}((* endblock *))
41
41
42 ((*- block data_png -*))
42 ((*- block data_png -*))
43 \begin{center}
43 \begin{center}
44 \includegraphics[width=0.7\textwidth, height=0.9\textheight, keepaspectratio]{(((output.key_png)))}
44 \includegraphics[max size={0.7\textwidth}{0.9\textheight}]{(((output.key_png)))}
45 \par
45 \par
46 \end{center}
46 \end{center}
47 ((*- endblock -*))
47 ((*- endblock -*))
48
48
49 ((*- block data_jpg -*))
49 ((*- block data_jpg -*))
50 \begin{center}
50 \begin{center}
51 \includegraphics[width=0.7\textwidth, height=0.9\textheight, keepaspectratio]{(((output.key_jpeg)))}
51 \includegraphics[max size={0.7\textwidth}{0.9\textheight}]{(((output.key_jpeg)))}
52 \par
52 \par
53 \end{center}
53 \end{center}
54 ((*- endblock -*))
54 ((*- endblock -*))
55
55
56 ((*- block data_svg -*))
56 ((*- block data_svg -*))
57 \begin{center}
57 \begin{center}
58 \includegraphics[width=0.7\textwidth]{(((output.key_svg)))}
58 \includegraphics[width=0.7\textwidth]{(((output.key_svg)))}
59 \par
59 \par
60 \end{center}
60 \end{center}
61 ((*- endblock -*))
61 ((*- endblock -*))
62
62
63 ((* block pyout *))
63 ((* block pyout *))
64 ((* block data_priority scoped *))((( super() )))((* endblock *))
64 ((* block data_priority scoped *))((( super() )))((* endblock *))
65 ((* endblock pyout *))
65 ((* endblock pyout *))
66
66
67 ((* block data_text *))
67 ((* block data_text *))
68 \begin{verbatim}
68 \begin{verbatim}
69 ((( output.text )))
69 ((( output.text )))
70 \end{verbatim}
70 \end{verbatim}
71 ((* endblock *))
71 ((* endblock *))
72
72
73 ((* block data_latex -*))
73 ((* block data_latex -*))
74 ((*- if output.latex.startswith('$'): -*)) \begin{equation*}
74 ((*- if output.latex.startswith('$'): -*)) \begin{equation*}
75 ((( output.latex | rm_dollars)))
75 ((( output.latex | rm_dollars)))
76 \end{equation*}
76 \end{equation*}
77 ((*- else -*)) ((( output.latex ))) ((*- endif *))
77 ((*- else -*)) ((( output.latex ))) ((*- endif *))
78 ((* endblock *))
78 ((* endblock *))
79
79
80 ((* block stream *))
80 ((* block stream *))
81 \begin{Verbatim}[commandchars=\\\{\}]
81 \begin{Verbatim}[commandchars=\\\{\}]
82 ((( output.text | ansi2latex)))
82 ((( output.text | ansi2latex)))
83 \end{Verbatim}
83 \end{Verbatim}
84 ((* endblock stream *))
84 ((* endblock stream *))
85
85
86 ((* block markdowncell scoped *))((( cell.source | markdown2latex )))
86 ((* block markdowncell scoped *))((( cell.source | markdown2latex )))
87 ((* endblock markdowncell *))
87 ((* endblock markdowncell *))
88
88
89 ((* block headingcell scoped -*))
89 ((* block headingcell scoped -*))
90 \
90 \
91 ((*- if cell.level == 1 -*))
91 ((*- if cell.level == 1 -*))
92 ((* block h1 -*))section((* endblock h1 -*))
92 ((* block h1 -*))section((* endblock h1 -*))
93 ((*- elif cell.level == 2 -*))
93 ((*- elif cell.level == 2 -*))
94 ((* block h2 -*))subsection((* endblock h2 -*))
94 ((* block h2 -*))subsection((* endblock h2 -*))
95 ((*- elif cell.level == 3 -*))
95 ((*- elif cell.level == 3 -*))
96 ((* block h3 -*))subsubsection((* endblock h3 -*))
96 ((* block h3 -*))subsubsection((* endblock h3 -*))
97 ((*- elif cell.level == 4 -*))
97 ((*- elif cell.level == 4 -*))
98 ((* block h4 -*))paragraph((* endblock h4 -*))
98 ((* block h4 -*))paragraph((* endblock h4 -*))
99 ((*- elif cell.level == 5 -*))
99 ((*- elif cell.level == 5 -*))
100 ((* block h5 -*))subparagraph((* endblock h5 -*))
100 ((* block h5 -*))subparagraph((* endblock h5 -*))
101 ((*- elif cell.level == 6 -*))
101 ((*- elif cell.level == 6 -*))
102 ((* block h6 -*))subparagraph((* endblock h6 -*))
102 ((* block h6 -*))subparagraph((* endblock h6 -*))
103 ((= 6th level not available in standard latex =))
103 ((= 6th level not available in standard latex =))
104
104
105 ((*- endif -*)){((( cell.source | markdown2latex )))}
105 ((*- endif -*)){((( cell.source | markdown2latex )))}
106 ((* endblock headingcell *))
106 ((* endblock headingcell *))
107
107
108 ((* block rawcell scoped *))
108 ((* block rawcell scoped *))
109 ((( cell.source | pycomment )))
109 ((( cell.source | pycomment )))
110 ((* endblock rawcell *))
110 ((* endblock rawcell *))
111
111
112 ((* block unknowncell scoped *))
112 ((* block unknowncell scoped *))
113 unknown type (((cell.type)))
113 unknown type (((cell.type)))
114 ((* endblock unknowncell *))
114 ((* endblock unknowncell *))
115
115
116
116
117
117
118 ((* block body *))
118 ((* block body *))
119
119
120 ((* block bodyBegin *))
120 ((* block bodyBegin *))
121 \begin{document}
121 \begin{document}
122 ((* endblock bodyBegin *))
122 ((* endblock bodyBegin *))
123
123
124 ((( super() )))
124 ((( super() )))
125
125
126 ((* block bodyEnd *))
126 ((* block bodyEnd *))
127 \end{document}
127 \end{document}
128 ((* endblock bodyEnd *))
128 ((* endblock bodyEnd *))
129 ((* endblock body *))
129 ((* endblock body *))
130
130
131 ((* block header *))
131 ((* block header *))
132 %% This file was auto-generated by IPython.
132 %% This file was auto-generated by IPython.
133 %% Conversion from the original notebook file:
133 %% Conversion from the original notebook file:
134 %%
134 %%
135 \documentclass[11pt,english]{article}
135 \documentclass[11pt,english]{article}
136
136
137 %% This is the automatic preamble used by IPython. Note that it does *not*
137 %% This is the automatic preamble used by IPython. Note that it does *not*
138 %% include a documentclass declaration, that is added at runtime to the overall
138 %% include a documentclass declaration, that is added at runtime to the overall
139 %% document.
139 %% document.
140
140
141 \usepackage{amsmath}
141 \usepackage{amsmath}
142 \usepackage{amssymb}
142 \usepackage{amssymb}
143 \usepackage{graphicx}
143 \usepackage{graphicx}
144 \usepackage{ucs}
144 \usepackage{ucs}
145 \usepackage[utf8x]{inputenc}
145 \usepackage[utf8x]{inputenc}
146
146
147 % Scale down larger images
148 \usepackage[export]{adjustbox}
149
147 %fancy verbatim
150 %fancy verbatim
148 \usepackage{fancyvrb}
151 \usepackage{fancyvrb}
149 % needed for markdown enumerations to work
152 % needed for markdown enumerations to work
150 \usepackage{enumerate}
153 \usepackage{enumerate}
151
154
152 % Slightly bigger margins than the latex defaults
155 % Slightly bigger margins than the latex defaults
153 \usepackage{geometry}
156 \usepackage{geometry}
154 \geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=2.5cm,rmargin=2.5cm}
157 \geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=2.5cm,rmargin=2.5cm}
155
158
156 % Define a few colors for use in code, links and cell shading
159 % Define a few colors for use in code, links and cell shading
157 \usepackage{color}
160 \usepackage{color}
158 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
161 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
159 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
162 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
160 \definecolor{darkgreen}{rgb}{.12,.54,.11}
163 \definecolor{darkgreen}{rgb}{.12,.54,.11}
161 \definecolor{myteal}{rgb}{.26, .44, .56}
164 \definecolor{myteal}{rgb}{.26, .44, .56}
162 \definecolor{gray}{gray}{0.45}
165 \definecolor{gray}{gray}{0.45}
163 \definecolor{lightgray}{gray}{.95}
166 \definecolor{lightgray}{gray}{.95}
164 \definecolor{mediumgray}{gray}{.8}
167 \definecolor{mediumgray}{gray}{.8}
165 \definecolor{inputbackground}{rgb}{.95, .95, .85}
168 \definecolor{inputbackground}{rgb}{.95, .95, .85}
166 \definecolor{outputbackground}{rgb}{.95, .95, .95}
169 \definecolor{outputbackground}{rgb}{.95, .95, .95}
167 \definecolor{traceback}{rgb}{1, .95, .95}
170 \definecolor{traceback}{rgb}{1, .95, .95}
168
171
169 % new ansi colors
172 % new ansi colors
170 \definecolor{brown}{rgb}{0.54,0.27,0.07}
173 \definecolor{brown}{rgb}{0.54,0.27,0.07}
171 \definecolor{purple}{rgb}{0.5,0.0,0.5}
174 \definecolor{purple}{rgb}{0.5,0.0,0.5}
172 \definecolor{darkgray}{gray}{0.25}
175 \definecolor{darkgray}{gray}{0.25}
173 \definecolor{lightred}{rgb}{1.0,0.39,0.28}
176 \definecolor{lightred}{rgb}{1.0,0.39,0.28}
174 \definecolor{lightgreen}{rgb}{0.48,0.99,0.0}
177 \definecolor{lightgreen}{rgb}{0.48,0.99,0.0}
175 \definecolor{lightblue}{rgb}{0.53,0.81,0.92}
178 \definecolor{lightblue}{rgb}{0.53,0.81,0.92}
176 \definecolor{lightpurple}{rgb}{0.87,0.63,0.87}
179 \definecolor{lightpurple}{rgb}{0.87,0.63,0.87}
177 \definecolor{lightcyan}{rgb}{0.5,1.0,0.83}
180 \definecolor{lightcyan}{rgb}{0.5,1.0,0.83}
178
181
179 % Framed environments for code cells (inputs, outputs, errors, ...). The
182 % Framed environments for code cells (inputs, outputs, errors, ...). The
180 % various uses of \unskip (or not) at the end were fine-tuned by hand, so don't
183 % various uses of \unskip (or not) at the end were fine-tuned by hand, so don't
181 % randomly change them unless you're sure of the effect it will have.
184 % randomly change them unless you're sure of the effect it will have.
182 \usepackage{framed}
185 \usepackage{framed}
183
186
184 % remove extraneous vertical space in boxes
187 % remove extraneous vertical space in boxes
185 \setlength\fboxsep{0pt}
188 \setlength\fboxsep{0pt}
186
189
187 % codecell is the whole input+output set of blocks that a Code cell can
190 % codecell is the whole input+output set of blocks that a Code cell can
188 % generate.
191 % generate.
189
192
190 % TODO: unfortunately, it seems that using a framed codecell environment breaks
193 % TODO: unfortunately, it seems that using a framed codecell environment breaks
191 % the ability of the frames inside of it to be broken across pages. This
194 % the ability of the frames inside of it to be broken across pages. This
192 % causes at least the problem of having lots of empty space at the bottom of
195 % causes at least the problem of having lots of empty space at the bottom of
193 % pages as new frames are moved to the next page, and if a single frame is too
196 % pages as new frames are moved to the next page, and if a single frame is too
194 % long to fit on a page, will completely stop latex from compiling the
197 % long to fit on a page, will completely stop latex from compiling the
195 % document. So unless we figure out a solution to this, we'll have to instead
198 % document. So unless we figure out a solution to this, we'll have to instead
196 % leave the codecell env. as empty. I'm keeping the original codecell
199 % leave the codecell env. as empty. I'm keeping the original codecell
197 % definition here (a thin vertical bar) for reference, in case we find a
200 % definition here (a thin vertical bar) for reference, in case we find a
198 % solution to the page break issue.
201 % solution to the page break issue.
199
202
200 %% \newenvironment{codecell}{%
203 %% \newenvironment{codecell}{%
201 %% \def\FrameCommand{\color{mediumgray} \vrule width 1pt \hspace{5pt}}%
204 %% \def\FrameCommand{\color{mediumgray} \vrule width 1pt \hspace{5pt}}%
202 %% \MakeFramed{\vspace{-0.5em}}}
205 %% \MakeFramed{\vspace{-0.5em}}}
203 %% {\unskip\endMakeFramed}
206 %% {\unskip\endMakeFramed}
204
207
205 % For now, make this a no-op...
208 % For now, make this a no-op...
206 \newenvironment{codecell}{}
209 \newenvironment{codecell}{}
207
210
208 \newenvironment{codeinput}{%
211 \newenvironment{codeinput}{%
209 \def\FrameCommand{\colorbox{inputbackground}}%
212 \def\FrameCommand{\colorbox{inputbackground}}%
210 \MakeFramed{\advance\hsize-\width \FrameRestore}}
213 \MakeFramed{\advance\hsize-\width \FrameRestore}}
211 {\unskip\endMakeFramed}
214 {\unskip\endMakeFramed}
212
215
213 \newenvironment{codeoutput}{%
216 \newenvironment{codeoutput}{%
214 \def\FrameCommand{\colorbox{outputbackground}}%
217 \def\FrameCommand{\colorbox{outputbackground}}%
215 \vspace{-1.4em}
218 \vspace{-1.4em}
216 \MakeFramed{\advance\hsize-\width \FrameRestore}}
219 \MakeFramed{\advance\hsize-\width \FrameRestore}}
217 {\unskip\medskip\endMakeFramed}
220 {\unskip\medskip\endMakeFramed}
218
221
219 \newenvironment{traceback}{%
222 \newenvironment{traceback}{%
220 \def\FrameCommand{\colorbox{traceback}}%
223 \def\FrameCommand{\colorbox{traceback}}%
221 \MakeFramed{\advance\hsize-\width \FrameRestore}}
224 \MakeFramed{\advance\hsize-\width \FrameRestore}}
222 {\endMakeFramed}
225 {\endMakeFramed}
223
226
224 % Use and configure listings package for nicely formatted code
227 % Use and configure listings package for nicely formatted code
225 \usepackage{listingsutf8}
228 \usepackage{listingsutf8}
226 \lstset{
229 \lstset{
227 language=python,
230 language=python,
228 inputencoding=utf8x,
231 inputencoding=utf8x,
229 extendedchars=\true,
232 extendedchars=\true,
230 aboveskip=\smallskipamount,
233 aboveskip=\smallskipamount,
231 belowskip=\smallskipamount,
234 belowskip=\smallskipamount,
232 xleftmargin=2mm,
235 xleftmargin=2mm,
233 breaklines=true,
236 breaklines=true,
234 basicstyle=\small \ttfamily,
237 basicstyle=\small \ttfamily,
235 showstringspaces=false,
238 showstringspaces=false,
236 keywordstyle=\color{blue}\bfseries,
239 keywordstyle=\color{blue}\bfseries,
237 commentstyle=\color{myteal},
240 commentstyle=\color{myteal},
238 stringstyle=\color{darkgreen},
241 stringstyle=\color{darkgreen},
239 identifierstyle=\color{darkorange},
242 identifierstyle=\color{darkorange},
240 columns=fullflexible, % tighter character kerning, like verb
243 columns=fullflexible, % tighter character kerning, like verb
241 }
244 }
242
245
243 % The hyperref package gives us a pdf with properly built
246 % The hyperref package gives us a pdf with properly built
244 % internal navigation ('pdf bookmarks' for the table of contents,
247 % internal navigation ('pdf bookmarks' for the table of contents,
245 % internal cross-reference links, web links for URLs, etc.)
248 % internal cross-reference links, web links for URLs, etc.)
246 \usepackage{hyperref}
249 \usepackage{hyperref}
247 \hypersetup{
250 \hypersetup{
248 breaklinks=true, % so long urls are correctly broken across lines
251 breaklinks=true, % so long urls are correctly broken across lines
249 colorlinks=true,
252 colorlinks=true,
250 urlcolor=blue,
253 urlcolor=blue,
251 linkcolor=darkorange,
254 linkcolor=darkorange,
252 citecolor=darkgreen,
255 citecolor=darkgreen,
253 }
256 }
254
257
255 % hardcode size of all verbatim environments to be a bit smaller
258 % hardcode size of all verbatim environments to be a bit smaller
256 \makeatletter
259 \makeatletter
257 \g@addto@macro\@verbatim\small\topsep=0.5em\partopsep=0pt
260 \g@addto@macro\@verbatim\small\topsep=0.5em\partopsep=0pt
258 \makeatother
261 \makeatother
259
262
260 % Prevent overflowing lines due to urls and other hard-to-break entities.
263 % Prevent overflowing lines due to urls and other hard-to-break entities.
261 \sloppy
264 \sloppy
262
265
263 ((* endblock *))
266 ((* endblock *))
General Comments 0
You need to be logged in to leave comments. Login now