Opened 9 years ago

Closed 8 years ago

#13356 closed defect (fixed)

Wrong LaTeX for products of numbers

Reported by: novoselt Owned by: burcin
Priority: major Milestone: sage-6.2
Component: symbolics Keywords: latex, pynac, sd48
Cc: burcin, eviatarbach 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



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 9 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 Changed 9 years ago by novoselt

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

comment:2 Changed 9 years ago by novoselt

#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 9 years ago by novoselt

  • Cc burcin added

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

comment:4 Changed 9 years ago by novoselt

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

comment:5 Changed 9 years ago by burcin

  • Authors set to 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

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 novoselt

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 eviatarbach

  • Cc eviatarbach added

comment:9 Changed 8 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:10 Changed 8 years ago by eviatarbach

  • Dependencies set to #15198

comment:11 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:12 Changed 8 years ago by jpflori

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

comment:13 Changed 8 years ago by jpflori

  • Branch set to u/jpflori/ticket/13356
  • Commit set to 2c9b4e6d6de18630846a529eeb0a2bde08cbd56c
  • Reviewers set to Jean-Pierre Flori
  • Status changed from new to needs_review

New commits:

2c9b4e6Add doctests for printing fixes in pynac.

comment:14 Changed 8 years ago by jpflori

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 8 years ago by jpflori

  • Status changed from needs_review to positive_review

comment:16 Changed 8 years ago by vbraun

  • Branch changed from u/jpflori/ticket/13356 to 2c9b4e6d6de18630846a529eeb0a2bde08cbd56c
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.