Pavel Sanda wrote: > it will be like the patch below (more or less, really want to go sleep > now;) which i propose to put into trunk for the time beeing. if you can be > more verbose how the 'global document options' solution looks in latex i > may try something later. opinions?
I thought about something like the attached (untested, not even compiled) patch, on top of your patch. Could you play with it (my tree is too dirty ATM). Jürgen
Index: src/PDFOptions.cpp =================================================================== --- src/PDFOptions.cpp (Revision 22661) +++ src/PDFOptions.cpp (Arbeitskopie) @@ -87,13 +87,11 @@ } -void PDFOptions::writeLaTeX(odocstream & os, bool hyperref_already_provided) const +string const PDFOptions::getOptionalArgs() const { - string opt; - // since LyX uses unicode, also set the PDF strings to unicode strings with the // hyperref option "unicode" - opt += "unicode=true, "; + string opt = "unicode=true, "; // try to extract author and title from document when none is // explicitely given @@ -121,9 +119,14 @@ opt += "colorlinks=" + convert<string>(colorlinks) + ','; if (!pagemode.empty()) opt += "pdfpagemode=" + pagemode + ','; - + return opt; +} +void PDFOptions::writeLaTeX(odocstream & os, bool hyperref_already_provided) const +{ + string opt = getOptionalArgs(); + // load the pdftitle etc. as hypersetup, otherwise you'll get // LaTeX-errors when using non-latin characters string hyperset; @@ -146,19 +149,10 @@ if (!hyperref_already_provided) { opt = rtrim(opt,","); opt = "\\usepackage[" + opt + "]\n {hyperref}\n"; + } - if (!hyperset.empty()) - opt += "\\hypersetup{" + hyperset + "}\n "; - } else - // only in case hyperref is already loaded by the current text class - // try to put it into hyperset - // - // FIXME: this still does not fix the cases where hyperref is loaded - // and the option is active only when part of usepackage parameter - // (e.g. pdfusetitle). - { - opt = "\\hypersetup{" + opt + hyperset + "}\n "; - } + if (!hyperset.empty()) + opt += "\\hypersetup{" + hyperset + "}\n "; // FIXME UNICODE os << from_utf8(opt); Index: src/BufferParams.cpp =================================================================== --- src/BufferParams.cpp (Revision 22661) +++ src/BufferParams.cpp (Arbeitskopie) @@ -993,6 +993,9 @@ clsoptions << language_options.str() << ','; } + if (getTextClass().provides("hyperref")) + clsoptions << pdfoptions().getOptionalArgs(); + // the user-defined options if (!options.empty()) { clsoptions << options << ','; Index: src/PDFOptions.h =================================================================== --- src/PDFOptions.h (Revision 22661) +++ src/PDFOptions.h (Arbeitskopie) @@ -29,6 +29,8 @@ bool empty() const; /// output to lyx header void writeFile(std::ostream &) const; + /// the options that must be passed as optional arguments + std::string const getOptionalArgs() const; /// output to tex header void writeLaTeX(odocstream &, bool hyperref_already_provided) const; /// read tokens from lyx header