Opened 10 years ago

Closed 9 years ago

# Wrong LaTeX for products of numbers

Reported by: Owned by: Andrey Novoseltsev Burcin Erocal major sage-6.2 symbolics latex, pynac, sd48 Burcin Erocal, Eviatar Bach Burcin Erocal Jean-Pierre Flori N/A 2c9b4e6 2c9b4e6d6de18630846a529eeb0a2bde08cbd56c #15198

### 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.)

### 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

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}}


### comment:5 Changed 9 years ago by Burcin Erocal

Authors: → Burcin Erocal 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:9 Changed 9 years ago by Jeroen Demeyer

Milestone: sage-5.11 → sage-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.1 → sage-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 → 2c9b4e6d6de18630846a529eeb0a2bde08cbd56c → Jean-Pierre Flori new → needs_review

New commits:

 ​2c9b4e6 Add 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_review → positive_review

### comment:16 Changed 9 years ago by Volker Braun

Branch: u/jpflori/ticket/13356 → 2c9b4e6d6de18630846a529eeb0a2bde08cbd56c → fixed positive_review → closed
Note: See TracTickets for help on using tickets.