commit b215e58ed12b16028983a0094934b64c3777ce9f
Author: Juergen Spitzmueller <[email protected]>
Date:   Sun Dec 21 12:10:06 2014 +0100

    Output package options before loading any package.
    
    Fixes: #9355

diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 890f584..0ca1364 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -1774,6 +1774,9 @@ bool BufferParams::writeLaTeX(otexstream & os, 
LaTeXFeatures & features,
                        lyxpreamble += "\\synctex=-1\n";
        }
 
+       // The package options (via \PassOptionsToPackage)
+       lyxpreamble += from_ascii(features.getPackageOptions());
+
        // due to interferences with babel and hyperref, the color package has 
to
        // be loaded (when it is not already loaded) before babel when hyperref
        // is used with the colorlinks option, see
diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index 87280ad..0c8c740 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -831,6 +831,22 @@ string const LaTeXFeatures::getColorOptions() const
 }
 
 
+string const LaTeXFeatures::getPackageOptions() const
+{
+       ostringstream packageopts;
+       // Output all the package option stuff we have been asked to do.
+       map<string, string>::const_iterator it =
+               params_.documentClass().packageOptions().begin();
+       map<string, string>::const_iterator en =
+               params_.documentClass().packageOptions().end();
+       for (; it != en; ++it)
+               if (mustProvide(it->first))
+                       packageopts << "\\PassOptionsToPackage{" << it->second 
<< "}"
+                                << "{" << it->first << "}\n";
+       return packageopts.str();
+}
+
+
 string const LaTeXFeatures::getPackages() const
 {
        ostringstream packages;
@@ -841,16 +857,6 @@ string const LaTeXFeatures::getPackages() const
        // also unknown packages can be requested. They are silently
        // swallowed now. We should change this eventually.
 
-       // Output all the package option stuff we have been asked to do.
-       map<string, string>::const_iterator it =
-           params_.documentClass().packageOptions().begin();
-       map<string, string>::const_iterator en =
-           params_.documentClass().packageOptions().end();
-       for (; it != en; ++it)
-               if (mustProvide(it->first))
-                       packages << "\\PassOptionsToPackage{" << it->second << 
"}"
-                                << "{" << it->first << "}\n";
-
        //  These are all the 'simple' includes.  i.e
        //  packages which we just \usepackage{package}
        for (int i = 0; i < nb_simplefeatures; ++i) {
diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h
index be00847..097fe4c 100644
--- a/src/LaTeXFeatures.h
+++ b/src/LaTeXFeatures.h
@@ -55,6 +55,8 @@ public:
                      OutputParams const &);
        /// The color packages
        std::string const getColorOptions() const;
+       /// The requested package options
+       std::string const getPackageOptions() const;
        /// The packages needed by the document
        std::string const getPackages() const;
        /// The macros definitions needed by the document
diff --git a/status.21x b/status.21x
index 4c4269a..94c756e 100644
--- a/status.21x
+++ b/status.21x
@@ -90,6 +90,9 @@ What's new
 - Fix incorrect output of ampersands when multiple keys are given for a
   citation (bug 9296).
 
+- Output package options (specified with PackageOptions layout tag)
+  before loading any potentially affected package (bug 9355).
+
 - Fix export of documents that use the LaTeX-packages mhchem and wasysym
   (bug 9266).
 

Reply via email to