Bug 312738 - Should import Sage LaTeX macros
Summary: Should import Sage LaTeX macros
Status: RESOLVED FIXED
Alias: None
Product: cantor
Classification: Applications
Component: sage-backend (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Filipe Saraiva
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-06 11:33 UTC by Antonio Rojas
Modified: 2016-07-04 00:17 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 16.04.3


Attachments
Sage output (42.75 KB, image/png)
2016-07-02 16:30 UTC, Filipe Saraiva
Details
Output of Zmod(5) (3.43 KB, image/png)
2016-07-02 21:07 UTC, Antonio Rojas
Details
Output of Zmod(5) in Cantor (Sage backend) (34.88 KB, image/png)
2016-07-03 00:00 UTC, Filipe Saraiva
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Antonio Rojas 2013-01-06 11:33:50 UTC
Cantor should import Sage's LaTeX macros before processing the LaTeX output, otherwise some expressions are not rendered.
The list of macros can be obtained with the Sage command:

from sage.misc.latex import *
print latex_extra_preamble()

As of Sage 5.5 the list is:

\newcommand{\ZZ}{\Bold{Z}}
\newcommand{\NN}{\Bold{N}}
\newcommand{\RR}{\Bold{R}}
\newcommand{\CC}{\Bold{C}}
\newcommand{\QQ}{\Bold{Q}}
\newcommand{\QQbar}{\overline{\QQ}}
\newcommand{\GF}[1]{\Bold{F}_{#1}}
\newcommand{\Zp}[1]{\ZZ_{#1}}
\newcommand{\Qp}[1]{\QQ_{#1}}
\newcommand{\Zmod}[1]{\ZZ/#1\ZZ}
\newcommand{\CDF}{\Bold{C}}
\newcommand{\CIF}{\Bold{C}}
\newcommand{\CLF}{\Bold{C}}
\newcommand{\RDF}{\Bold{R}}
\newcommand{\RIF}{\Bold{I} \Bold{R}}
\newcommand{\RLF}{\Bold{R}}
\newcommand{\CFF}{\Bold{CFF}}
\newcommand{\Bold}[1]{\mathbf{#1}}


Reproducible: Always

Steps to Reproduce:
1.Open a new worksheet with the Sage backend
2.Evaluate 'Zmod(5)'

Actual Results:  
LaTeX fails to compile, outputs raw LaTeX code 

Expected Results:  
LaTeX output is rendered
Comment 1 simnale 2013-09-27 11:21:53 UTC
I had the same problem. I tried to compile one of the temporary .tex files, that Cantor creates in /tmp/kde-user/cantor/ with texi2dvi and it failed saying it couldn't find "ulem.sty".
After downloading the file, placing it in /usr/share/texlive/texmf-dist/tex/latex/base/ and running texhash everything worked fine.
Comment 2 simnale 2013-09-27 11:48:00 UTC
Ok, I think I didn't have the same problem. Before adding the file, the LaTeX typesetting in 
Cantor didn't work at all for me. Now everything works except the command mentioned above.
Comment 3 Filipe Saraiva 2016-05-26 22:48:01 UTC
Looks like it is not necessary. The LaTeX rendering for Sage backend is back after 03242efc commit [1].

If you have this problem again, please reopen the bug.

[1] http://commits.kde.org/cantor/03242efc03679d54105745ff21beacfb9850a59b
Comment 4 Antonio Rojas 2016-05-27 16:58:44 UTC
This has nothing to do with the broken latex rendering in the sagemath backend. This is about the specific latex command defined by sage, which are not available in standard latex. 
As I said in the original  report, reproducing is easy: just evaluate "Zmod(5)"
Comment 5 jackdyson31 2016-06-26 17:08:23 UTC
Using version 0.6 pn Kubuntu 16.04 I can't get LaTeX rendering at all: you just get a plain text answer:

(cot(x)^2 + 1)*x/cot(x)^2 + 1/cot(x)

I thought this is sagemath version thing again - however the plugin for maxima  produces the same issue. All latex deps installed - cantor renders its tex cells successfully
Comment 6 T2 2016-07-02 09:36:57 UTC
I'm experiencing that too. On Arch Linux x64 with Cantor 16.04.2-1, sage and LaTeX installed, a simple matrix doesn't render. Input: matrix([[2,3,4],[5,6,7],[8,9,10]])

Output: 
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr}

2 & 3 & 4 \\

5 & 6 & 7 \\

8 & 9 & 10

\end{array}\right)

With Maxima, on the other hand, LaTeX seems to render just fine.
Comment 7 Antonio Rojas 2016-07-02 09:52:28 UTC
@jackdyson31 @T2 your issue is bug 327259, which is already fixed in trunk and has nothing to do with this bug
Comment 8 jackdyson31 2016-07-02 11:08:00 UTC
@Antonio Rojas : right thanks, thats quite an old issue - it is actually happening on Kubuntu 16.04 with the latest version of Cantor that I have access to. 327259 affected just Sagemath. What I am saying here is the is NO LaTeX output for Maxima or Sage and I have downloaded and built the latest one on your repository to check before I posted this.

We might also check to remove an old bug: open more than a single session and the menus reorganize themselves on the menubar. Kill the status bar and you cannot type text anymore.

If there is anything I should or could do to help please say, given that I know you guys are busy. I just need to know how to properly install as a debian package (apt-get source doesn't work for this version).

However, in my experience, every release of Sagemath or Cantor has broken something, which wastes time. It is a great concept but if we are serious then we might have a discussion about ensuring basic stability of common features (and that can also include the Sagemath people so that they don't keep changing basic stuff).
Comment 9 Filipe Saraiva 2016-07-02 16:18:10 UTC
(In reply to jackdyson31 from comment #5)
> Using version 0.6 pn Kubuntu 16.04 I can't get LaTeX rendering at all: you
> just get a plain text answer:

This bug was fixed in master and will be available in Cantor 16.08 version (August 2016).
Comment 10 Filipe Saraiva 2016-07-02 16:25:20 UTC
(In reply to jackdyson31 from comment #8)
> However, in my experience, every release of Sagemath or Cantor has broken
> something, which wastes time. It is a great concept but if we are serious
> then we might have a discussion about ensuring basic stability of common
> features (and that can also include the Sagemath people so that they don't
> keep changing basic stuff).

You are right about it. Cantor has a great concept and it is easy to implement new backends, however, it is hard to just one person to maintain those lot of backends. The author needs to track changes in each of those 10 programming languages in several versions and keep all of them working correctly. So, that is impossible for a person working at least 6 hours/week to do this work alone.

If you want to help, you can to step forward and be the maintainer of some backend [1]. Or help correctly informing the version of the programming language utilized, the version of Cantor utilized, and provide some step-by-step example of how to reproduce your bug in a new bug report.

I am doing my best to fix the bugs related and keep the software working, but I can not to do everything alone.

[1] https://bugs.kde.org/describecomponents.cgi?product=cantor
Comment 11 Filipe Saraiva 2016-07-02 16:30:35 UTC
Created attachment 99803 [details]
Sage output
Comment 12 Filipe Saraiva 2016-07-02 16:32:48 UTC
(In reply to T2 from comment #6)
> I'm experiencing that too. On Arch Linux x64 with Cantor 16.04.2-1, sage and
> LaTeX installed, a simple matrix doesn't render. Input:
> matrix([[2,3,4],[5,6,7],[8,9,10]])
> 
> Output: 
> \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr}

> 2 & 3 & 4 \\

> 5 & 6 & 7 \\

> 8 & 9 & 10

> \end{array}\right)

This is fixed in current master branch and will be available in Cantor 16.08. You can see the output of that command in attachment 99803 [details].
Comment 13 Filipe Saraiva 2016-07-02 18:48:38 UTC
(In reply to Antonio Rojas from comment #4)
> This has nothing to do with the broken latex rendering in the sagemath
> backend. This is about the specific latex command defined by sage, which are
> not available in standard latex. 
> As I said in the original  report, reproducing is easy: just evaluate
> "Zmod(5)"

Hi Antonio, could you provide a screenshot of the "Zmod(5)" output expected? Which is the output in Sage Notebook?
Comment 14 Antonio Rojas 2016-07-02 21:07:42 UTC
Created attachment 99813 [details]
Output of Zmod(5)
Comment 15 Filipe Saraiva 2016-07-03 00:00:04 UTC
Created attachment 99818 [details]
Output of Zmod(5) in Cantor (Sage backend)
Comment 16 Filipe Saraiva 2016-07-03 00:01:24 UTC
Thanks Antonio, so it is currently fixed in master branch as you can see in attachment 99818 [details].
This fix will be available in Cantor 16.04.3 and 16.08.0
Comment 17 Filipe Saraiva 2016-07-03 00:10:04 UTC
Git commit 1a358899c6c249ee7c093ee8506544eb7a290cab by Filipe Saraiva.
Committed on 03/07/2016 at 00:06.
Pushed by filipesaraiva into branch 'master'.

Import Sage LaTeX macros when the output
is a LaTeX rendered text.
FIXED-IN: 16.08

M  +21   -2    src/backends/sage/sageexpression.cpp

http://commits.kde.org/cantor/1a358899c6c249ee7c093ee8506544eb7a290cab
Comment 18 Filipe Saraiva 2016-07-03 00:12:37 UTC
Git commit abc5d99184c3591e93028476d7f17f7bdb710b09 by Filipe Saraiva.
Committed on 03/07/2016 at 00:09.
Pushed by filipesaraiva into branch 'Applications/16.04'.

Import Sage LaTeX macros when the output
is a LaTeX rendered text.
FIXED-IN: 16.04.3

M  +21   -2    src/backends/sage/sageexpression.cpp

http://commits.kde.org/cantor/abc5d99184c3591e93028476d7f17f7bdb710b09
Comment 19 jackdyson31 2016-07-04 00:17:44 UTC
@Filipe from comment 10:

I understand completely, and thank you for your reply. I wholeheartedly appreciate you cannot of course do all this alone. The fact that Cantor has got this far is tribute to the efforts yourself and all the others who do contribute are putting in.

Yes I would like to help. Starting with decent bug reports is totally ok with me.

I'll add a couple of points as I see them:

1) 10 languages is far too many, let's support a few of them but support them well?
2) The interface basics in Cantor need to be stabilised
3) support for LTS versions - a new install of Kbuntu for every minor bugfix drives users away

As for me, I could contribute to the sage plugin, I have been checking through the code - I am not up to your level with understanding and packaging the everything right now, but if I could get in touch with you, perhaps I can experiment/develop the code and send it to you for approval? I am interested in making sure the LTS backports are as up to date as we can make them and available on the repos. 

I am also interested in adding more sage specific features to the plugin. Sage uses a browser for its notebook, but that approach eats up a lot of memory per notebook - the Cantor solution if developed can be a real alternative where memory is a premium.

I can get in touch with the sage guys as well if results are positive, given that Cantor could become cross platform in the future. Their sagenb project has slowed a bit as they are concentrated on the cloud project. Cantor's plugin could therefore be a way forward for desktop users en masse and cross platform.

All the best for now!