modify latex representation of user-defined function

21 views
Skip to first unread message

Andrei Berceanu

unread,
Jun 6, 2014, 5:13:39 PM6/6/14
to sy...@googlegroups.com
I define a function gamma with the following code:

from sympy import *
x = Symbol('x')
class gamma(Function): pass

Its latex representation is

print latex(gamma(x))
\Gamma\left(x\right)

whereas I would like it to be
\gamma\left(x\right)

i.e. lowercase instead of capital.

How can I achieve this?


Björn Dahlgren

unread,
Jun 6, 2014, 5:37:49 PM6/6/14
to sy...@googlegroups.com

This should do it:

class gamma(Function):
   
def _latex(self, printer):
       
return r'\gamma{\left(%s \right)}' % printer._print(self.args[0])

 

Aaron Meurer

unread,
Jun 14, 2014, 4:06:15 PM6/14/14
to sy...@googlegroups.com
You may want to subclass gamma (the original SymPy version) instead of
Function, so that you keep all the gamma behavior.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/e4addabc-3010-4107-b270-9767ee113c5d%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages