+
+// Have to overwrite the default InsetCommand method in order to check that
+// the \cite command is valid. Eg, the user has natbib enabled, inputs some
+// citations and then changes his mind, turning natbib support off. The output
+// should revert to \cite[]{}
+int InsetCitation::latex(Buffer const * buffer, ostream & os,
+ bool /*fragile*/, bool/*fs*/) const
+{
+ os << "\\";
+ if (buffer->params.use_natbib)
+ os << getCmdName();
+ else
+ os << "cite";
+
+ if (!getOptions().empty())
+ os << "[" << getOptions() << "]";
+
+ // Paranoia check: make sure that there is no whitespace in here
+ string content;
+ for (string::const_iterator it = getContents().begin();
+ it != getContents().end(); ++it) {
+ if (*it != ' ') content += *it;
+ }
+
+ os << "{" << content << "}";
+
+ return 0;
+}
+
+
+void InsetCitation::validate(LaTeXFeatures & features) const
+{
+ if (features.bufferParams().use_natbib)
+ features.require("natbib");
+}