static InsetLabel * dummy_pointer = 0;
InsetMathHull::InsetMathHull(Buffer * buf)
- : InsetMathGrid(buf, 1, 1), type_(hullNone), numbered_(1, false),
+ : InsetMathGrid(buf, 1, 1), type_(hullNone), numbered_(1, true),
label_(1, dummy_pointer), preview_(new RenderPreview(this))
{
//lyxerr << "sizeof InsetMath: " << sizeof(InsetMath) << endl;
InsetMathHull::InsetMathHull(Buffer * buf, HullType type)
- : InsetMathGrid(buf, getCols(type), 1), type_(type), numbered_(1, false),
+ : InsetMathGrid(buf, getCols(type), 1), type_(type), numbered_(1, true),
label_(1, dummy_pointer), preview_(new RenderPreview(this))
{
buffer_ = buf;
break;
default:
- os << "\\begin{unknown" << star(n) << '}';
+ os << "\\begin{unknown" << star(n) << "}\n";
break;
}
}
case hullEquation:
if (n)
- os << "\\end{equation" << star(n) << "}\n";
+ os << "\n\\end{equation" << star(n) << "}\n";
else
- os << "\\]\n";
+ os << "\n\\]\n";
break;
case hullEqnArray:
case hullXAlignAt:
case hullGather:
case hullMultline:
- os << "\\end{" << hullName(type_) << star(n) << "}\n";
+ os << "\n\\end{" << hullName(type_) << star(n) << "}\n";
break;
case hullXXAlignAt:
- os << "\\end{" << hullName(type_) << "}\n";
+ os << "\n\\end{" << hullName(type_) << "}\n";
break;
case hullRegexp:
break;
default:
- os << "\\end{unknown" << star(n) << '}';
+ os << "\n\\end{unknown" << star(n) << "}\n";
break;
}
}
}
}
*this = InsetMathHull(buffer_, hullSimple);
- if (label)
- label_[0] = label;
+ label_[0] = label;
cell(0) = ar;
setDefaults();
}
numbered(0, false);
} else {
setType(hullEquation);
+ numbered(0, label_[0] ? true : false);
mutate(newtype);
}
}
}
-docstring InsetMathHull::eolString(row_type row, bool fragile, bool last_eoln) const
+docstring InsetMathHull::eolString(row_type row, bool fragile, bool latex,
+ bool last_eoln) const
{
docstring res;
if (numberedType()) {
- if (label_[row] && numbered_[row])
- res += "\\label{" +
- escape(label_[row]->getParam("name")) + '}';
+ if (label_[row] && numbered_[row]) {
+ docstring const name =
+ latex ? escape(label_[row]->getParam("name"))
+ : label_[row]->getParam("name");
+ res += "\\label{" + name + '}';
+ }
if (!numbered_[row] && (type_ != hullMultline))
res += "\\nonumber ";
}
// Never add \\ on the last empty line of eqnarray and friends
last_eoln = false;
- return res + InsetMathGrid::eolString(row, fragile, last_eoln);
+ return res + InsetMathGrid::eolString(row, fragile, latex, last_eoln);
}
InsetCommandParams p(LABEL_CODE);
p["name"] = cmd.argument().empty() ? old_label : cmd.argument();
- string const data = InsetCommand::params2string("label", p);
+ string const data = InsetCommand::params2string(p);
if (cmd.argument().empty())
cur.bv().showDialog("label", data);
string const name = cmd.getArg(0);
if (name == "label") {
InsetCommandParams p(LABEL_CODE);
- InsetCommand::string2params(name, to_utf8(cmd.argument()), p);
+ InsetCommand::string2params(to_utf8(cmd.argument()), p);
docstring str = p["name"];
cur.recordUndoInset();
row_type const r = (type_ == hullMultline) ? nrows() - 1 : cur.row();