mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Amend [5ed01cd6/lyxgit]
This commit takes into account also the case in which a prime follows a superscript, a case not explicitly mentioned in bug 1633. This case has to be accounted for in a different way. We cannot look ahead when exporting, so we simply tell TeXMathStream to output an empty group if we just output a superscript and a prime comes next.
This commit is contained in:
parent
c05077f2c2
commit
3cf5a71463
@ -511,7 +511,7 @@ void InsetMathScript::write(TeXMathStream & os) const
|
||||
|
||||
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())
|
||||
@ -529,8 +529,13 @@ 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 (lock_ && !os.latex())
|
||||
|
@ -111,6 +111,10 @@ TeXMathStream & operator<<(TeXMathStream & ws, docstring const & s)
|
||||
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;
|
||||
@ -241,6 +245,10 @@ TeXMathStream & operator<<(TeXMathStream & ws, char c)
|
||||
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')
|
||||
|
@ -84,8 +84,10 @@ public:
|
||||
/// 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);
|
||||
@ -128,7 +130,8 @@ private:
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user