]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
adjust
[lyx.git] / src / BufferParams.cpp
index 6f2e3ed3a9dbc18801e7beba3fa5b6842c9ac77d..303fe2fcb229f7e7b595d00df85464dc0979cd24 100644 (file)
@@ -901,7 +901,8 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                        language_options << language->babel();
                }
                // when Vietnamese is used, babel must directly be loaded with the
-               // language options, not in the class options
+               // language options, not in the class options, see
+               // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129417.html
                int viet = language_options.str().find("vietnam");
                // viet = string::npos when not found
                if (lyxrc.language_global_options && !language_options.str().empty()
@@ -1134,8 +1135,12 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
        // translate the word "Index" to the German "Stichwortverzeichnis".
        // For more infos why this place was chosen, see
        // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg128425.html
-       // if you encounter problem, you can shift babel to its old place behind
-       // the user-defined preamble
+       // If you encounter problems, you can shift babel to its old place behind
+       // the user-defined preamble. But in this case you must change the Vietnamese
+       // support from currently "\usepackage[vietnamese]{babel}" to:
+       // \usepackage{vietnamese}
+       // \usepackage{babel}
+       // because vietnamese must be loaded before hyperref
        if (use_babel && !features.isRequired("jurabib")) {
                // FIXME UNICODE
                lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n';
@@ -1143,10 +1148,16 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
        }
 
        // When the language "japanese-plain" is used, the package "japanese" must
-       // be loaded behind babel (it provides babel support for Japanese)
-       // see http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html
-       if (language->lang() == "japanese-plain")
+       // be loaded behind babel (it provides babel support for Japanese) but before
+       // hyperref, see
+       // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html
+       if (language->lang() == "japanese-plain" &&
+               !getTextClass().provides("japanese")) {
+               //load babel in case it was not loaded due to an empty language list
+               if (language_options.str().empty())
+                       lyxpreamble += "\\usepackage{babel}\n";
                lyxpreamble += "\\usepackage{japanese}\n";
+       }
 
        // PDF support.
        // * Hyperref manual: "Make sure it comes last of your loaded
@@ -1157,7 +1168,8 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
        // * Has to be loaded before the "LyX specific LaTeX commands" to
        //   avoid errors with algorithm floats.
        odocstringstream oss;
-       pdfoptions().writeLaTeX(oss);
+       // use hyperref explicitely when it is required
+       pdfoptions().writeLaTeX(oss, features.isRequired("hyperref"));
        lyxpreamble += oss.str();
 
        // this might be useful...
@@ -1561,7 +1573,8 @@ string const BufferParams::babelCall(string const & lang_opts) const
        if (lang_opts.empty())
                return string();
        // when Vietnamese is used, babel must directly be loaded with the
-       // language options
+       // language options, see
+       // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129417.html
        int viet = lang_opts.find("vietnam");
        // viet = string::npos when not found
        if (!lyxrc.language_global_options || viet != string::npos)