Order Add args when printing latex

30 views
Skip to first unread message

Paul Royik

unread,
Jan 13, 2023, 6:10:45 AM1/13/23
to sympy
Hello.

Is it possible to render cos ^2 (x)- sin ^2 (x) as "cos ^2 (x)- sin ^2 (x)", not "- sin ^2 (x)+cos^2(x)"? I want terms with negative sign be last.

I've discovered that there is def _print_Add(self, expr, order=None):

How should order be specified?

Oscar Benjamin

unread,
Jan 21, 2023, 9:36:58 AM1/21/23
to sy...@googlegroups.com
There is an order argument to init_printing but it probably doesn't do
what you want. You can set it to None though and then manually set the
order of the terms in the expression:

In [13]: init_printing(order='none')

In [14]: Add(y, x, evaluate=False)
Out[14]: y + x

--
Oscar

Paul Royik

unread,
Jan 21, 2023, 10:24:38 AM1/21/23
to sympy
Thank you very much for the response.
Is there any other ways without evaluate=False?
What about def _parse_order(cls, order): function?
Can I specify a custom order?

Oscar Benjamin

unread,
Jan 21, 2023, 10:28:51 AM1/21/23
to sy...@googlegroups.com
On Sat, 21 Jan 2023 at 15:24, Paul Royik <distan...@gmail.com> wrote:
>
> Thank you very much for the response.
> Is there any other ways without evaluate=False?
> What about def _parse_order(cls, order): function?
> Can I specify a custom order?

I don't think anything like this is possible but it would be good to
add something like this. I think it's quite common that people don't
like the ordering used by the printers. Personally I think that
order='none' should at least be the default.

--
Oscar

Paul Royik

unread,
Jan 21, 2023, 12:04:27 PM1/21/23
to sympy
Thank you very much!
Reply all
Reply to author
Forward
0 new messages