diff --git a/IPython/extensions/sympyprinting.py b/IPython/extensions/sympyprinting.py index 01eca93..18a8533 100644 --- a/IPython/extensions/sympyprinting.py +++ b/IPython/extensions/sympyprinting.py @@ -54,6 +54,15 @@ def print_png(o): png = latex_to_png(s) return png + +def print_display_png(o): + """A function to display sympy expression using LaTex -> PNG.""" + s = latex(o, mode='plain') + s = s.strip('$') + png = latex_to_png('$$%s$$' % s, backend='dvipng') + return png + + def can_print_latex(o): """ Return True if type o can be printed with LaTeX. @@ -115,6 +124,9 @@ def load_ipython_extension(ip): png_formatter.for_type_by_name( 'sympy.core.basic', 'Basic', print_png ) + png_formatter.for_type_by_name( + 'sympy.matrices.matrices', 'Matrix', print_display_png + ) for cls in [dict, int, long, float] + printable_containers: png_formatter.for_type(cls, print_png)