Opened 10 years ago

Closed 2 years ago

#14509 closed defect (fixed)

Fix LaTeX of free algebras (and repr_lincomb)

Reported by: Karl-Dieter Crisman Owned by: William Stein
Priority: minor Milestone: sage-9.3
Component: user interface Keywords: latex
Cc: Travis Scrimshaw, Frédéric Chapoton, Hoa Nguyen Merged in:
Authors: Hoa Nguyen Reviewers: Frédéric Chapoton, Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: 8d8dd83 (Commits, GitHub, GitLab) Commit: 8d8dd831849e4537a5cdd587ce640ccefef53b5d
Dependencies: #29892 Stopgaps:

Status badges

Description (last modified by Matthias Köppe)

sage: K.< alpha,b > = FreeAlgebra(SR)
sage: latex(alpha*b)
\alphab

Someone we are not using repr_lincomb correctly, and in fact that function itself looks pretty hackishly defined. I couldn't even find a very good workaround.

See the first report at ask.sagemath.

See also: #26606 (same problem for power series in one variable).

Change History (23)

comment:1 Changed 9 years ago by Punarbasu Purkayastha

  • sage/misc/latex.py

    diff --git a/sage/misc/latex.py b/sage/misc/latex.py
    a b  
    25032503        '\\alpha'
    25042504    """
    25052505    if a in common_varnames:
    2506         return "\\" + a
     2506        return "\\" + a + "{}"
    25072507    elif len(a) == 1:
    25082508        return a
    25092509    elif is_fname is True:

This fixes the latex, but the raw latex doesn't look good any more.

sage: K.< alpha,b > = FreeAlgebra(SR)      
sage: latex(alpha*b)                       
\alpha{}b

comment:2 Changed 9 years ago by Punarbasu Purkayastha

In fact, what will break if we simply add a space after every such comman variable name?

  • sage/misc/latex.py

    a b  
    25032503        '\\alpha'
    25042504    """
    25052505    if a in common_varnames:
    2506         return "\\" + a
     2506        return "\\" + a + " "
    25072507    elif len(a) == 1:
    25082508        return a
    25092509    elif is_fname is True:

Visually, and in latex, this is probably the simplest fix.

Version 0, edited 9 years ago by Punarbasu Purkayastha (next)

comment:3 Changed 9 years ago by Jeroen Demeyer

Milestone: sage-5.11sage-5.12

comment:4 Changed 9 years ago by For batch modifications

Milestone: sage-6.1sage-6.2

comment:5 Changed 9 years ago by For batch modifications

Milestone: sage-6.2sage-6.3

comment:6 Changed 8 years ago by For batch modifications

Milestone: sage-6.3sage-6.4

comment:7 Changed 2 years ago by Matthias Köppe

Milestone: sage-6.4sage-9.2

Still broken in 9.2.beta1.

For repr_lincomb see also #29892.

comment:8 Changed 2 years ago by Matthias Köppe

Cc: Travis Scrimshaw Frédéric Chapoton added

comment:9 Changed 2 years ago by Dave Morris

Related ticket: #26606 (same problem for power series in one variable).

comment:10 Changed 2 years ago by Matthias Köppe

Dependencies: #29869

comment:11 Changed 2 years ago by Matthias Köppe

Dependencies: #29869#29892

comment:12 Changed 2 years ago by Matthias Köppe

Description: modified (diff)

comment:13 Changed 2 years ago by Matthias Köppe

Cc: Hoa Nguyen added

comment:14 Changed 2 years ago by Matthias Köppe

Milestone: sage-9.2sage-9.3

comment:15 Changed 2 years ago by Hoa Nguyen

Branch: u/hoanguyen/fix_latex_of_free_algebras__and_repr_lincomb_

comment:16 Changed 2 years ago by Hoa Nguyen

Authors: Hoa Nguyen
Commit: 395deabbf8ea5722248c063ca2bba4733bf7a51f
Status: newneeds_review

comment:17 Changed 2 years ago by Frédéric Chapoton

missing empty line after

+            Check that :trac:`14509` is fixed::

and doctests should be indented, or rather this line should be un-indented

Last edited 2 years ago by Frédéric Chapoton (previous) (diff)

comment:18 Changed 2 years ago by git

Commit: 395deabbf8ea5722248c063ca2bba4733bf7a51f20395b595a9a4f4f31bd81b1dc5b53c012ff2383

Branch pushed to git repo; I updated commit sha1. New commits:

20395b5Fix doctest

comment:19 Changed 2 years ago by git

Commit: 20395b595a9a4f4f31bd81b1dc5b53c012ff238387d3fc75e5464499c1811e2cc70ff526c8aa0010

Branch pushed to git repo; I updated commit sha1. New commits:

87d3fc7Fix doctest

comment:20 Changed 2 years ago by git

Commit: 87d3fc75e5464499c1811e2cc70ff526c8aa0010ef6c22d56c7e0aeaf226c05f0f6db80b0939aa98

Branch pushed to git repo; I updated commit sha1. New commits:

ef6c22dFix doctest

comment:21 Changed 2 years ago by git

Commit: ef6c22d56c7e0aeaf226c05f0f6db80b0939aa988d8dd831849e4537a5cdd587ce640ccefef53b5d

Branch pushed to git repo; I updated commit sha1. New commits:

8d8dd83Update doctest

comment:22 Changed 2 years ago by Travis Scrimshaw

Reviewers: Frédéric Chapoton, Travis Scrimshaw
Status: needs_reviewpositive_review

LGTM.

comment:23 Changed 2 years ago by Volker Braun

Branch: u/hoanguyen/fix_latex_of_free_algebras__and_repr_lincomb_8d8dd831849e4537a5cdd587ce640ccefef53b5d
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.