+ else if (t.cs() == "cancelto") {
+ MathData ar;
+ parse(ar, FLAG_ITEM, mode);
+ cell->push_back(MathAtom(new InsetMathCancelto(buf)));
+ cell->back().nucleus()->cell(1) = ar;
+ parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
+ }
+
+ else if (t.cs() == "unit") {
+ // Allowed formats \unit[val]{unit}
+ MathData ar;
+ parse(ar, FLAG_OPTION, mode);
+ if (!ar.empty()) {
+ cell->push_back(MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNIT)));
+ cell->back().nucleus()->cell(0) = ar;
+ parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
+ } else {
+ cell->push_back(MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNIT, 1)));
+ parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
+ }
+ }
+
+ else if (t.cs() == "unitfrac") {
+ // Here allowed formats are \unitfrac[val]{num}{denom}
+ MathData ar;
+ parse(ar, FLAG_OPTION, mode);
+ if (!ar.empty()) {
+ cell->push_back(MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNITFRAC, 3)));
+ cell->back().nucleus()->cell(2) = ar;
+ } else {
+ cell->push_back(MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNITFRAC)));
+ }
+ parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
+ parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
+ }
+
+ else if (t.cs() == "cfrac") {
+ // allowed formats are \cfrac[pos]{num}{denom}
+ docstring const arg = getArg('[', ']');
+ //lyxerr << "got so far: '" << arg << "'" << endl;
+ if (arg == "l")
+ cell->push_back(MathAtom(new InsetMathFrac(buf, InsetMathFrac::CFRACLEFT)));
+ else if (arg == "r")
+ cell->push_back(MathAtom(new InsetMathFrac(buf, InsetMathFrac::CFRACRIGHT)));
+ else if (arg.empty() || arg == "c")
+ cell->push_back(MathAtom(new InsetMathFrac(buf, InsetMathFrac::CFRAC)));
+ else {
+ error("found invalid optional argument");
+ break;
+ }
+ parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
+ parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
+ }
+
+ else if (t.cs() == "sideset") {
+ // Here allowed formats are \sideset{_{bl}^{tl}}{_{br}^{tr}}{operator}
+ MathData ar[2];
+ InsetMathScript * script[2] = {0, 0};
+ for (int i = 0; i < 2; ++i) {
+ parse(ar[i], FLAG_ITEM, mode);
+ if (ar[i].size() == 1)
+ script[i] = ar[i][0].nucleus()->asScriptInset();
+ }
+ bool const hasscript[2] = {script[0] ? true : false, script[1] ? true : false};
+ cell->push_back(MathAtom(new InsetMathSideset(buf, hasscript[0], hasscript[1])));
+ if (hasscript[0]) {
+ if (script[0]->hasDown())
+ cell->back().nucleus()->cell(1) = script[0]->down();
+ if (script[0]->hasUp())
+ cell->back().nucleus()->cell(2) = script[0]->up();
+ } else
+ cell->back().nucleus()->cell(1) = ar[0];
+ if (hasscript[1]) {
+ if (script[1]->hasDown())
+ cell->back().nucleus()->cell(2 + hasscript[0]) = script[1]->down();
+ if (script[1]->hasUp())
+ cell->back().nucleus()->cell(3 + hasscript[0]) = script[1]->up();
+ } else
+ cell->back().nucleus()->cell(2 + hasscript[0]) = ar[1];
+ parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
+ }
+
+ else if (t.cs() == "stackrel") {
+ // Here allowed formats are \stackrel[subscript]{superscript}{operator}
+ MathData ar;
+ parse(ar, FLAG_OPTION, mode);
+ cell->push_back(MathAtom(new InsetMathStackrel(buf, !ar.empty())));
+ if (!ar.empty())
+ cell->back().nucleus()->cell(2) = ar;