commit c38d2035c799482581c252bd19e3e76d0d028748
Author: Enrico Forestieri <for...@lyx.org>
Date:   Thu May 1 09:37:09 2025 +0200

    Fix display of matrix output from maxima
    
    Part of #13178.
    
    (cherry picked from commit f6e37cc72f0a28e67d3ef468d3b4a2ff6f09fcc0)
---
 src/mathed/MathExtern.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index ac9ef931a7..ba5405a812 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -1168,6 +1168,21 @@ namespace {
                        return MathData(nullptr);
 
                out = subst(subst(tmp[1], "\\>", string()), "{\\it ", 
"\\mathit{");
+
+               // When returning a matrix, maxima produces a latex snippet
+               // for using one of the two constructs "\pmatrix{...}" or
+               // "\begin{pmatrix}...\end{pmatrix}" depending on whether
+               // the macro \endpmatrix is defined (e.g. by amsmath) or not.
+               // However, our math parser cannot cope with this latex
+               // snippet. So, simply retain the \begin{}...\end{} version.
+               if (out.find("\\ifx\\endpmatrix\\undefined") != string::npos) {
+                       out = subst(subst(subst(subst(out,
+                               "\\ifx\\endpmatrix\\undefined", string()),
+                               "\\pmatrix{\\else\\begin{pmatrix}\\fi", 
"\\begin{pmatrix}"),
+                               "}\\else\\end{pmatrix}\\fi", "\\end{pmatrix}"),
+                               "\\cr", "\\\\");
+               }
+
                lyxerr << "output: '" << out << "'" << endl;
 
                // Ugly code that tries to make the result prettier
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to