// calculate new metrics according to display mode
if (d->displayMode_ == DISPLAY_INIT || d->displayMode_ == DISPLAY_INTERACTIVE_INIT) {
+ Changer dummy = mi.base.changeFontSet("lyxtex");
mathed_string_dim(mi.base.font, from_ascii("\\") + name(), dim);
} else if (d->displayMode_ == DISPLAY_UNFOLDED) {
+ Changer dummy = mi.base.changeFontSet("lyxtex");
cell(0).metrics(mi, dim);
Dimension bsdim;
mathed_string_dim(mi.base.font, from_ascii("\\"), bsdim);
} else {
LBUFERR(d->macro_);
+ Changer dummy = (currentMode() == TEXT_MODE)
+ ? mi.base.font.changeShape(UP_SHAPE)
+ : Changer();
+
// calculate metrics, hoping that all cells are seen
d->macro_->lock();
d->expanded_.metrics(mi, dim);
++pi.base.macro_nesting;
bool drawBox = lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_INLINE_BOX;
- bool upshape = currentMode() == TEXT_MODE;
- Changer dummy = pi.base.font.changeShape(upshape ? UP_SHAPE
- : pi.base.font.shape());
+ Changer dummy = (currentMode() == TEXT_MODE)
+ ? pi.base.font.changeShape(UP_SHAPE)
+ : Changer();
// warm up cells
for (size_t i = 0; i < nargs(); ++i)
// we should be ok to continue even if this fails.
LATTEST(d->macro_);
+ // We may already be in the argument of a macro
+ bool const inside_macro = os.insideMacro();
+ os.insideMacro(true);
+
+ // Enclose in braces to avoid latex errors with xargs if we have
+ // optional arguments and are in the optional argument of a macro
+ if (d->optionals_ && inside_macro)
+ os << '{';
+
// Always protect macros in a fragile environment
if (os.fragile())
os << "\\protect";
first = false;
}
- // add space if there was no argument
- if (first)
+ // Close the opened brace or add space if there was no argument
+ if (d->optionals_ && inside_macro)
+ os << '}';
+ else if (first)
os.pendingSpace(true);
+
+ os.insideMacro(inside_macro);
}