if (!nuc().empty()) {
os << nuc();
- // Avoid double superscript errors (bug #1633)
+ // Avoid double superscript errors (bug 1633)
if (os.latex() && hasUp() && nuc().back()->getChar() == '\'')
os << "{}";
} else if (os.firstitem())
(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())
else if (s[first] == ' ' && ws.textMode())
ws.os() << '\\';
ws.pendingSpace(false);
+ } else if (ws.useBraces()) {
+ if (s[first] == '\'')
+ ws.os() << "{}";
+ ws.useBraces(false);
}
ws.os() << s.substr(first);
int lf = 0;
else if (c == ' ' && ws.textMode())
ws.os() << '\\';
ws.pendingSpace(false);
+ } else if (ws.useBraces()) {
+ if (c == '\'')
+ ws.os() << "{}";
+ ws.useBraces(false);
}
ws.os() << c;
if (c == '\n')
/// writes space if next thing is isalpha()
bool pendingSpace() const { return pendingspace_; }
/// write braces if a space is pending and next char is [
+ /// or when a prime immediately follows a superscript
void useBraces(bool braces);
/// write braces if a space is pending and next char is [
+ /// or when a prime immediately follows a superscript
bool useBraces() const { return usebraces_; }
/// tell whether to write the closing brace of \ensuremath
void pendingBrace(bool brace);
OutputType output_ = wsDefault;
/// do we have a space pending?
bool pendingspace_ = false;
- /// do we have to write braces when a space is pending and [ follows?
+ /// do we have to write braces when a space is pending and [ follows,
+ /// or when a prime immediately follows a superscript?
bool usebraces_ = false;
/// do we have a brace pending?
bool pendingbrace_ = false;