diff --git a/src/tex2lyx/Preamble.h b/src/tex2lyx/Preamble.h index db2242f3ce..d438c95e2f 100644 --- a/src/tex2lyx/Preamble.h +++ b/src/tex2lyx/Preamble.h @@ -62,6 +62,10 @@ public: /// void suppressDate(bool suppress); /// + std::string citeEngine() const { return h_cite_engine; } + /// + void citeEngine(std::string const & e) { h_cite_engine = e; } + /// bool titleLayoutFound() const { return title_layout_found; } /// void titleLayoutFound(bool found) { title_layout_found = found; } diff --git a/src/tex2lyx/tex2lyx.cpp b/src/tex2lyx/tex2lyx.cpp index ceb4e92ed3..ea20561f08 100644 --- a/src/tex2lyx/tex2lyx.cpp +++ b/src/tex2lyx/tex2lyx.cpp @@ -446,6 +446,13 @@ bool checkModule(string const & name, bool command) } +bool isProvided(string const & name) +{ + // This works only for features that are named like the LaTeX packages + return textclass.provides(name) || preamble.isPackageUsed(name); +} + + bool noweb_mode = false; bool pdflatex = false; bool xetex = false; diff --git a/src/tex2lyx/tex2lyx.h b/src/tex2lyx/tex2lyx.h index e3da48b478..94f2497fac 100644 --- a/src/tex2lyx/tex2lyx.h +++ b/src/tex2lyx/tex2lyx.h @@ -118,6 +118,8 @@ extern InsetLayout const * findInsetLayoutWithoutModule( * list of used modules if yes. */ extern bool checkModule(std::string const & name, bool command); +/// Is this feature already provided e.g. by the document class? +extern bool isProvided(std::string const & name); // Access to environment stack extern std::vector active_environments; std::string active_environment(); diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index f406869153..c90b3cd25d 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -2161,8 +2161,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, // (needed for bibtex inset) string btprint; string bibliographystyle = "default"; - bool const use_natbib = preamble.isPackageUsed("natbib"); - bool const use_jurabib = preamble.isPackageUsed("jurabib"); + bool const use_natbib = isProvided("natbib"); + bool const use_jurabib = isProvided("jurabib"); string last_env; while (p.good()) { Token const & t = p.get_token(); @@ -3371,6 +3371,10 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, << convert_command_inset_arg(p.verbatim_item()) << "\"\n"; end_inset(os); + // Need to set the cite engine if natbib is loaded by + // the document class directly + if (preamble.citeEngine() == "basic") + preamble.citeEngine("natbib"); } else if (use_jurabib && @@ -3421,6 +3425,10 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, os << "before " << '"' << before << '"' << "\n"; os << "key " << '"' << citation << '"' << "\n"; end_inset(os); + // Need to set the cite engine if jurabib is loaded by + // the document class directly + if (preamble.citeEngine() == "basic") + preamble.citeEngine("jurabib"); } else if (t.cs() == "cite"