Opened 8 years ago
Closed 7 years ago
#13356 closed defect (fixed)
Wrong LaTeX for products of numbers
Reported by:  novoselt  Owned by:  burcin 

Priority:  major  Milestone:  sage6.2 
Component:  symbolics  Keywords:  latex, pynac, sd48 
Cc:  burcin, eviatarbach  Merged in:  
Authors:  Burcin Erocal  Reviewers:  JeanPierre Flori 
Report Upstream:  N/A  Work issues:  
Branch:  2c9b4e6 (Commits)  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 8 years ago by
comment:2 Changed 8 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 8 years ago by
 Cc burcin added
Burcin, any ideas on whether it is in Pynac or Ginac and how to fix it?
comment:4 Changed 7 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 7 years ago by
comment:5 Changed 7 years ago by
 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 7 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 7 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 7 years ago by
 Cc eviatarbach added
comment:9 Changed 7 years ago by
 Milestone changed from sage5.11 to sage5.12
comment:10 Changed 7 years ago by
 Dependencies set to #15198
comment:11 Changed 7 years ago by
 Milestone changed from sage6.1 to sage6.2
comment:12 Changed 7 years ago by
This is to be merged with the pynac update at #15198.
comment:13 Changed 7 years ago by
 Branch set to u/jpflori/ticket/13356
 Commit set to 2c9b4e6d6de18630846a529eeb0a2bde08cbd56c
 Reviewers set to JeanPierre Flori
 Status changed from new to needs_review
New commits:
2c9b4e6  Add doctests for printing fixes in pynac.

comment:14 Changed 7 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 7 years ago by
 Status changed from needs_review to positive_review
comment:16 Changed 7 years ago by
 Branch changed from u/jpflori/ticket/13356 to 2c9b4e6d6de18630846a529eeb0a2bde08cbd56c
 Resolution set to fixed
 Status changed from positive_review to closed
My investigation shows that the issue is in
GEx_to_str_latex
, but I have no clue how to fix it.