commit 183836dde3a3bb07ab35d604b6cd609142810980
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Sat Sep 6 15:58:48 2025 +0200

    Fixup 5d40b9b779: finer control of primes
    
    Fix cases where primes are forced to appear to the right of
    super/subscripts.
    
    An empty {} will be inserted when a superscript or a prime have been used.
    
    No status.24x entry needed.
    
    (cherry picked from commit fc02eece787262330d1f926dcdffb923cf420bed)
    (cherry picked from commit 148efdf6bb52bcc3fbb03682f49d678ffe34388a)
    (cherry picked from commit 55f10d7f1a9ec6cd8d0e7c8fa453dbb84fcbf3a7)
---
 src/mathed/InsetMathScript.cpp | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/mathed/InsetMathScript.cpp b/src/mathed/InsetMathScript.cpp
index 36c32d5198..da413c7208 100644
--- a/src/mathed/InsetMathScript.cpp
+++ b/src/mathed/InsetMathScript.cpp
@@ -13,6 +13,7 @@
 #include "InsetMathScript.h"
 
 #include "InsetMathBrace.h"
+#include "InsetMathChar.h"
 #include "MathData.h"
 #include "MathStream.h"
 #include "MathSupport.h"
@@ -523,20 +524,19 @@ void InsetMathScript::write(TeXMathStream & os) const
                    (up().size() == 1 && up().back()->asBraceInset() &&
                     up().back()->asBraceInset()->cell(0).empty())))
                        os << "^ {}";
-               else {
+               else
                        os << "^{" << up() << '}';
-                       // Avoid double superscript errors by writing an
-                       // empty group {} when a prime immediately follows
-                       if (os.latex())
-                               os.useBraces(true);
-               }
        }
 
-       if (hasDown() /*&& !down().empty()*/) {
+       if (hasDown() /*&& !down().empty()*/)
                os << "_{" << down() << '}';
-               if (os.latex())
-                       os.useBraces(true);
-       }
+
+       // Avoid double superscript errors by writing an
+       // empty group {} when a prime immediately follows
+       if (os.latex() && (hasUp() ||
+           (hasDown() && !nuc().empty() && nuc().back()->asCharInset() &&
+            nuc().back()->asCharInset()->getChar() == '\'')))
+               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