Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#384 closed defect (fixed)

[with patch, positive review] latex formatting issues with symbolic expressions

Reported by: jbmohler Owned by: was
Priority: minor Milestone: sage-2.10.1
Component: calculus Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

There are two latex formatting issues for the symbolic expressions.

1) The \cdot's for implicit multiplication take up a lot of room and confuse my eyes.

2) I have expressions which are a product of about 5 things and they are output with excessive parentheses, for example: (((1+a)(1+b))(1+c))(1+d) The parenthesis check in the code just adds parentheses if the left subexpression contains a minus or plus. Of course, it should check if there is a minus or plus that isn't already bracketed or something like that (but, who am I to claim to know what should be done :) ).

Attachments (4)

384-latex_symbexp.patch (2.0 KB) - added by AlexGhitza 13 years ago.
384-2.patch (1.9 KB) - added by mhansen 13 years ago.
Sage-2.10.1.rc1-384-doctest-fallout-fixes_part_1.patch (1.5 KB) - added by mabshoff 13 years ago.
Sage-2.10.1.rc1-384-doctest-fallout-fixes_part_2.patch (1.5 KB) - added by mabshoff 13 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 14 years ago by mabshoff

  • Milestone set to sage-2.9

comment:2 Changed 13 years ago by mabshoff

This is still an issue with Sage 2.10:

sage: var('x,y')
(x, y)
sage: f=(x+y)*(x-y)*(x^2-2)*(y^2-3)
sage: latex(f)
{\left( {\left( {\left( {x}^{2}  - 2 \right) \cdot \left( x - y \right)} \right) \cdot \left( y + x \right)} \right) \cdot \left( {y}^{2}  - 3 \right)}

We really ought to fix this.

Cheers,

Michael

Changed 13 years ago by AlexGhitza

comment:3 Changed 13 years ago by AlexGhitza

  • Summary changed from latex formatting issues with symbolic expressions to [with patch, needs review] latex formatting issues with symbolic expressions

See the patch. A few comments:

  1. The parenthesis issue is, I believe, taken care of.
  2. After some thinking, I decided to do away with all the \cdot's. For a while, I thought they might still been needed in some situations, but since in the default behavior _latex_ first simplifies the expressions, all the weird cases I could think of (e.g. f=cos*(x-1)) are taken care of automatically. I'd be happy to change my mind if anyone can prove me wrong.

Some examples:

sage: var('x,y')
(x, y)
sage: f=(x+y)*(x-y)*(x^2-2)*(y^2-3)
sage: latex(f)
{{{\left( {x}^{2}  - 2 \right) \left( x - y \right)} \left( y + x \right)} \left( {y}^{2}  - 3 \right)}
sage: latex(cos*(x+1))
{\left( x + 1 \right) \cos}
sage: latex(x^2*2*cos(x+1))
{{{
sage: var('x,y')
(x, y)
sage: f=(x+y)*(x-y)*(x^2-2)*(y^2-3)
sage: latex(f)
{{{\left( {x}^{2}  - 2 \right) \left( x - y \right)} \left( y + x \right)} \left( {y}^{2}  - 3 \right)}
sage: latex(cos*(x+1))
{\left( x + 1 \right) \cos}
sage: latex(x^2*2*cos(x+1))
{{2 {x}^{2} } \cos \left( x + 1 \right)}
}}}

Changed 13 years ago by mhansen

comment:4 Changed 13 years ago by mhansen

Added a patch to be applied after Alex's.

comment:5 Changed 13 years ago by mhansen

  • Summary changed from [with patch, needs review] latex formatting issues with symbolic expressions to [with patch, positive review] latex formatting issues with symbolic expressions

comment:6 Changed 13 years ago by mabshoff

  • Resolution set to fixed
  • Status changed from new to closed

Merged in Sage 2.10.1.rc1

comment:7 Changed 13 years ago by mabshoff

The two doctest patches fix the issue in the documentation and the sage library. They have been merged in Sage 2.10.1.rc1.

Cheers,

Michael

Note: See TracTickets for help on using tickets.