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
This commit is contained in:
Julien Rioux 2013-01-04 23:57:40 +01:00
parent 2f33755814
commit 2e72a0af48
3 changed files with 47 additions and 1 deletions

View File

@ -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}

View File

@ -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

View File

@ -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";