void MathGridInset::write(std::ostream & os, bool fragile) const
{
for (int row = 0; row < nrows(); ++row) {
- if (row)
- os << " \\\\\n";
for (int col = 0; col < ncols(); ++col) {
- if (col)
- os << " & ";
cell(index(row, col)).write(os, fragile);
+ os << eocString(row);
}
+ os << eolString(row);
}
}
+string MathGridInset::eolString(int row) const
+{
+ if (row == nrows() - 1)
+ return "";
+
+ // make sure an upcoming '[' does not break anything
+ MathArray const & c = cell(index(row + 1, 0));
+ if (c.size() && (*c.begin())->getChar() == '[')
+ return "\\\\[0pt]\n";
+
+ return "\\\\\n";
+}
+
+
+string MathGridInset::eocString(int col) const
+{
+ if (col == ncols() - 1)
+ return "";
+ return " & ";
+}
+
+
void MathGridInset::addRow(int row)
{
rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo());
std::vector<int> idxBetween(int from, int to) const;
protected:
+ /// returns proper 'end of line' code for LaTeX
+ string eolString(int row) const;
+ /// returns proper 'end of column' code for LaTeX
+ string eocString(int col) const;
+
/// row info
std::vector<RowInfo> rowinfo_;
/// column info
bool n = numberedType();
for (int row = 0; row < nrows(); ++row) {
- if (row)
- os << " \\\\\n";
for (int col = 0; col < ncols(); ++col) {
- if (col)
- os << " & ";
+ os << eocString(col);
cell(index(row, col)).write(os, fragile);
}
if (n) {
if (nonum_[row])
os << "\\nonumber ";
}
+ os << eolString(row);
}
footer_write(os);
while (is_.good()) {
unsigned char c = getuchar();
- //lyxerr << "reading byte: '" << c << "' code: " << lexcode[c] << endl;
+ lyxerr << "reading byte: '" << c << "' code: " << lexcode[c] << endl;
if (lexcode[c] == LexNewLine) {
++lineno_;
break;
case LM_TK_NEWLINE:
+ {
+ lexArg('['); // ignore things like \\[5pt] for a while
if (flags & FLAG_NEWLINE) {
flags &= ~FLAG_NEWLINE;
--plevel;
lyxerr[Debug::MATHED]
<< "found newline unexpectedly, array: '" << array << "'\n";
break;
+ }
case LM_TK_PROTECT:
break;