Opened 8 years ago

Closed 7 months ago

#14509 closed defect (fixed)

Fix LaTeX of free algebras (and repr_lincomb)

Reported by: kcrisman Owned by: was
Priority: minor Milestone: sage-9.3
Component: user interface Keywords: latex
Cc: tscrim, chapoton, hoanguyen 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 mkoeppe)

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

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

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.

Edit: Ok. Visually, this breaks subscripts and superscripts although the latex is fine.

Last edited 8 years ago by ppurka (previous) (diff)

comment:3 Changed 8 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:4 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:5 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:6 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:7 Changed 12 months ago by mkoeppe

  • Milestone changed from sage-6.4 to sage-9.2

Still broken in 9.2.beta1.

For repr_lincomb see also #29892.

comment:8 Changed 12 months ago by mkoeppe

  • Cc tscrim chapoton added

comment:9 Changed 12 months ago by gh-DaveWitteMorris

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

comment:10 Changed 12 months ago by mkoeppe

  • Dependencies set to #29869

comment:11 Changed 12 months ago by mkoeppe

  • Dependencies changed from #29869 to #29892

comment:12 Changed 12 months ago by mkoeppe

  • Description modified (diff)

comment:13 Changed 8 months ago by mkoeppe

  • Cc hoanguyen added

comment:14 Changed 8 months ago by mkoeppe

  • Milestone changed from sage-9.2 to sage-9.3

comment:15 Changed 8 months ago by hoanguyen

  • Branch set to u/hoanguyen/fix_latex_of_free_algebras__and_repr_lincomb_

comment:16 Changed 8 months ago by hoanguyen

  • Authors set to Hoa Nguyen
  • Commit set to 395deabbf8ea5722248c063ca2bba4733bf7a51f
  • Status changed from new to needs_review

comment:17 Changed 8 months ago by 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 8 months ago by chapoton (previous) (diff)

comment:18 Changed 8 months ago by git

  • Commit changed from 395deabbf8ea5722248c063ca2bba4733bf7a51f to 20395b595a9a4f4f31bd81b1dc5b53c012ff2383

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

20395b5Fix doctest

comment:19 Changed 8 months ago by git

  • Commit changed from 20395b595a9a4f4f31bd81b1dc5b53c012ff2383 to 87d3fc75e5464499c1811e2cc70ff526c8aa0010

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

87d3fc7Fix doctest

comment:20 Changed 8 months ago by git

  • Commit changed from 87d3fc75e5464499c1811e2cc70ff526c8aa0010 to ef6c22d56c7e0aeaf226c05f0f6db80b0939aa98

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

ef6c22dFix doctest

comment:21 Changed 8 months ago by git

  • Commit changed from ef6c22d56c7e0aeaf226c05f0f6db80b0939aa98 to 8d8dd831849e4537a5cdd587ce640ccefef53b5d

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

8d8dd83Update doctest

comment:22 Changed 7 months ago by tscrim

  • Reviewers set to Frédéric Chapoton, Travis Scrimshaw
  • Status changed from needs_review to positive_review

LGTM.

comment:23 Changed 7 months ago by vbraun

  • Branch changed from u/hoanguyen/fix_latex_of_free_algebras__and_repr_lincomb_ to 8d8dd831849e4537a5cdd587ce640ccefef53b5d
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.