From 2e72a0af48023956ae6ce3285b47168c2fed5099 Mon Sep 17 00:00:00 2001 From: Julien Rioux Date: Fri, 4 Jan 2013 23:57:40 +0100 Subject: [PATCH] Add known citation packages to LaTeXFeatures: - achicago - apacite - apalike - astron - authordate - chicago - harvard - mslapa - named This allows these citation packages can be Required by the document layout. LyX handles the package ordering, loading any of these packages before natbib when both are required by the document layout. For example, apacite can be used with or without natbib. The package achicago isn't compatible with natbib out-of-the-box, but the following compatibility code makes it work: \usepackage{achicago} \let\achicagobib\thebibliography \usepackage[authoryear]{natbib} \let\thebibliography\achicagobib \let\UnexpandableProtect\protect \let\SCcite\astroncite --- lib/chkconfig.ltx | 9 +++++++++ src/LaTeX.cpp | 6 +++++- src/LaTeXFeatures.cpp | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx index 5b9f9576de..76ece71f00 100644 --- a/lib/chkconfig.ltx +++ b/lib/chkconfig.ltx @@ -269,10 +269,15 @@ %%% Packages \TestPackage{accents} +\TestPackage{achicago} \TestPackage{algorithm} \TestPackage{amstext} +\TestPackage{apacite} +\TestPackage{apalike} \TestPackage[arabic.ldf]{arabi} \TestPackage{array} +\TestPackage{astron} +\TestPackage{authordate1-4} \TestPackage{babel} \TestPackage{bibtopic} \TestPackage{bidi} @@ -283,6 +288,7 @@ \TestPackage{CJKutf8} \TestPackage{calc} \TestPackage{cancel} +\TestPackage{chicago} \TestPackage{color} % this one should be there if graphics.sty is there. \TestPackage{covington} \TestPackage{csquotes} @@ -293,6 +299,7 @@ \TestPackage{esint} \TestPackage{eso-pic} \TestPackage{fontspec} +\TestPackage{harvard} \TestPackage{hhline} \TestPackage{ifthen} \TestPackage{iftex} @@ -320,7 +327,9 @@ \TestPackage{mathtools} \TestPackage{mhchem} \TestPackage[mongolian.ldf]{mongolian} +\TestPackage{mslapa} \TestPackage{multirow} +\TestPackage{named} \TestPackage{natbib} \TestPackage{nicefrac} \TestPackage{nomencl} diff --git a/src/LaTeX.cpp b/src/LaTeX.cpp index c9d32478d1..a6244863ff 100644 --- a/src/LaTeX.cpp +++ b/src/LaTeX.cpp @@ -184,7 +184,7 @@ int LaTeX::run(TeXErrors & terr) bool had_depfile = depfile.exists(); bool run_bibtex = false; - FileName const aux_file(changeExtension(file.absFileName(), "aux")); + FileName const aux_file(changeExtension(file.absFileName(), ".aux")); if (had_depfile) { LYXERR(Debug::DEPEND, "Dependency file exists"); @@ -694,6 +694,10 @@ int LaTeX::scanLogFile(TeXErrors & terr) && contains(token, "on page") && contains(token, "undefined")) { retval |= UNDEF_CIT; + } else if (contains(token, "Citation") + && contains(token, "on input line") + && contains(token, "undefined")) { + retval |= UNDEF_CIT; } } else if (prefixIs(token, "Package")) { // Package warnings diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 6b23fc537b..562f9b1150 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -716,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 *); } @@ -894,6 +909,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). @@ -907,6 +933,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"; -- 2.39.2