]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathScript.cpp
We only support gcc >= 4.9.
[lyx.git] / src / mathed / InsetMathScript.cpp
index 0b82d05c12ed7c86613fed7cfea3bafaec8bec85..c06291e31da6b888834c185b70a19d49b67c3bb3 100644 (file)
@@ -505,13 +505,16 @@ bool InsetMathScript::idxUpDown(Cursor & cur, bool up) const
 }
 
 
-void InsetMathScript::write(WriteStream & os) const
+void InsetMathScript::write(TeXMathStream & os) const
 {
        MathEnsurer ensurer(os);
 
-       if (!nuc().empty())
+       if (!nuc().empty()) {
                os << nuc();
-       else if (os.firstitem())
+               // Avoid double superscript errors (bug 1633)
+               if (os.latex() && hasUp() && nuc().back()->getChar() == '\'')
+                       os << "{}";
+       } else if (os.firstitem())
                LYXERR(Debug::MATHED, "suppressing {} when writing");
        else
                os << "{}";
@@ -526,8 +529,13 @@ void InsetMathScript::write(WriteStream & 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 (lock_ && !os.latex())