This re-uses the options line edit introduced for biblatex.
-----------------------
+2017-01-13 Jürgen Spitzmüller <spitz@lyx.org>
+ * Format incremented to 530: Support natbib & jurabib package options.
+
+
2017-01-13 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 529:
\begin_inset CommandInset citation
i = j + 1
+
+def revert_bibpackopts(document):
+ " Revert support for natbib/jurabib package options "
+
+ engine = "basic"
+ i = find_token(document.header, "\\cite_engine", 0)
+ if i == -1:
+ document.warning("Malformed document! Missing \\cite_engine")
+ else:
+ engine = get_value(document.header, "\\cite_engine", i)
+
+ biblatex = False
+ if engine not in ["natbib", "jurabib"]:
+ return
+
+ biblio_options = ""
+ i = find_token(document.header, "\\biblio_options", 0)
+ if i != -1:
+ biblio_options = get_value(document.header, "\\biblio_options", i)
+ del document.header[i]
+
+ i = find_token(document.header, "\\begin_local_layout", 0)
+ if i == -1:
+ k = find_token(document.header, "\\language", 0)
+ if k == -1:
+ # this should not happen
+ document.warning("Malformed LyX document! No \\language header found!")
+ return
+ document.header[k-1 : k-1] = ["\\begin_local_layout", "\\end_local_layout"]
+ i = k - 1
+
+ j = find_end_of(document.header, i, "\\begin_local_layout", "\\end_local_layout")
+ if j == -1:
+ # this should not happen
+ document.warning("Malformed LyX document! Can't find end of local layout!")
+ return
+
+ document.header[i+1 : i+1] = [
+ "### Inserted by lyx2lyx (bibliography package options) ###",
+ "PackageOptions " + engine + " " + biblio_options,
+ "### End of insertion by lyx2lyx (bibliography package options) ###"
+ ]
+
+
##
# Conversion hub
#
[526, []],
[527, []],
[528, []],
- [529, []]
+ [529, []],
+ [530, []]
]
revert = [
+ [529, [revert_bibpackopts]],
[528, [revert_citekeyonly]],
[527, [revert_biblatex]],
[526, [revert_noprefix]],
}
+bool LyXCiteEngine::requires(const string p) const
+{
+ return find(package_list_.begin(), package_list_.end(), p) != package_list_.end();
+}
+
+
// used when sorting the cite engine list.
class EngineSorter {
public:
///
std::vector<std::string> const & getPackageList() const
{ return package_list_; }
+ ///
+ bool requires(std::string const p) const;
private:
/// what appears in the ui
std::string name_;
packages << "numbers";
else
packages << "authoryear";
+ if (!params_.biblio_opts.empty())
+ packages << ',' << params_.biblio_opts;
packages << "]{natbib}\n";
}
}
// jurabib -- we need version 0.6 at least.
- if (mustProvide("jurabib"))
- packages << "\\usepackage{jurabib}[2004/01/25]\n";
+ if (mustProvide("jurabib")) {
+ packages << "\\usepackage";
+ if (!params_.biblio_opts.empty())
+ packages << '[' << params_.biblio_opts << ']';
+ packages << "{jurabib}[2004/01/25]\n";
+ }
// opcit -- we pass custombst as we output \bibliographystyle ourselves
if (mustProvide("opcit")) {
biblioModule->bibtopicCB->setEnabled(!biblatex);
// These are only useful with Biblatex
- biblioModule->citePackageOptionsLE->setEnabled(biblatex);
- biblioModule->citePackageOptionsL->setEnabled(biblatex);
biblioModule->biblatexBbxCO->setEnabled(biblatex);
biblioModule->biblatexBbxLA->setEnabled(biblatex);
biblioModule->biblatexCbxCO->setEnabled(biblatex);
biblioModule->resetBbxPB->setEnabled(biblatex);
biblioModule->resetCbxPB->setEnabled(biblatex);
biblioModule->matchBbxPB->setEnabled(biblatex);
+
+ // These are useful with biblatex, jurabib and natbib
+ QString const engine =
+ biblioModule->citeEngineCO->itemData(
+ biblioModule->citeEngineCO->currentIndex()).toString();
+ LyXCiteEngine const * ce = theCiteEnginesList[fromqstr(engine)];
+
+ bool const citepack = ce->requires("biblatex.sty") || ce->requires("jurabib.sty")
+ || ce->requires("natbib.sty");
+ biblioModule->citePackageOptionsLE->setEnabled(citepack);
+ biblioModule->citePackageOptionsL->setEnabled(citepack);
}
<rect>
<x>0</x>
<y>0</y>
- <width>534</width>
+ <width>545</width>
<height>481</height>
</rect>
</property>
</sizepolicy>
</property>
<property name="toolTip">
- <string>Here you can enter further options of the biblatex package</string>
+ <string>Here you can enter further options of the bibliography package</string>
</property>
</widget>
</item>
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 529 // spitz: keyonly cite type
-#define LYX_FORMAT_TEX2LYX 529
+#define LYX_FORMAT_LYX 530 // spitz: natbib/jurabib package options
+#define LYX_FORMAT_TEX2LYX 530
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER