commit 5d40b9b77951cdd6a28ec94765288932695fa36c
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Tue Jun 24 13:59:08 2025 +0200

    Output superscripts before subscripts
    
    This is useful when using primes. Indeed, in math mode, `'` is
    transformed by LaTeX to `^{\prime}` and merged with the next
    superscript if there is one.
    
    Therefore `$x'^2_3$` compiles whereas the original output `$x'_3^2$`
    did not.
    
    Fixes bug #13004.
    
    (cherry picked from commit f284b58838537ae635814999b465b71b7831f8c5)
---
 src/mathed/InsetMathScript.cpp | 16 ++++++++--------
 status.24x                     |  3 +++
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp
index 6ccaaaa840..36c32d5198 100644
--- a/src/mathed/InsetMathScript.cpp
+++ b/src/mathed/InsetMathScript.cpp
@@ -509,19 +509,13 @@ void InsetMathScript::write(TeXMathStream & os) const
 {
        MathEnsurer ensurer(os);
 
-       if (!nuc().empty()) {
+       if (!nuc().empty())
                os << nuc();
-               // Avoid double superscript errors (bug 1633)
-               if (os.latex() && hasUp() && nuc().back()->getChar() == '\'')
-                       os << "{}";
-       } else if (os.firstitem())
+       else if (os.firstitem())
                LYXERR(Debug::MATHED, "suppressing {} when writing");
        else
                os << "{}";
 
-       if (hasDown() /*&& !down().empty()*/)
-               os << "_{" << down() << '}';
-
        if (hasUp() /*&& !up().empty()*/) {
                // insert space if up() is empty or an empty brace inset
                // (see bug 8305)
@@ -538,6 +532,12 @@ void InsetMathScript::write(TeXMathStream & os) const
                }
        }
 
+       if (hasDown() /*&& !down().empty()*/) {
+               os << "_{" << down() << '}';
+               if (os.latex())
+                       os.useBraces(true);
+       }
+
        if (lock_ && !os.latex())
                os << "\\lyxlock ";
 }
diff --git a/status.24x b/status.24x
index 489f797a3f..5d10b8ad32 100644
--- a/status.24x
+++ b/status.24x
@@ -47,6 +47,9 @@ What's new
 
 - Fix check of broken cross-references (false negatives).
 
+- Fix LaTeX output of formulas with a prime, a superscript and a subscripi 
+  (bug 13004).
+
 
 * USER INTERFACE
 
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to