# Fix maxima LaTeX output for matricsClosedPublicActions

Authored by sirgienko on May 5 2018, 7:44 PM.

# Details

Reviewers
 asemke
Group Reviewers
 Cantor
Commits
R55:220b864d6ac2: Fix maxima LaTeX output for matrics
R55:42687f6542db: Fix maxima LaTeX output for matrics
Summary

Maxima tex output generate old code for matrixs(\pmatrix{...} instead of \begin{pmatrix}...\end{pmatrix}). This commit fix it by redifinition a tex function for matrixs. Maybe, it fix bug 387303, but bug report author haven't given a lot of information about this bug and where exectly is the bug.

Test Plan
1. Run maxima and write matrix([1,2],[3,4]) and check, that there aren't LaTeX output
2. Apply the patch
3. Check, that we have LaTeX matrix in the output

# Diff Detail

Repository
R55 Cantor
Lint
 Automatic diff as part of commit; lint not applicable.
Unit
 Automatic diff as part of commit; unit tests not applicable.
sirgienko created this revision.May 5 2018, 7:44 PM
Restricted Application added a project: KDE Edu. May 5 2018, 7:44 PM
Restricted Application added a subscriber: KDE Edu.
sirgienko requested review of this revision.May 5 2018, 7:44 PM

@asemke, I'm confused: https://bugs.kde.org/show_bug.cgi?id=387303 in general component, but I found pmatrix only in maxima backend (and it maxima bug). So, I don't sure, that this fix 387303 bug.

asemke added a comment.May 5 2018, 8:07 PM

@asemke, I'm confused: https://bugs.kde.org/show_bug.cgi?id=387303 in general component, but I found pmatrix only in maxima backend (and it maxima bug). So, I don't sure, that this fix 387303 bug.

my understanding of BUG 387303 is that during the "Export to LaTeX" (available in the main menu "File") wrong/old latex syntax is used for matrices. Here src/xslt/latex.xsl is used and my first guess was to add here a proper transformation rule. But you have also a valid point here with rendering of matrix(...) in maxima and most probably in Sage. I'll check your patch.

@asemke, I'm confused: https://bugs.kde.org/show_bug.cgi?id=387303 in general component, but I found pmatrix only in maxima backend (and it maxima bug). So, I don't sure, that this fix 387303 bug.

my understanding of BUG 387303 is that during the "Export to LaTeX" (available in the main menu "File") wrong/old latex syntax is used for matrices. Here src/xslt/latex.xsl is used and my first guess was to add here a proper transformation rule. But you have also a valid point here with rendering of matrix(...) in maxima and most probably in Sage. I'll check your patch.

As I understad, latex.xsl is template file for html worksheet output, right? But we don't have special html output for matrixs, aren't it? As I see, matrixs from different backends returned as plain text with '\n' (octave, python2, maybe python3 (import bug, can't test), qalqulate (not sure, that output is valid, but it still plain text), scilab) or latexentry (maxima). I haven't tested sage (broken for me), R (haven't output for matrix), Julia (broken too, after upgrade to 18.04), KAlgebra (don't know, how write matrix).
So, if we haven't special tags, we can't specify rule for matrixs, right?

asemke added a comment.May 6 2018, 4:45 PM

@asemke, I'm confused: https://bugs.kde.org/show_bug.cgi?id=387303 in general component, but I found pmatrix only in maxima backend (and it maxima bug). So, I don't sure, that this fix 387303 bug.

my understanding of BUG 387303 is that during the "Export to LaTeX" (available in the main menu "File") wrong/old latex syntax is used for matrices. Here src/xslt/latex.xsl is used and my first guess was to add here a proper transformation rule. But you have also a valid point here with rendering of matrix(...) in maxima and most probably in Sage. I'll check your patch.

As I understad, latex.xsl is template file for html worksheet output, right? But we don't have special html output for matrixs, aren't it? As I see, matrixs from different backends returned as plain text with '\n' (octave, python2, maybe python3 (import bug, can't test), qalqulate (not sure, that output is valid, but it still plain text), scilab) or latexentry (maxima). I haven't tested sage (broken for me), R (haven't output for matrix), Julia (broken too, after upgrade to 18.04), KAlgebra (don't know, how write matrix).
So, if we haven't special tags, we can't specify rule for matrixs, right?

This xsl file is used in Worksheet::saveLatex(). So, it's used when the user exports the xml-content of the worksheet to a tex file. Let's check this feature later. Your fix addresses another issue and with this fix I see now nicely formatted matrices in the output. Please help me to understand your comment "Fix bug with old matrix tex output in maxima, until it is fixed". Until what is fixed? Where does this tex-matrix function come from? Do you expect this to be fixed somewhere in maxima and to produce the output always with \begin{pmatrix} ... \end{pmatrix}?

Please help me to understand your comment "Fix bug with old matrix tex output in maxima, until it is fixed". Until what is fixed? Where does this tex-matrix function come from? Do you expect this to be fixed somewhere in maxima and to produce the output always with \begin{pmatrix} ... \end{pmatrix}?

Maxima defines function for tex output. Function tex-matrix defined in maxima source file mactex.list:662. It looks like this:

(defun tex-matrix(x l r) ;;matrix looks like ((mmatrix)((mlist) a b) ...)
(append l ("\\pmatrix{")
(mapcan #'(lambda(y)
(tex-list (cdr y) nil (list "\\cr ") "&"))
(cdr x))
'("}") r))

As you see, the function generate outdated tex output. And I think that for modern LaTeX it should update to '\begin{pmatrix}...\end{pmatrix}. So, if I push this changes to maxima and the changes be accepted, function tex-matrix redifinition in cantor-initmaxima.lisp can be removed.

asemke added a comment.May 6 2018, 5:06 PM

Please help me to understand your comment "Fix bug with old matrix tex output in maxima, until it is fixed". Until what is fixed? Where does this tex-matrix function come from? Do you expect this to be fixed somewhere in maxima and to produce the output always with \begin{pmatrix} ... \end{pmatrix}?

Maxima defines function for tex output. Function tex-matrix defined in maxima source file mactex.list:662. It looks like this:

(defun tex-matrix(x l r) ;;matrix looks like ((mmatrix)((mlist) a b) ...)
(append l ("\\pmatrix{")
(mapcan #'(lambda(y)
(tex-list (cdr y) nil (list "\\cr ") "&"))
(cdr x))
'("}") r))

As you see, the function generate outdated tex output. And I think that for modern LaTeX it should update to '\begin{pmatrix}...\end{pmatrix}. So, if I push this changes to maxima and the changes be accepted, function tex-matrix redifinition in cantor-initmaxima.lisp can be removed.

Got it. Thanks for the clarification.

asemke accepted this revision.May 6 2018, 5:06 PM
This revision is now accepted and ready to land.May 6 2018, 5:06 PM
This revision was automatically updated to reflect the committed changes.