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:  sage6.2 
Component:  symbolics  Keywords:  latex, pynac, sd48 
Cc:  Burcin Erocal, Eviatar Bach  Merged in:  
Authors:  Burcin Erocal  Reviewers:  JeanPierre Flori 
Report Upstream:  N/A  Work issues:  
Branch:  2c9b4e6 (Commits, GitHub, GitLab)  Commit:  2c9b4e6d6de18630846a529eeb0a2bde08cbd56c 
Dependencies:  #15198  Stopgaps: 
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)
Change History (17)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
#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
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
Slight change in Sage5.10.rc1:
sage: sage: e = 2 * 2^(1/3) sage: sage: print latex(e) 2 \, 2^{\frac{1}{3}}
Changed 9 years ago by
Attachment:  trac_13356latex_coeff_sep.patch added 

comment:5 Changed 9 years ago by
Authors:  → Burcin Erocal 

Keywords:  pynac sd48 added 
Patch for pynac available on my workinprogress repo. Doctest fixes in trac_13356latex_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
In this sagesupport@ 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
I certainly would not object  I think Sagegenerated code should be as close to humanwritten as possible, so that it is relatively easy to copypaste 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
Cc:  Eviatar Bach added 

comment:9 Changed 9 years ago by
Milestone:  sage5.11 → sage5.12 

comment:10 Changed 9 years ago by
Dependencies:  → #15198 

comment:11 Changed 9 years ago by
Milestone:  sage6.1 → sage6.2 

comment:13 Changed 9 years ago by
Branch:  → u/jpflori/ticket/13356 

Commit:  → 2c9b4e6d6de18630846a529eeb0a2bde08cbd56c 
Reviewers:  → JeanPierre Flori 
Status:  new → needs_review 
New commits:
2c9b4e6  Add doctests for printing fixes in pynac.

comment:14 Changed 9 years ago by
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
Status:  needs_review → positive_review 

comment:16 Changed 9 years ago by
Branch:  u/jpflori/ticket/13356 → 2c9b4e6d6de18630846a529eeb0a2bde08cbd56c 

Resolution:  → fixed 
Status:  positive_review → closed 
My investigation shows that the issue is in
GEx_to_str_latex
, but I have no clue how to fix it.