X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferParams.cpp;h=a12a2860dc037d4c7d87a068b998180c278e5ded;hb=858c12c6bb850b7ed7a708e3e66fd58ba6f06cb9;hp=7a527a75927e35bb79b897edd2cc2c213b0d4645;hpb=16c33b5f6e3fd5ff8f278542d6d12bc7c82ffb93;p=lyx.git diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 7a527a7592..a12a2860dc 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -634,7 +634,7 @@ string BufferParams::readToken(Lexer & lex, string const & token, "See section 3.1.2.2 (Class Availability) of the\n" "User's Guide for more information."), desc, prereqs); frontend::Alert::warning(_("Document class not available"), - msg); + msg, true); } } else if (token == "\\begin_preamble") { readPreamble(lex); @@ -1326,6 +1326,11 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features, // are doing! if (features.mustProvide("fix-cm")) os << "\\RequirePackage{fix-cm}\n"; + // Likewise for fixltx2e. If other packages conflict with this policy, + // treat it as a package bug (and report it!) + // See http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=latex/4407 + if (features.mustProvide("fixltx2e")) + os << "\\RequirePackage{fixltx2e}\n"; os << "\\documentclass"; @@ -1494,18 +1499,8 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features, // XeTeX and LuaTeX (with OS fonts) do not need fontenc if (!useNonTeXFonts && !features.isProvided("fontenc") && font_encoding() != "default") { - vector fontencs; - // primary language font encoding and default encoding - if (ascii_lowercase(language->fontenc()) != "none") { - vector fencs = getVectorFromString(font_encoding()); - fontencs.insert(fontencs.end(), fencs.begin(), fencs.end()); - fencs = getVectorFromString(language->fontenc()); - vector::const_iterator fit = fencs.begin(); - for (; fit != fencs.end(); ++fit) { - if (find(fontencs.begin(), fontencs.end(), *fit) == fontencs.end()) - fontencs.push_back(*fit); - } - } + // get main font encodings + vector fontencs = font_encodings(); // get font encodings of secondary languages features.getFontEncodings(fontencs); if (!fontencs.empty()) { @@ -1952,7 +1947,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features, + atlyxpreamble + "\\makeatother\n\n"; // We try to load babel late, in case it interferes with other packages. - // Jurabib, hyperref, varioref and listings (bug 8995) have to be + // Jurabib, hyperref, varioref, bicaption and listings (bug 8995) have to be // called after babel, though. if (use_babel && !features.isRequired("jurabib") && !features.isRequired("hyperref") @@ -1965,6 +1960,8 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features, features.needBabelLangOptions())) + '\n'; lyxpreamble += from_utf8(features.getBabelPostsettings()); } + if (features.isRequired("bicaption")) + lyxpreamble += "\\usepackage{bicaption}\n"; if (!listings_params.empty() || features.isRequired("listings")) lyxpreamble += "\\usepackage{listings}\n"; if (!listings_params.empty()) { @@ -2755,7 +2752,31 @@ string const BufferParams::dvips_options() const string const BufferParams::font_encoding() const { - return (fontenc == "global") ? lyxrc.fontenc : fontenc; + return font_encodings().empty() ? "default" : font_encodings().back(); +} + + +vector const BufferParams::font_encodings() const +{ + string doc_fontenc = (fontenc == "global") ? lyxrc.fontenc : fontenc; + + vector fontencs; + + // "default" means "no explicit font encoding" + if (doc_fontenc != "default") { + fontencs = getVectorFromString(doc_fontenc); + if (!language->fontenc().empty() + && ascii_lowercase(language->fontenc()) != "none") { + vector fencs = getVectorFromString(language->fontenc()); + vector::const_iterator fit = fencs.begin(); + for (; fit != fencs.end(); ++fit) { + if (find(fontencs.begin(), fontencs.end(), *fit) == fontencs.end()) + fontencs.push_back(*fit); + } + } + } + + return fontencs; } @@ -2825,7 +2846,8 @@ void BufferParams::writeEncodingPreamble(otexstream & os, // inputenc must be omitted. // see http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html if ((!encodings.empty() || package == Encoding::inputenc) - && !features.isRequired("japanese")) { + && !features.isRequired("japanese") + && !features.isProvided("inputenc")) { os << "\\usepackage["; set::const_iterator it = encodings.begin(); set::const_iterator const end = encodings.end(); @@ -2856,7 +2878,9 @@ void BufferParams::writeEncodingPreamble(otexstream & os, break; case Encoding::inputenc: // do not load inputenc if japanese is used - if (features.isRequired("japanese")) + // or if the class provides inputenc + if (features.isRequired("japanese") + || features.isProvided("inputenc")) break; os << "\\usepackage[" << from_ascii(encoding().latexName()) << "]{inputenc}\n"; @@ -2992,7 +3016,8 @@ Encoding const & BufferParams::encoding() const // FIXME: actually, we should check for the flavor // or runparams.isFullyUnicode() here: // This check will not work with XeTeX/LuaTeX and tex fonts. - // Thus we have to reset the encoding in Buffer::makeLaTeXFile. + // Thus we have to reset the encoding in Buffer::makeLaTeXFile + // (for export) and Buffer::writeLaTeXSource (for preview). if (useNonTeXFonts) return *(encodings.fromLyXName("utf8-plain")); if (inputenc == "auto" || inputenc == "default")