X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLaTeXFeatures.cpp;h=10adb14c3bf67ffc740cad5dd13296baa24e29db;hb=86994bf75320524ec656fd70950633c83d445a6c;hp=bbc76d18523eb714573fdc7dc874e90baf90e8e5;hpb=aafd52f44167d5510be1ddcb974daa9dae486933;p=lyx.git diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index bbc76d1852..10adb14c3b 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -184,19 +184,19 @@ static docstring const changetracking_dvipost_def = from_ascii( "\\dvipost{osend color pop}\n" "\\dvipost{cbstart color push Blue}\n" "\\dvipost{cbend color pop}\n" - "\\newcommand{\\lyxadded}[3]{\\changestart#3\\changeend}\n" - "\\newcommand{\\lyxdeleted}[3]{%\n" + "\\DeclareRobustCommand{\\lyxadded}[3]{\\changestart#3\\changeend}\n" + "\\DeclareRobustCommand{\\lyxdeleted}[3]{%\n" "\\changestart\\overstrikeon#3\\overstrikeoff\\changeend}\n"); static docstring const changetracking_xcolor_ulem_def = from_ascii( "%% Change tracking with ulem\n" - "\\newcommand{\\lyxadded}[3]{{\\color{lyxadded}{}#3}}\n" - "\\newcommand{\\lyxdeleted}[3]{{\\color{lyxdeleted}\\sout{#3}}}\n"); + "\\DeclareRobustCommand{\\lyxadded}[3]{{\\color{lyxadded}{}#3}}\n" + "\\DeclareRobustCommand{\\lyxdeleted}[3]{{\\color{lyxdeleted}\\sout{#3}}}\n"); static docstring const changetracking_xcolor_ulem_hyperref_def = from_ascii( "%% Change tracking with ulem\n" - "\\newcommand{\\lyxadded}[3]{{\\texorpdfstring{\\color{lyxadded}{}}{}#3}}\n" - "\\newcommand{\\lyxdeleted}[3]{{\\texorpdfstring{\\color{lyxdeleted}\\sout{#3}}{}}}\n"); + "\\DeclareRobustCommand{\\lyxadded}[3]{{\\texorpdfstring{\\color{lyxadded}{}}{}#3}}\n" + "\\DeclareRobustCommand{\\lyxdeleted}[3]{{\\texorpdfstring{\\color{lyxdeleted}\\sout{#3}}{}}}\n"); static docstring const changetracking_none_def = from_ascii( "\\newcommand{\\lyxadded}[3]{#3}\n" @@ -327,7 +327,7 @@ LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p, {} -LaTeXFeatures::LangPackage LaTeXFeatures::langPackage(bool englishbabel) const +LaTeXFeatures::LangPackage LaTeXFeatures::langPackage() const { string const local_lp = bufferParams().lang_package; @@ -347,9 +347,6 @@ LaTeXFeatures::LangPackage LaTeXFeatures::langPackage(bool englishbabel) const * If babel is selected (either directly or via the "auto" * mechanism), we really do only require it if we have * a language that needs it. - * English alone normally does not require babel (since it is - * the default language of LaTeX). However, in some cases we - * need to surpass this exception (see Font::validate). */ bool const polyglossia_required = isRequired("polyglossia") @@ -357,8 +354,7 @@ LaTeXFeatures::LangPackage LaTeXFeatures::langPackage(bool englishbabel) const && !isProvided("babel") && this->hasOnlyPolyglossiaLanguages(); bool const babel_required = - ((englishbabel || bufferParams().language->lang() != "english") - && !bufferParams().language->babel().empty()) + !bufferParams().language->babel().empty() || !this->getBabelLanguages().empty(); if (local_lp == "auto") { @@ -702,7 +698,7 @@ char const * simplefeatures[] = { "mathrsfs", "mathabx", "mathtools", - "cancel", + // "cancel", "ascii", "url", "covington", @@ -720,6 +716,21 @@ char const * simplefeatures[] = { "tfrupee" }; +char const * bibliofeatures[] = { + // Known bibliography packages (will be loaded before natbib) + "achicago", + "apacite", + "apalike", + "astron", + "authordate1-4", + "chicago", + "harvard", + "mslapa", + "named" +}; + +int const nb_bibliofeatures = sizeof(bibliofeatures) / sizeof(char const *); + int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *); } @@ -822,6 +833,9 @@ string const LaTeXFeatures::getPackages() const if (mustProvide("fixltx2e")) packages << "\\usepackage{fixltx2e}\n"; + if (mustProvide("cancel") && + params_.use_package("cancel") != BufferParams::package_off) + packages << "\\usepackage{cancel}\n"; // wasysym is a simple feature, but it must be after amsmath if both // are used // wasysym redefines some integrals (e.g. iint) from amsmath. That @@ -850,6 +864,15 @@ string const LaTeXFeatures::getPackages() const params_.use_package("yhmath") != BufferParams::package_off) packages << "\\usepackage{yhmath}\n"; + // stmaryrd must be loaded after amsmath + if (mustProvide("stmaryrd") && + params_.use_package("stmaryrd") != BufferParams::package_off) + packages << "\\usepackage{stmaryrd}\n"; + + if (mustProvide("stackrel") && + params_.use_package("stackrel") != BufferParams::package_off) + packages << "\\usepackage{stackrel}\n"; + if (mustProvide("undertilde") && params_.use_package("undertilde") != BufferParams::package_off) packages << "\\usepackage{undertilde}\n"; @@ -889,6 +912,17 @@ string const LaTeXFeatures::getPackages() const params_.use_package("esint") != BufferParams::package_off) packages << "\\usepackage{esint}\n"; + // Known bibliography packages (simple \usepackage{package}) + for (int i = 0; i < nb_bibliofeatures; ++i) { + if (mustProvide(bibliofeatures[i])) + packages << "\\usepackage{" + << bibliofeatures[i] << "}\n"; + } + + // Compatibility between achicago and natbib + if (mustProvide("achicago") && mustProvide("natbib")) + packages << "\\let\\achicagobib\\thebibliography\n"; + // natbib.sty // Some classes load natbib themselves, but still allow (or even require) // plain numeric citations (ReVTeX is such a case, see bug 5182). @@ -902,6 +936,13 @@ string const LaTeXFeatures::getPackages() const packages << "]{natbib}\n"; } + // Compatibility between achicago and natbib + if (mustProvide("achicago") && mustProvide("natbib")) { + packages << "\\let\\thebibliography\\achicagobib\n"; + packages << "\\let\\SCcite\\astroncite\n"; + packages << "\\let\\UnexpandableProtect\\protect\n"; + } + // jurabib -- we need version 0.6 at least. if (mustProvide("jurabib")) packages << "\\usepackage{jurabib}[2004/01/25]\n";