Unicode Art#

This module implements ascii art using unicode characters. It is a strict superset of ascii_art.

class sage.typeset.unicode_art.UnicodeArt(lines=[], breakpoints=[], baseline=None)#

Bases: CharacterArt

An Ascii art object is an object with some specific representation for printing.

INPUT:

  • lines – the list of lines of the representation of the ascii art object

  • breakpoints – the list of points where the representation can be split

  • baseline – the reference line (from the bottom)

EXAMPLES:

sage: i = var('i')
sage: unicode_art(sum(pi^i/factorial(i)*x^i, i, 0, oo))
 π⋅x

sage.typeset.unicode_art.unicode_art(*obj, **kwds)#

Return an unicode art representation

INPUT:

  • *obj – any number of positional arguments, of arbitrary type. The objects whose ascii art representation we want.

  • sep – optional 'sep=...' keyword argument (or 'separator'). Anything that can be converted to unicode art (default: empty unicode art). The separator in-between a list of objects. Only used if more than one object given.

  • baseline – (default: 0) the baseline for the object

  • sep_baseline – (default: 0) the baseline for the separator

OUTPUT:

UnicodeArt instance.

EXAMPLES:

sage: result = unicode_art(integral(exp(sqrt(x))/(x+pi), x))
...
sage: result

    ⎮   √x
    ⎮  ℯ
    ⎮ ───── dx
    ⎮ x + π

sage: ident = lambda n: identity_matrix(ZZ, n)
sage: unicode_art(ident(1), ident(2), ident(3), sep=' : ')
              ⎛1 0 0⎞
      ⎛1 0⎞   ⎜0 1 0⎟
(1) : ⎝0 1⎠ : ⎝0 0 1⎠

If specified, the sep_baseline overrides the baseline of an unicode art separator:

sage: sep_line = unicode_art('\n'.join(' ⎟ ' for _ in range(5)), baseline=5)
sage: unicode_art(*AlternatingSignMatrices(3),
....:             separator=sep_line, sep_baseline=1)
        ⎟         ⎟         ⎟            ⎟         ⎟         ⎟
⎛1 0 0⎞ ⎟ ⎛0 1 0⎞ ⎟ ⎛1 0 0⎞ ⎟ ⎛ 0  1  0⎞ ⎟ ⎛0 0 1⎞ ⎟ ⎛0 1 0⎞ ⎟ ⎛0 0 1⎞
⎜0 1 0⎟ ⎟ ⎜1 0 0⎟ ⎟ ⎜0 0 1⎟ ⎟ ⎜ 1 -1  1⎟ ⎟ ⎜1 0 0⎟ ⎟ ⎜0 0 1⎟ ⎟ ⎜0 1 0⎟
⎝0 0 1⎠ ⎟ ⎝0 0 1⎠ ⎟ ⎝0 1 0⎠ ⎟ ⎝ 0  1  0⎠ ⎟ ⎝0 1 0⎠ ⎟ ⎝1 0 0⎠ ⎟ ⎝1 0 0⎠
        ⎟         ⎟         ⎟            ⎟         ⎟         ⎟
sage.typeset.unicode_art.unicode_subscript(x)#

Return the integer x as a superscript.

EXAMPLES:

sage: from sage.typeset.unicode_art import unicode_subscript
sage: unicode_subscript(15123902)
'₁₅₁₂₃₉₀₂'
sage: unicode_subscript(-712)
'₋₇₁₂'
sage.typeset.unicode_art.unicode_superscript(x)#

Return the rational number x as a superscript.

EXAMPLES:

sage: from sage.typeset.unicode_art import unicode_superscript
sage: unicode_superscript(15123902)
'¹⁵¹²³⁹⁰²'
sage: unicode_superscript(-712/5)
'⁻⁷¹²ᐟ⁵'