Permalink
Browse files

Merge pull request #1426 from scolobb/preview-packages

sympy.printing.preview: Support additional LaTeX packages.
  • Loading branch information...
ness01 committed Jul 26, 2012
2 parents ea2bd6e + c3106d9 commit 861a066d0e95787ebdd74a7ad66eaf5cdbbaefa5
Showing with 15 additions and 22 deletions.
  1. +15 −22 sympy/printing/preview.py
View
@@ -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

0 comments on commit 861a066

Please sign in to comment.