}
-docstring InsetMathGrid::eolString(row_type row, bool fragile) const
+docstring InsetMathGrid::eolString(row_type row, bool fragile, bool last_eoln) const
{
docstring eol;
}
// only add \\ if necessary
- if (eol.empty() && row + 1 == nrows())
+ if (eol.empty() && row + 1 == nrows() && (nrows() == 1 || !last_eoln))
return docstring();
return (fragile ? "\\protect\\\\" : "\\\\") + eol;
// unless there are vertical lines
col_type lastcol = 0;
bool emptyline = true;
- for (col_type col = beg_col; col < end_col; ++col)
- if (!cell(index(row, col)).empty()
- || colinfo_[col + 1].lines_) {
+ bool last_eoln = true;
+ for (col_type col = beg_col; col < end_col; ++col) {
+ bool const empty_cell = cell(index(row, col)).empty();
+ if (!empty_cell)
+ last_eoln = false;
+ if (!empty_cell || colinfo_[col + 1].lines_) {
lastcol = col + 1;
emptyline = false;
}
+ }
for (col_type col = beg_col; col < lastcol; ++col) {
os << cell(index(row, col));
if (os.pendingBrace())
ModeSpecifier specifier(os, TEXT_MODE);
os << eocString(col, lastcol);
}
- eol = eolString(row, os.fragile());
+ eol = eolString(row, os.fragile(), last_eoln);
os << eol;
// append newline only if line wasn't completely empty
// and the formula is not written on a single line
/// returns y offset of cell compared to inset
int cellYOffset(idx_type idx) const;
/// returns proper 'end of line' code for LaTeX
- virtual docstring eolString(row_type row, bool fragile) const;
+ virtual docstring eolString(row_type row, bool fragile, bool last_eoln) const;
/// returns proper 'end of column' code for LaTeX
virtual docstring eocString(col_type col, col_type lastcol) const;
/// splits cells and shifts right part to the next cell
}
-docstring InsetMathHull::eolString(row_type row, bool fragile) const
+docstring InsetMathHull::eolString(row_type row, bool fragile, bool last_eoln) const
{
docstring res;
if (numberedType()) {
if (nonum_[row] && (type_ != hullMultline))
res += "\\nonumber ";
}
- return res + InsetMathGrid::eolString(row, fragile);
+ // Never add \\ on the last empty line of eqnarray and friends
+ last_eoln = false;
+ return res + InsetMathGrid::eolString(row, fragile, last_eoln);
}
bool getStatus(Cursor & cur, FuncRequest const & cmd,
FuncStatus & status) const;
///
- docstring eolString(row_type row, bool fragile) const;
+ docstring eolString(row_type row, bool fragile, bool last_eoln) const;
private:
virtual Inset * clone() const;
// probably need to refine this test.
// Right now we only have to test for
// single line hull insets.
- if (grid.nrows() > 1)
+ if (grid.nrows() > 1 && name == "array")
delEmptyLastRow(grid);
return success_;
}