From fd0e789dea69629cc409355ff3fc92cde03fa643 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Mon, 31 Mar 2008 01:26:57 +0000 Subject: [PATCH] Only add \makeatletter and \makeatother to the preamble when actually needed git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24068 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferParams.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 43141b46e1..b79ca7357c 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -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')); -- 2.39.2