# Ticket #11775: trac_11775_pretty_print_multiple_args.diff

File trac_11775_pretty_print_multiple_args.diff, 2.8 KB (added by ppurka, 10 years ago)

The patch for ticket #11775

• ## sage/misc/latex.py

# trac ticket #11775: HG changeset patch
# User P Purkayastha <ppurka@gmail.com>
# Date 1315137052 -28800
# Node ID a5526ce127658e2865704fd6c30f8cde603c0a45
# Parent  4198d41f9a77a2b7a7e01657143de17dede7c3e5
[mq]: pretty_print_multiple_args

diff --git a/sage/misc/latex.py b/sage/misc/latex.py
 a else: print(object) def pretty_print (object): def pretty_print (*args): r""" Try to pretty print an object in an intelligent way.  For graphics objects, this returns their default representation.  For other sage: from sage.misc.latex import pretty_print sage: pretty_print(ZZ)  # indirect doctest \newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Z}\newcommand{\Bold}[1]{\mathbf{#1}}\hbox{$\Bold{Z}$} sage: pretty_print("Integers = ", ZZ, ", $\\frac{d(x^3)}{dx} =$ ", derivative(x^3, x)) # test multiple inputs \newcommand{\Bold}[1]{\mathbf{#1}}\hbox{Integers = $\Bold{Z}$, $\frac{d(x^3)}{dx} =$ $3 \, x^{2}$} """ if object is None: return import __builtin__ __builtin__._=object from sage.plot.plot import Graphics from sage.plot.plot3d.base import Graphics3d if isinstance(object, (Graphics, Graphics3d)): print repr(object) return else: if EMBEDDED_MODE: view(object) # view s if it is not empty. Used twice. def _show_s(s): if not s == '': if EMBEDDED_MODE: view(s) else: print JSMath().eval(s, mode='inline') s = '' for object in args: if object is None: continue import __builtin__ __builtin__._=object from sage.plot.plot import Graphics from sage.plot.plot3d.base import Graphics3d if isinstance(object, (Graphics, Graphics3d)): _show_s(s) s = '' print repr(object) else: print JSMath().eval(object, mode='inline') return s += ('$'+object._latex_()+'$' if hasattr(object, '_latex_') else str(object)) _show_s(s) return def pretty_print_default(enable=True): r""" sage: pretty_print_default(True) sage: sys.displayhook ...\hbox{ < function pretty_print at ... > }...\hbox{} sage: pretty_print_default(False) sage: sys.displayhook == sys.__displayhook__ True