mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-06 00:10:59 +00:00
Fix bug #8305: ^ symbol does not render into upward arrow when using mhchem
The mhchem package treats the caret both as a shorthand for \uparrow or as a superscript operator according to whether it is surrounded by spaces or not. The \ce and \cf insets allow inserting spaces but there is no provision for inserting a space after the caret, which is always considered by LyX as a superscript operator. The solution here is to insert a space after the caret if the superscript is empty or an empty brace inset. Mathed does not allow empty superscripts, so an empty brace has to be inserted when working in LyX. On the other hand, when importing latex code, an empty superscript is retained. This has no effect whatsoever for normal latex code, as a space after the caret is ignored. In any case, the output is only changed if an empty brace inset is used as superscript. Specifically, the output is changed from "^{{}}" to "^ {}".
This commit is contained in:
parent
3a99e351d9
commit
f251e01892
@ -15,6 +15,7 @@
|
|||||||
#include "DispatchResult.h"
|
#include "DispatchResult.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
#include "FuncStatus.h"
|
#include "FuncStatus.h"
|
||||||
|
#include "InsetMathBrace.h"
|
||||||
#include "InsetMathFont.h"
|
#include "InsetMathFont.h"
|
||||||
#include "InsetMathScript.h"
|
#include "InsetMathScript.h"
|
||||||
#include "InsetMathSymbol.h"
|
#include "InsetMathSymbol.h"
|
||||||
@ -547,8 +548,16 @@ void InsetMathScript::write(WriteStream & os) const
|
|||||||
if (hasDown() /*&& down().size()*/)
|
if (hasDown() /*&& down().size()*/)
|
||||||
os << "_{" << down() << '}';
|
os << "_{" << down() << '}';
|
||||||
|
|
||||||
if (hasUp() /*&& up().size()*/)
|
if (hasUp() /*&& up().size()*/) {
|
||||||
os << "^{" << up() << '}';
|
// insert space if up() is empty or an empty brace inset
|
||||||
|
// (see bug 8305)
|
||||||
|
if (os.latex() && (up().size() == 0 ||
|
||||||
|
(up().size() == 1 && up().back()->asBraceInset() &&
|
||||||
|
up().back()->asBraceInset()->cell(0).empty())))
|
||||||
|
os << "^ {}";
|
||||||
|
else
|
||||||
|
os << "^{" << up() << '}';
|
||||||
|
}
|
||||||
|
|
||||||
if (lock_ && !os.latex())
|
if (lock_ && !os.latex())
|
||||||
os << "\\lyxlock ";
|
os << "\\lyxlock ";
|
||||||
|
Loading…
Reference in New Issue
Block a user