diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index b1108f6d12..7de23595a1 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -863,6 +863,7 @@ void MathGridInset::write(WriteStream & os) const { for (row_type row = 0; row < nrows(); ++row) { os << verboseHLine(rowinfo_[row].lines_); + // don't write & and empty cells at end of line for (col_type col = 0; col < ncols(); ++col) os << cell(index(row, col)) << eocString(col); os << eolString(row, os.fragile()); diff --git a/src/mathed/math_gridinset.h b/src/mathed/math_gridinset.h index 79c8ad45fc..cef894035a 100644 --- a/src/mathed/math_gridinset.h +++ b/src/mathed/math_gridinset.h @@ -216,9 +216,9 @@ protected: /// returns y offset of cell compared to inset int cellYOffset(idx_type idx) const; /// returns proper 'end of line' code for LaTeX - string eolString(row_type row, bool fragile = false) const; + virtual string eolString(row_type row, bool fragile = false) const; /// returns proper 'end of column' code for LaTeX - string eocString(col_type col) const; + virtual string eocString(col_type col) const; /// extract number of columns from alignment string col_type guessColumns(string const & halign) const; /// splits cells and shifts right part to the next cell diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 8b1c556c5c..039eef924c 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -607,24 +607,23 @@ void MathHullInset::mutate(string const & newtype) } +string MathHullInset::eolString(row_type row, bool fragile) const +{ + string res; + if (numberedType()) { + if (!label_[row].empty()) + res += "\\label{" + label_[row] + "}"; + if (nonum_[row]) + res += "\\nonumber "; + } + return res + MathGridInset::eolString(row, fragile); +} + + void MathHullInset::write(WriteStream & os) const { header_write(os); - - bool n = numberedType(); - - for (row_type row = 0; row < nrows(); ++row) { - for (col_type col = 0; col < ncols(); ++col) - os << cell(index(row, col)) << eocString(col); - if (n) { - if (!label_[row].empty()) - os << "\\label{" << label_[row] << "}"; - if (nonum_[row]) - os << "\\nonumber "; - } - os << eolString(row); - } - + MathGridInset::write(os); footer_write(os); } diff --git a/src/mathed/math_hullinset.h b/src/mathed/math_hullinset.h index b45c4f8872..1c84e36ff6 100644 --- a/src/mathed/math_hullinset.h +++ b/src/mathed/math_hullinset.h @@ -89,6 +89,10 @@ public: /// void infoize(std::ostream & os) const; +protected: + /// + string eolString(row_type row, bool fragile) const; + private: /// void setType(string const & type);