lyxpreamble += oss.str();
}
- // this might be useful...
- lyxpreamble += "\n\\makeatletter\n";
+ // only add \makeatletter and \makeatother when actually needed
+ bool makeatletter = false;
// Some macros LyX will need
docstring tmppreamble(from_ascii(features.getMacros()));
if (!tmppreamble.empty()) {
+ if (!makeatletter) {
+ lyxpreamble += "\n\\makeatletter\n";
+ makeatletter = true;
+ }
lyxpreamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
"LyX specific LaTeX commands.\n"
+ tmppreamble + '\n';
// the text class specific preamble
tmppreamble = features.getTClassPreamble();
if (!tmppreamble.empty()) {
+ if (!makeatletter) {
+ lyxpreamble += "\n\\makeatletter\n";
+ makeatletter = true;
+ }
lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
"Textclass specific LaTeX commands.\n"
+ tmppreamble + '\n';
/* the user-defined preamble */
if (!preamble.empty()) {
+ if (!makeatletter) {
+ lyxpreamble += "\n\\makeatletter\n";
+ makeatletter = true;
+ }
// FIXME UNICODE
lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
"User specified LaTeX commands.\n"
}
}
- if (!bullets_def.empty())
+ if (!bullets_def.empty()) {
+ if (!makeatletter) {
+ lyxpreamble += "\n\\makeatletter\n";
+ makeatletter = true;
+ }
lyxpreamble += bullets_def + "}\n\n";
+ }
- lyxpreamble += "\\makeatother\n\n";
+ if (makeatletter)
+ lyxpreamble += "\\makeatother\n\n";
int const nlines =
int(count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));