- os << "\n\\newcommand{\\" << name << "}";
-
- if (nargs_ > 0 )
- os << "[" << nargs_ << "]";
-
- os << "{";
-
- for (int i = 0; i < nargs_; ++i) {
- args_[i].setExpand(false);
- }
- Write(os, fragile);
- os << "}\n";
-}
-
-
-void MathMacroTemplate::setArgument(MathedArray * a, int i)
-{
- args_[i].setData(*a);
-}
-
-
-void MathMacroTemplate::GetMacroXY(int i, int & x, int & y) const
-{
- args_[i].GetXY(x, y);
-}
-
-
-MathParInset * MathMacroTemplate::getMacroPar(int i) const
-{
- if (i >= 0 && i < nargs_)
- return const_cast<MathParInset *>
- (static_cast<MathParInset const *>(&args_[i]));
- else
- return 0;
-}
-
-
-void MathMacroTemplate::SetMacroFocus(int &idx, int x, int y)
-{
- for (int i = 0; i < nargs_; ++i) {
- if (args_[i].Inside(x, y)) {
- idx = i;
- break;
- }
+ if (os.latex()) {
+ os << "\n\\newcommand{\\" << name_.c_str() << '}';
+ if (numargs_ > 0)
+ os << '[' << numargs_ << ']';
+ os << '{' << cell(0) << "}\n";
+ } else {
+ // writing .lyx
+ os << "\n\\newcommand{\\" << name_.c_str() << '}';
+ if (numargs_ > 0)
+ os << '[' << numargs_ << ']';
+ os << '{' << cell(0) << '}';
+ // write special .tex export only if necessary
+ if (!cell(1).empty())
+ os << "\n{" << cell(1) << '}';