#include "frontends/Painter.h"
#include "support/lassert.h"
+#include "support/lstrings.h"
using namespace std;
Changer dummy = mi.base.changeEnsureMath();
Dimension dimr;
if (root) {
- Changer script = mi.base.font.changeStyle(FONT_STYLE_SCRIPTSCRIPT);
+ Changer script = mi.base.font.changeStyle(SCRIPTSCRIPT_STYLE);
// make sure that the dim is high enough for any character
root->metrics(mi, dimr, false);
}
*/
int const t = mi.base.solidLineThickness();
int const x_height = mathed_font_x_height(mi.base.font);
- int const phi = (mi.base.font.style() == FONT_STYLE_DISPLAY) ? x_height : t;
+ int const phi = (mi.base.font.style() == DISPLAY_STYLE) ? x_height : t;
// first part is the spacing, second part is the line width
// itself, and last one is the spacing above.
int const space_above = (t + phi / 4) + t + t;
int const a = dim.ascent();
int const d = dim.descent();
int const t = pi.base.solidLineThickness();
- Dimension const dimn = nucleus.dimension(*pi.base.bv);
+ Dimension const & dimn = nucleus.dimension(*pi.base.bv);
// the width of the left part of the root
int const wl = dim.width() - dimn.width();
// the "exponent"
if (root) {
- Changer script = pi.base.font.changeStyle(FONT_STYLE_SCRIPTSCRIPT);
- Dimension const dimr = root->dimension(*pi.base.bv);
+ Changer script = pi.base.font.changeStyle(SCRIPTSCRIPT_STYLE);
+ Dimension const & dimr = root->dimension(*pi.base.bv);
int const root_offset = wl - 3 * w / 8 - dimr.width();
root->draw(pi, x + root_offset, y + (d - a)/2);
}
}
-void InsetMathRoot::write(WriteStream & os) const
+void InsetMathRoot::write(TeXMathStream & os) const
{
MathEnsurer ensurer(os);
- os << "\\sqrt[" << cell(1) << "]{" << cell(0) << '}';
+ if (os.latex() && !cell(1).empty() && !cell(1).front()->asBraceInset()
+ && support::contains(asString(cell(1)), '['))
+ os << "\\sqrt[{" << cell(1) << "}]{" << cell(0) << '}';
+ else
+ os << "\\sqrt[" << cell(1) << "]{" << cell(0) << '}';
}
bool InsetMathRoot::idxUpDown(Cursor & cur, bool up) const
{
- Cursor::idx_type const target = up; //up ? 1 : 0;
+ idx_type const target = up; //up ? 1 : 0;
if (cur.idx() == target)
return false;
cur.idx() = target;
}
-void InsetMathRoot::mathmlize(MathStream & os) const
+void InsetMathRoot::mathmlize(MathMLStream & ms) const
{
- os << MTag("mroot") << cell(0) << cell(1) << ETag("mroot");
+ ms << MTag("mroot") << cell(0) << cell(1) << ETag("mroot");
}