Both problems where caused by the fact that tex2lyx did not handle
natbib/jurabib citations correctly if natbib/jurabib was loaded by the
document class. Therefore it tried to parse the standard \cite syntax, and
did not recognize \citet and \citep.
This commit is contained in:
Georg Baum 2012-12-28 14:29:46 +01:00
parent 594c83261a
commit 8693f5a91e
4 changed files with 23 additions and 2 deletions

View File

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

View File

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

View File

@ -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<std::string> active_environments;
std::string active_environment();

View File

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