Re: [sympy] Re: modify latex representation of user-defined function

2014-06-14 Thread Aaron Meurer
You may want to subclass gamma (the original SymPy version) instead of
Function, so that you keep all the gamma behavior.

Aaron Meurer

On Fri, Jun 6, 2014 at 4:37 PM, Björn Dahlgren bjo...@gmail.com wrote:


 On Friday, 6 June 2014 23:13:39 UTC+2, Andrei Berceanu wrote:

 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?


 This should do it:

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



 --
 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+unsubscr...@googlegroups.com.
 To post to this group, send email to sympy@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.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@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/CAKgW%3D6JMDau4CK-1Od-CO7QiKGs9woZp4NTi2XQjq7fKiwx8zA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Re: modify latex representation of user-defined function

2014-06-06 Thread Björn Dahlgren


On Friday, 6 June 2014 23:13:39 UTC+2, Andrei Berceanu wrote:

 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?


This should do it:

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

 

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@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.