Hi Jason, On Wed, Mar 25, 2009 at 11:57 AM, Jason Grout <jason-s...@creativetrax.com> > Can you post your patch that makes the functions typeset as greek > letters?
This is my first attempt to modify Sage. So please feel free to correct me. Let me mention the changes I have made to get the elementary support for typesetting functions as Greek letters. (1) In file: "sage/misc/latex.py", I have added a function after the list "common_varnames" as follows -------------------------------------- def is_common_varname(a): """ Checks whether it is a common variable name such as alpha, beta """ if a in common_varnames: return True else: return False ---------------------------------- (2) In file: "sage/calculus/calculus.py", change the line "from sage.misc.latex import latex, latex_variable_name" to "from sage.misc.latex import latex, latex_variable_name, is_common_varname" and in _latex_(self) function for "class SymbolicFunctionEvaluation" I have added following three lines -------------------------------------------------------- + n = self._f._name + if is_common_varname(n): + return "\\%s(%s)"%(n, ', '.join([x._latex_() for x in self._args])) try: return latex(self._maxima_()) --------------------------------------------------------- > I believe http://trac.sagemath.org/sage_trac/ticket/4202 is relevant here. Thanks, it should definitely help. >> (2) In the list "common_varnames" (in sage/misc/latex.py) two >> letters "Phi" and "phi" are missing. > Yep, I ran into (2) a while back when doing spherical coordinates. Do > you already have a patch to add them? The patch that I am attaching has them added in it. However, I think it will be better to have a separate patch for this, as this is a stand-alone issue and should be fixed separately. BTW, this patch is highly incomplete (for the intended aim) as of now. Cheers, Golam --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
# HG changeset patch # User Golam Mortuza Hossain <gmhoss...@gmail.com> # Date 1238002038 10800 # Node ID 50546678cf7a3d0d208b4f476512c418f7e0dc5e # Parent d9c91204a79be393d5c965b4ed18917b625fd007 Adds support for typsetting functions as Greek letters diff -r d9c91204a79b -r 50546678cf7a sage/calculus/calculus.py --- a/sage/calculus/calculus.py Fri Mar 13 14:01:37 2009 -0700 +++ b/sage/calculus/calculus.py Wed Mar 25 14:27:18 2009 -0300 @@ -297,7 +297,7 @@ from sage.structure.parent_base import ParentWithBase import operator -from sage.misc.latex import latex, latex_variable_name +from sage.misc.latex import latex, latex_variable_name, is_common_varname from sage.misc.misc import uniq as unique from sage.structure.sage_object import SageObject @@ -9749,6 +9749,9 @@ {{{\it \partial}}\over{{\it \partial}\,x}}\,\left \lceil x \right \rceil """ + n = self._f._name + if is_common_varname(n): + return "\\%s(%s)"%(n, ', '.join([x._latex_() for x in self._args])) try: return latex(self._maxima_()) except: diff -r d9c91204a79b -r 50546678cf7a sage/misc/latex.py --- a/sage/misc/latex.py Fri Mar 13 14:01:37 2009 -0700 +++ b/sage/misc/latex.py Wed Mar 25 14:27:18 2009 -0300 @@ -747,6 +747,8 @@ 'Sigma', 'tau', 'upsilon', + 'phi', + 'Phi', 'varphi', 'chi', 'psi', @@ -754,6 +756,15 @@ 'omega', 'Omega'] +def is_common_varname(a): + """ + Checks whether it is a common variable name such as alpha, beta + """ + if a in common_varnames: + return True + else: + return False + def latex_varify(a): if a in common_varnames: return "\\" + a