From b7515068f86fa75296c16df50ff75865803bad1c Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Tue, 26 May 2009 00:58:36 +0000 Subject: [PATCH] As a safety measure, enclose the preamble in the \makeatletter and \makeatother pair also when an external file is included. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29851 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferParams.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 9aae6e7d2b..d2192067d1 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1466,9 +1466,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, /* the user-defined preamble */ if (!preamble.empty()) // FIXME UNICODE - atlyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " - "User specified LaTeX commands.\n" - + from_utf8(preamble) + '\n'; + atlyxpreamble += from_utf8(preamble); // subfig loads internally the LaTeX package "caption". As // caption is a very popular package, users will load it in @@ -1521,11 +1519,19 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, if (!bullets_def.empty()) atlyxpreamble += bullets_def + "}\n\n"; - if (atlyxpreamble.find(from_ascii("@")) != docstring::npos) - lyxpreamble += "\n\\makeatletter\n" + lyxpreamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " + "User specified LaTeX commands.\n"; + + // Check whether we should change the catcode of '@' in the preamble. + // We do it when '@' explicitly appears and, as a safety measure, also + // when an external file is included. + if (atlyxpreamble.find(from_ascii("@")) != docstring::npos + || atlyxpreamble.find(from_ascii("\\input")) != docstring::npos + || atlyxpreamble.find(from_ascii("\\include")) != docstring::npos) + lyxpreamble += "\\makeatletter\n" + atlyxpreamble + "\\makeatother\n\n"; else - lyxpreamble += '\n' + atlyxpreamble; + lyxpreamble += atlyxpreamble + '\n'; // We try to load babel late, in case it interferes with other packages. // Jurabib and Hyperref have to be called after babel, though. -- 2.39.2