Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1426 from scolobb/preview-packages

sympy.printing.preview: Support additional LaTeX packages.
  • Loading branch information...
commit 861a066d0e95787ebdd74a7ad66eaf5cdbbaefa5 2 parents ea2bd6e + c3106d9
@ness01 ness01 authored
Showing with 15 additions and 22 deletions.
  1. +15 −22 sympy/printing/preview.py
View
37 sympy/printing/preview.py
@@ -6,7 +6,7 @@
from latex import latex
-def preview(expr, output='png', viewer=None, euler=True, **latex_settings):
+def preview(expr, output='png', viewer=None, euler=True, packages=(), **latex_settings):
r"""
View expression or LaTeX markup in PNG, DVI, PostScript or PDF form.
@@ -93,27 +93,20 @@ def preview(expr, output='png', viewer=None, euler=True, **latex_settings):
if viewer not in special and not pexpect.which(viewer):
raise SystemError("Unrecognized viewer: %s" % viewer)
- if not euler:
- format = r"""\documentclass[12pt]{article}
- \usepackage{amsmath}
- \usepackage{amsfonts}
- \begin{document}
- \pagestyle{empty}
- %s
- \vfill
- \end{document}
- """
- else:
- format = r"""\documentclass[12pt]{article}
- \usepackage{amsmath}
- \usepackage{amsfonts}
- \usepackage{eulervm}
- \begin{document}
- \pagestyle{empty}
- %s
- \vfill
- \end{document}
- """
+ actual_packages = packages + ("amsmath", "amsfonts")
+ if euler:
+ actual_packages += ("euler",)
+ package_includes = "\n".join(["\\usepackage{%s}" % p
+ for p in actual_packages])
+
+ format = r"""\documentclass[12pt]{article}
+ %s
+ \begin{document}
+ \pagestyle{empty}
+ %s
+ \vfill
+ \end{document}
+ """ % (package_includes, "%s")
if isinstance(expr, str):
latex_string = expr
Please sign in to comment.
Something went wrong with that request. Please try again.