Ask Your Question
1

latex form of product of non-commuting variables

asked 2013-04-30 21:48:39 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

the result of

K.< alpha,b > = FreeAlgebra(SR)
latex(alpha*b)

is

\alphab

without a space between \alpha and b.

Is it a bug?

('Sage Version 5.8, Release Date: 2013-03-15' on osx 10.6.8)

edit retag flag offensive close merge delete

Comments

Yuck, this needs work. I couldn't even find a good workaround. You can try using `repr_lincomb` some to see what you get, but I wasn't able to get this to work as we would desire. See http://trac.sagemath.org/sage_trac/ticket/14509

kcrisman gravatar imagekcrisman ( 2013-04-30 22:18:43 +0200 )edit

The ticket @kcrisman points to is at http://trac.sagemath.org/sage_trac/ti... . @kcrisman: please leave the link above as is, I am referencing it at https://github.com/ASKBOT/askbot-deve... .

slelievre gravatar imageslelievre ( 2016-04-07 15:00:06 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-04-07 01:32:14 +0200

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

in my opinion, this problem can be solved in a clean way by replacing the line 2510 in sage/misc/latex.py

    ...
    2509  elif len(a) == 1:
    2510     return a
    2511  elif is_fname is True:
    ...

with

    ...
    2509  elif len(a) == 1:
    2510     return '{%s}'%a
    2511  elif is_fname is True:
    ...

actually I get a far better result with

...
2505  if a in common_varnames:
2506     return '{\\,\\%s}'%a
2507  elif len(a) == 0:
2508      return ''
2509  elif len(a) == 1:
2510      return '{\\,%s}'%a
2511  elif is_fname is True:
2512      return '{\\,\\rm %s}'%a
2513  else:
2514      return '\\,\\mathit{%s}'%a
...
edit flag offensive delete link more

Comments

Would you consider using raw strings, eg r'{\,\%s}' instead of '{\\,\\%s}'. Makes things clearer.

slelievre gravatar imageslelievre ( 2016-04-07 11:19:11 +0200 )edit

Shouldn't this discussion happen at http://trac.sagemath.org/ticket/14509?

John Palmieri gravatar imageJohn Palmieri ( 2016-04-07 20:47:11 +0200 )edit

@io: would you contribute your solution to Sage trac ticket #14509?

slelievre gravatar imageslelievre ( 2016-04-09 16:20:46 +0200 )edit

For the record: fixed in Sage trac ticket #14509, merged in Sage 9.3.beta2.

slelievre gravatar imageslelievre ( 2020-12-01 15:31:21 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-04-30 21:48:39 +0200

Seen: 550 times

Last updated: Apr 07 '16