OK for trunk? - Martin
Index: src/mathed/InsetMathFrac.h =================================================================== --- src/mathed/InsetMathFrac.h (revision 20193) +++ src/mathed/InsetMathFrac.h (working copy) @@ -27,7 +27,8 @@ FRAC, OVER, ATOP, - NICEFRAC + NICEFRAC, + UNITFRAC }; /// Index: src/mathed/MathFactory.cpp =================================================================== --- src/mathed/MathFactory.cpp (revision 20193) +++ src/mathed/MathFactory.cpp (working copy) @@ -370,6 +370,8 @@ return MathAtom(new InsetMathFrac(InsetMathFrac::OVER)); if (s == "nicefrac") return MathAtom(new InsetMathFrac(InsetMathFrac::NICEFRAC)); + if (s == "unitfrac") + return MathAtom(new InsetMathFrac(InsetMathFrac::UNITFRAC)); //if (s == "infer") // return MathAtom(new MathInferInset); if (s == "atop") Index: src/mathed/InsetMathFrac.cpp =================================================================== --- src/mathed/InsetMathFrac.cpp (revision 20193) +++ src/mathed/InsetMathFrac.cpp (working copy) @@ -48,9 +48,10 @@ bool InsetMathFrac::metrics(MetricsInfo & mi, Dimension & dim) const { FracChanger dummy(mi.base); + ShapeChanger dummy2(mi.base.font, Font::UP_SHAPE); cell(0).metrics(mi); cell(1).metrics(mi); - if (kind_ == NICEFRAC) { + if (kind_ == NICEFRAC || kind_ == UNITFRAC) { dim.wid = cell(0).width() + cell(1).width() + 5; dim.asc = cell(0).height() + 5; dim.des = cell(1).height() - 5; @@ -72,7 +73,8 @@ setPosCache(pi, x, y); int m = x + dim_.wid / 2; FracChanger dummy(pi.base); - if (kind_ == NICEFRAC) { + ShapeChanger dummy2(pi.base.font, Font::UP_SHAPE); + if (kind_ == NICEFRAC || kind_ == UNITFRAC) { cell(0).draw(pi, x + 2, y - cell(0).descent() - 5); cell(1).draw(pi, x + cell(0).width() + 5, @@ -111,7 +113,7 @@ cell(0).drawT(pain, m - cell(0).width() / 2, y - cell(0).descent() - 1); cell(1).drawT(pain, m - cell(1).width() / 2, y + cell(1).ascent()); // ASCII art: ignore niceties - if (kind_ == FRAC || kind_ == OVER || kind_ == NICEFRAC) + if (kind_ == FRAC || kind_ == OVER || kind_ == NICEFRAC || kind_ == UNITFRAC) pain.horizontalLine(x, y, dim_.width()); } @@ -128,6 +130,7 @@ break; case FRAC: case NICEFRAC: + case UNITFRAC: InsetMathNest::write(os); break; } @@ -143,6 +146,8 @@ return from_ascii("over"); case NICEFRAC: return from_ascii("nicefrac"); + case UNITFRAC: + return from_ascii("unitfrac"); case ATOP: return from_ascii("atop"); } @@ -183,7 +188,9 @@ void InsetMathFrac::validate(LaTeXFeatures & features) const { - if (kind_ == NICEFRAC) + if (kind_ == UNITFRAC) + features.require("units"); + else if (kind_ == NICEFRAC) features.require("nicefrac"); InsetMathNest::validate(features); } Index: src/LaTeXFeatures.cpp =================================================================== --- src/LaTeXFeatures.cpp (revision 20193) +++ src/LaTeXFeatures.cpp (working copy) @@ -406,6 +406,7 @@ "fancybox", "calc", "nicefrac", + "units", "tipa", "framed", "pdfcolmk", Index: lib/ui/stdtoolbars.inc =================================================================== --- lib/ui/stdtoolbars.inc (revision 20175) +++ lib/ui/stdtoolbars.inc (working copy) @@ -273,7 +273,8 @@ Toolbar "frac-square" "Fractions" Item "Standard \\frac" "math-insert \frac" Item "No hor. line \\atop" "math-insert \atop" - Item "Nice \\nicefrac" "math-insert \nicefrac" + Item "Nice (3/4) \\nicefrac" "math-insert \nicefrac" + Item "Units (km/h) \\unitfrac" "math-insert \unitfrac" Item "Text frac (amsmath) \\tfrac" "math-insert \tfrac" Item "Display frac (amsmath) \\dfrac" "math-insert \dfrac" Item "Binomial \\choose" "math-insert \choose"