]> git.lyx.org Git - features.git/commitdiff
Only add \makeatletter and \makeatother to the preamble when actually needed
authorEnrico Forestieri <forenr@lyx.org>
Mon, 31 Mar 2008 01:26:57 +0000 (01:26 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Mon, 31 Mar 2008 01:26:57 +0000 (01:26 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24068 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferParams.cpp

index 43141b46e199df0333736f10b8b1de499adf230f..b79ca7357c9846f83f659b6271d90efceb16824c 100644 (file)
@@ -1302,13 +1302,17 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                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';
@@ -1317,6 +1321,10 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
        // 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';
@@ -1324,6 +1332,10 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
 
        /* the user-defined preamble */
        if (!preamble.empty()) {
+               if (!makeatletter) {
+                       lyxpreamble += "\n\\makeatletter\n";
+                       makeatletter = true;
+               }
                // FIXME UNICODE
                lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
                        "User specified LaTeX commands.\n"
@@ -1362,10 +1374,16 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                }
        }
 
-       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'));