On Thu, Mar 31, 2016 at 12:34 PM, Francesco Bonazzi
<
franz....@gmail.com> wrote:
>
>
> On Thursday, 31 March 2016 17:51:33 UTC+2, Aaron Meurer wrote:
>>
>> In general, I'd say the two ought to produce the same result, unless
>> there is some formatting thing that is not possible to do in Unicode
>> but is in LaTeX.
>>
>> I've noticed that the LaTeX printer and the pretty printer have
>> different methods for computing parenthesization (the LaTeX method
>> seems to be better). This is likely the cause of this. We should unify
>> the two.
>
>
> I agree, LaTeX printer determines parenthesization from the expression node
> precedence, while the pretty printer uses lots of sparsely coded if-clauses.
>
> Can anyone think of an example where parenthesization should differ between
> the LaTeX printer and the pretty printer?
The only reason to do something differently is if it's not possible to
do something with Unicode characters. For parentheses, the only limit
is that they take up an additional two columns of space, which can
admittedly make some things look too wide. For instance, we might want
to make something like f(x).diff(x, 6).subs(x, 0) print like
f^{(6)}(0) in LaTeX, but
(6)
f (0)
doesn't look so good (not that I can think of a better way to print it).
>
> I'd also suggest to make it a goal that all LaTeX printed expressions can be
> parsed back by latex2sympy.
That's a good goal, but we shouldn't sacrifice the printing of
expressions. The number 1 goal should be to make expressions print
nicely. In other words, we should improve latex2sympy rather than
change latex() if it means making the output look less nice.
Aaron Meurer
>
https://groups.google.com/d/msgid/sympy/cf299501-20b8-45ca-8bb3-848d14c87699%40googlegroups.com.