Ticket #11428: trac11428_customize_latex_for_functions.patch

File trac11428_customize_latex_for_functions.patch, 1.1 KB (added by SimonKing, 10 years ago)

Preliminary patch: Change latex/repr of a function. But the custom names are not propagated.

  • sage/symbolic/function.pyx

    # HG changeset patch
    # User Simon King <simon.king@uni-jena.de>
    # Date 1307255340 -7200
    # Node ID df0bf4706f8c5a2e1792a22dbed212f3a6139caf
    # Parent  7ba4e0a048eba82061934690073348a631a91706
    #11428: Make string and latex representation of sage functions customizable
    
    diff --git a/sage/symbolic/function.pyx b/sage/symbolic/function.pyx
    a b  
    238238        else:
    239239            return self._name
    240240
     241    def set_name(self, name):
     242        """
     243        Provide a name used for printing.
     244
     245        INPUT:
     246
     247        ``name`` -- a string
     248
     249        EXAMPLE::
     250
     251            sage: tan.set_name('tg')
     252            sage: tan
     253            tg
     254
     255        """
     256        self._name = name
     257
     258    def set_latex_name(self, latex_name):
     259        r"""
     260        Provide a name used to create a represetation in LaTeX.
     261
     262        INPUT:
     263
     264        ``latex_name`` -- a string
     265
     266        EXAMPLE::
     267
     268            sage: tan.set_latex_name(r'\tg')
     269            sage: latex(tan)
     270            \tg
     271
     272        """
     273        self._latex_name = latex_name
     274
    241275    def __cmp__(self, other):
    242276        """
    243277        TESTS: