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