diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 27ac62a226..65b4f661ec 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -54,6 +54,7 @@ following hack as starting point to write some macros: #include "math_parinset.h" #include "math_rootinset.h" #include "math_scriptinset.h" +#include "math_splitinset.h" #include "math_sqrtinset.h" #include "math_support.h" #include "math_tabularinset.h" @@ -1097,16 +1098,22 @@ void Parser::parse1(MathGridInset & grid, unsigned flags, parse2(cell->back(), FLAG_END, MathInset::TEXT_MODE, false); } - else if (name == "split" || name == "cases" || - name == "gathered" || name == "aligned") { + else if (name == "split" || name == "cases") { cell->push_back(createMathInset(name)); parse2(cell->back(), FLAG_END, mode, false); } + else if (name == "gathered" || name == "aligned") { + string const valign = parse_verbatim_option() + 'c'; + cell->push_back(MathAtom(new MathSplitInset(name, valign[0]))); + parse2(cell->back(), FLAG_END, mode, false); + } + else if (name == "alignedat") { + string const valign = parse_verbatim_option() + 'c'; // ignore this for a while getArg('{', '}'); - cell->push_back(createMathInset(name)); + cell->push_back(MathAtom(new MathSplitInset(name, valign[0]))); parse2(cell->back(), FLAG_END, mode, false); } diff --git a/src/mathed/math_splitinset.C b/src/mathed/math_splitinset.C index 0d2a4f7f07..44938c79df 100644 --- a/src/mathed/math_splitinset.C +++ b/src/mathed/math_splitinset.C @@ -29,10 +29,9 @@ using std::string; using std::auto_ptr; -MathSplitInset::MathSplitInset(string const & name) - : MathGridInset(1, 1), name_(name) +MathSplitInset::MathSplitInset(string const & name, char valign) + : MathGridInset(1, 1, valign, string()), name_(name) { - setDefaults(); } @@ -89,6 +88,8 @@ void MathSplitInset::write(WriteStream & ws) const if (ws.fragile()) ws << "\\protect"; ws << "\\begin{" << name_ << '}'; + if (name_ != "split" && valign() != 'c') + ws << '[' << valign() << ']'; if (name_ == "alignedat") ws << '{' << static_cast((ncols() + 1)/2) << '}'; MathGridInset::write(ws); diff --git a/src/mathed/math_splitinset.h b/src/mathed/math_splitinset.h index db980147d1..2ffbcbb379 100644 --- a/src/mathed/math_splitinset.h +++ b/src/mathed/math_splitinset.h @@ -18,7 +18,7 @@ class MathSplitInset : public MathGridInset { public: /// - explicit MathSplitInset(std::string const & name); + explicit MathSplitInset(std::string const & name, char valign = 'c'); /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/status.14x b/status.14x index 49ecec73ee..0fe422c492 100644 --- a/status.14x +++ b/status.14x @@ -33,6 +33,8 @@ What's new * Document Input/Output +- Parse the optional argument of the AMS math environments aligned, gathered + and alignedat. * User Interface: