Opened 10 years ago

Closed 9 years ago

#13356 closed defect (fixed)

Wrong LaTeX for products of numbers

Reported by: Andrey Novoseltsev Owned by: Burcin Erocal
Priority: major Milestone: sage-6.2
Component: symbolics Keywords: latex, pynac, sd48
Cc: Burcin Erocal, Eviatar Bach Merged in:
Authors: Burcin Erocal Reviewers: Jean-Pierre Flori
Report Upstream: N/A Work issues:
Branch: 2c9b4e6 (Commits, GitHub, GitLab) Commit: 2c9b4e6d6de18630846a529eeb0a2bde08cbd56c
Dependencies: #15198 Stopgaps:

Status badges

Description

E.g.

sage: e = 2 * 2^(1/3)
sage: print latex(e)
2 \, 2^{\left(\frac{1}{3}\right)} 

the output looks like power of 22, there should be \cdot.

(And there should be no parenthesis around the power, but that does not change the meaning at least.)

Attachments (1)

trac_13356-latex_coeff_sep.patch (1.1 KB) - added by Burcin Erocal 9 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 Changed 10 years ago by Andrey Novoseltsev

My investigation shows that the issue is in GEx_to_str_latex, but I have no clue how to fix it.

comment:2 Changed 10 years ago by Andrey Novoseltsev

#3202 was about the same problem and claims to be fixed, but I am not sure what is/was the problem with the example there. On the other hand, there is a test in the docstring of symbolic expressions claiming that 2 \, 2 is great.

comment:3 Changed 10 years ago by Andrey Novoseltsev

Cc: Burcin Erocal added

Burcin, any ideas on whether it is in Pynac or Ginac and how to fix it?

comment:4 Changed 9 years ago by Andrey Novoseltsev

Slight change in Sage-5.10.rc1:

sage: sage: e = 2 * 2^(1/3)
sage: sage: print latex(e)
2 \, 2^{\frac{1}{3}}

Changed 9 years ago by Burcin Erocal

comment:5 Changed 9 years ago by Burcin Erocal

Authors: Burcin Erocal
Keywords: pynac sd48 added

Patch for pynac available on my work-in-progress repo. Doctest fixes in trac_13356-latex_coeff_sep.patch

Now the output is:

sage: latex(2 * 2^x)
2 \cdot 2^{x}

We still keep \, if the next character is not a digit:

sage: latex(2* x^2)
2 \, x^{2}

comment:6 Changed 9 years ago by Burcin Erocal

In this sage-support@ thread the consensus seems to be to remove \, and only use \cdot when both sides are numerals.

I am planning to make this change if there are no objections. I'm afraid this will mean fixing doctests all over the tree yet again.

comment:7 Changed 9 years ago by Andrey Novoseltsev

I certainly would not object - I think Sage-generated code should be as close to human-written as possible, so that it is relatively easy to copy-paste into manually written papers. I've never seen anyone manually inserting \, for every product. (It would be good also to have x_0^2 rather than x_{0}^{2}, but that's not related to this ticket.)

comment:8 Changed 9 years ago by Eviatar Bach

Cc: Eviatar Bach added

comment:9 Changed 9 years ago by Jeroen Demeyer

Milestone: sage-5.11sage-5.12

comment:10 Changed 9 years ago by Eviatar Bach

Dependencies: #15198

comment:11 Changed 9 years ago by For batch modifications

Milestone: sage-6.1sage-6.2

comment:12 Changed 9 years ago by Jean-Pierre Flori

This is to be merged with the pynac update at #15198.

comment:13 Changed 9 years ago by Jean-Pierre Flori

Branch: u/jpflori/ticket/13356
Commit: 2c9b4e6d6de18630846a529eeb0a2bde08cbd56c
Reviewers: Jean-Pierre Flori
Status: newneeds_review

New commits:

2c9b4e6Add doctests for printing fixes in pynac.

comment:14 Changed 9 years ago by Jean-Pierre Flori

It seems no doctests needs updating. I'll double check (I have a problem with ascii_art right now, but surely for other reasons) and if so set this to positive review.

comment:15 Changed 9 years ago by Jean-Pierre Flori

Status: needs_reviewpositive_review

comment:16 Changed 9 years ago by Volker Braun

Branch: u/jpflori/ticket/133562c9b4e6d6de18630846a529eeb0a2bde08cbd56c
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.