BufferParams.cpp: change the package loading to:

former                  now
needed packages         needed packages
---                     babel
hyperref                hyperref
LyX-specific stuff      LyX-specific stuff
user preamble           user preamble
babel                   ---

This is needed because hyperref should be loaded after babel but has to be loaded before the LyX-specific stuff. The LyX-specific stuff has to be loaded before the user preamble.

It shouldn't harm to load babel before the user preamble, I even think this is an advantage because many packages need the loaded babel for  translations and the users are able to change babel translation.

The new scheme compile fine with all LyX docs and my German math manual. When you have an example where this scheme doesn't work, please shout!

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20508 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2007-09-25 21:20:57 +00:00
parent 0f61e68ba7
commit c57143d682

View File

@ -1120,11 +1120,26 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
// The optional packages;
docstring lyxpreamble(from_ascii(features.getPackages()));
// PDF support. Hyperref manual: "Make sure it comes last of your loaded
// We try to load babel late, in case it interferes
// with other packages. But some packages also need babel to be loaded
// before, e.g. jurabib has to be called after babel.
// So load babel after the optional packages but before the user-defined
// preamble. This allows the users to redefine babel commands, e.g. to
// translate the word "Index" to the German "Stichwortverzeichnis".
if (use_babel && !features.isRequired("jurabib")) {
// FIXME UNICODE
lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n';
lyxpreamble += from_utf8(features.getBabelOptions());
}
// PDF support.
// * Hyperref manual: "Make sure it comes last of your loaded
// packages, to give it a fighting chance of not being over-written,
// since its job is to redefine many LATEX commands."
// Has to be put into lyxpreamble (preserving line-counting for error
// parsing).
// * Email from Heiko Oberdiek: "It is usually better to load babel
// before hyperref. Then hyperref has a chance to detect babel.
// * Has to be loaded before the "LyX specific LaTeX commands" to
// avoid errors with algorithm floats.
odocstringstream oss;
pdfoptions().writeLaTeX(oss);
lyxpreamble += oss.str();
@ -1192,15 +1207,6 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
if (!bullets_def.empty())
lyxpreamble += bullets_def + "}\n\n";
// We try to load babel late, in case it interferes
// with other packages.
// Jurabib has to be called after babel, though.
if (use_babel && !features.isRequired("jurabib")) {
// FIXME UNICODE
lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n';
lyxpreamble += from_utf8(features.getBabelOptions());
}
lyxpreamble += "\\makeatother\n\n";
int const nlines =