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
This commit is contained in:
Enrico Forestieri 2009-05-26 00:58:36 +00:00
parent 39c96ebb75
commit b7515068f8

View File

@ -1466,9 +1466,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
/* the user-defined preamble */ /* the user-defined preamble */
if (!preamble.empty()) if (!preamble.empty())
// FIXME UNICODE // FIXME UNICODE
atlyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " atlyxpreamble += from_utf8(preamble);
"User specified LaTeX commands.\n"
+ from_utf8(preamble) + '\n';
// subfig loads internally the LaTeX package "caption". As // subfig loads internally the LaTeX package "caption". As
// caption is a very popular package, users will load it in // 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()) if (!bullets_def.empty())
atlyxpreamble += bullets_def + "}\n\n"; atlyxpreamble += bullets_def + "}\n\n";
if (atlyxpreamble.find(from_ascii("@")) != docstring::npos) lyxpreamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
lyxpreamble += "\n\\makeatletter\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"; + atlyxpreamble + "\\makeatother\n\n";
else else
lyxpreamble += '\n' + atlyxpreamble; lyxpreamble += atlyxpreamble + '\n';
// We try to load babel late, in case it interferes with other packages. // We try to load babel late, in case it interferes with other packages.
// Jurabib and Hyperref have to be called after babel, though. // Jurabib and Hyperref have to be called after babel, though.