commit f6e37cc72f0a28e67d3ef468d3b4a2ff6f09fcc0
Author: Enrico Forestieri <[email protected]>
Date: Thu May 1 09:37:09 2025 +0200
Fix display of matrix output from maxima
Part of #13178.
---
src/mathed/MathExtern.cpp | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index 9316adfabe..c4291f7cb5 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -1166,6 +1166,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
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs