From 9b3e47fd8726e57f421f91ad4917450690b4d385 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sun, 21 Dec 2014 12:10:06 +0100 Subject: [PATCH] Output package options before loading any package. Fixes: #9355 --- src/BufferParams.cpp | 3 +++ src/LaTeXFeatures.cpp | 26 ++++++++++++++++---------- src/LaTeXFeatures.h | 2 ++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index d94600fb0f..f28d26d469 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1776,6 +1776,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 630cc4c30e..4d6a549228 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -815,6 +815,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::const_iterator it = + params_.documentClass().packageOptions().begin(); + map::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; @@ -825,16 +841,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::const_iterator it = - params_.documentClass().packageOptions().begin(); - map::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 be00847f7e..097fe4cf8c 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 -- 2.39.2