Hi Freddie! On Wed, Dec 24, 2008 at 1:31 PM, Freddie Witherden <fred...@witherden.org> wrote: > Hi, > > I have been toying around with the LaTeX printing over the last couple > of days and in the process have put together a few (potentially > idiosyncratic) changes to the printing class. I would be interested to > know what everyone thinks of this (i.e., is there enough interest that > it is worth making them mainstream). > > Firstly, I added support for fractional power folding. If an exponent > is of the form p/q where both p and q are rational (and q is not 2, as > then a square-root is appropriate) then the fraction is folded. Here > is an example: > >>> ex = sympify('x^(3/4)') > >>> latex(ex) > '$x^{\\frac{3}{4}}$' > >>> latex(ex,foldFracPowers=True) > '$x^{3/4}$' > > As you can see instead of a fraction a plain old division symbol is > used. This is often nice when handling fractions of the form p/q^a as > it saves all-important vertical space and makes the power much more > readable (as the font size will be larger). > > Secondly, I have added support for function bracket folding. If a > function (lets say tan) has one and only one argument which does not > itself need brackets, then it is possible to fold them. Another > example if you will: > >>> ex = sympify('tan(2*x)') > >>> latex(ex) > '$\\operatorname{tan}\\left(2 x\\right)$' > >>> latex(ex,foldFuncBrackets=True) > '$\\operatorname{tan}2 x$' > > This is done by the addition of a new function > _needs_function_brackets, which is a more generalised form of > needs_brackets, namely one that allows Mul and Pow to not require > them. I am still testing this, however, so there may be some cases > where it (erroneously) omits brackets. I am still working on a way to > handle tan(x)*cos(x) (currently '$\\operatorname{cos}x \ > \operatorname{tan}2 x$') but it might come down to either a) folding > tan(x*cos(x)) to tan xcos x or b) folding tan(x)*cos(x) to tan x cos x. > > Finally, I would like to apologise for my use of camelCase, I'll fix > that soon.
Thanks a lot for this work. Is your code available somewhere? If you use git, just publish your branch for example on github.com and we'll then see how to integrate this. I like both things that you implemented. Thanks also for reporting several issues that you found along the way. Happy Christmas, Ondrej --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---