##// END OF EJS Templates
Improve conversion to latex of output cells...
jakobgager -
Show More
@@ -42,6 +42,7 b' class ConverterLaTeX(Converter):'
42 42 6: r'\subparagraph'}
43 43 user_preamble = None
44 44 exclude_cells = []
45 display_data_priority = ['latex', 'pdf', 'svg', 'png', 'jpg', 'text']
45 46
46 47 def in_env(self, environment, lines):
47 48 """Return list of environment lines for input lines
@@ -96,7 +97,7 b' class ConverterLaTeX(Converter):'
96 97 final.extend([r'\begin{document}', '',
97 98 body,
98 99 r'\end{document}', ''])
99 # Retun value must be a string
100 # Return value must be a string
100 101 return '\n'.join(final)
101 102
102 103 def render_heading(self, cell):
@@ -133,7 +134,7 b' class ConverterLaTeX(Converter):'
133 134
134 135 def _img_lines(self, img_file):
135 136 return self.in_env('center',
136 [r'\includegraphics[width=6in]{%s}' % img_file, r'\par'])
137 [r'\includegraphics[width=0.7\textwidth]{%s}' % os.path.relpath(img_file, self.infile_dir), r'\par'])
137 138
138 139 def _svg_lines(self, img_file):
139 140 base_file = os.path.splitext(img_file)[0]
@@ -150,9 +151,10 b' class ConverterLaTeX(Converter):'
150 151
151 152 # output is a dictionary like object with type as a key
152 153 if 'latex' in output:
153 lines.extend(self.in_env('equation*', output.latex.lstrip('$$').rstrip('$$')))
154 lines.extend(self.in_env('equation', output.latex.lstrip('$$').rstrip('$$')))
154 155
155 if 'text' in output:
156 #use text only if no latex representation is available
157 elif 'text' in output:
156 158 lines.extend(self.in_env('verbatim', output.text))
157 159
158 160 return lines
@@ -174,20 +176,13 b' class ConverterLaTeX(Converter):'
174 176 self.in_env('verbatim', data)
175 177
176 178 def render_display_format_text(self, output):
177 lines = []
178
179 if 'text' in output:
180 lines.extend(self.in_env('verbatim', output.text.strip()))
181
182 return lines
179 return self.in_env('verbatim', output.text.strip())
183 180
184 181 def render_display_format_html(self, output):
185 182 return []
186 183
187 184 def render_display_format_latex(self, output):
188 if type(output.latex) == type([]):
189 return output.latex
190 return [output.latex]
185 return self.in_env('equation', output.latex.lstrip('$$').rstrip('$$'))
191 186
192 187 def render_display_format_json(self, output):
193 188 # latex ignores json
General Comments 0
You need to be logged in to leave comments. Login now