commit f284b58838537ae635814999b465b71b7831f8c5
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.
---
 src/mathed/InsetMathScript.cpp | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp
index b30e3424af..ef3fabe30b 100644
--- a/src/mathed/InsetMathScript.cpp
+++ b/src/mathed/InsetMathScript.cpp
@@ -508,19 +508,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)
@@ -537,6 +531,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 ";
 }
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to