From 8ee2ffaa52dfd7b1de547df36331f0343fc6a7a2 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Thu, 18 Apr 2019 16:27:22 +0200 Subject: [PATCH] Amend 3615a6a75bfe7b Natbib provides separation of abbreviated and full author list also beyond BibTeX --- src/frontends/qt4/GuiBibitem.cpp | 15 ++++++++++++--- src/frontends/qt4/ui/BibitemUi.ui | 31 ++++++++++++++++++++++++------- src/insets/InsetBibitem.cpp | 8 +++++++- 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/frontends/qt4/GuiBibitem.cpp b/src/frontends/qt4/GuiBibitem.cpp index dddb507945..462a8705f5 100644 --- a/src/frontends/qt4/GuiBibitem.cpp +++ b/src/frontends/qt4/GuiBibitem.cpp @@ -36,6 +36,8 @@ GuiBibitem::GuiBibitem(QWidget * parent) : InsetParamsWidget(parent) this, SIGNAL(changed())); connect(labelED, SIGNAL(textChanged(QString)), this, SIGNAL(changed())); + connect(allAuthorsED, SIGNAL(textChanged(QString)), + this, SIGNAL(changed())); connect(yearED, SIGNAL(textChanged(QString)), this, SIGNAL(changed())); connect(literalCB, SIGNAL(clicked()), @@ -54,21 +56,28 @@ void GuiBibitem::paramsToDialog(Inset const * inset) if (bp.citeEngine() == "natbib" && bp.citeEngineType() == ENGINE_TYPE_AUTHORYEAR) { yearED->setHidden(false); yearLA->setHidden(false); - labelLA->setText(qt_("Author &Name:")); - labelED->setToolTip(qt_("Insert the author name(s) here. The year goes to the separate field.")); + allAuthorsED->setHidden(false); + allAuthorsLA->setHidden(false); + labelLA->setText(qt_("Author &Names:")); + labelED->setToolTip(qt_("Insert the author name(s) for the author-year reference here. " + "If you use an abbreviated list (with 'et al.'), the full list can go below.")); int const i = label.lastIndexOf("("); int const j = label.lastIndexOf(")"); if (i != -1 && j != -1 && i < j) { // Split Author(Year) to Author and Year QString const year = label.left(j).mid(i + 1); QString const author = label.left(i); + QString const allauthors = label.mid(j + 1); labelED->setText(author); yearED->setText(year); + allAuthorsED->setText(allauthors); } else labelED->setText(label); } else { yearED->setHidden(true); yearLA->setHidden(true); + allAuthorsED->setHidden(true); + allAuthorsLA->setHidden(true); labelLA->setText(qt_("&Label:")); labelED->setToolTip(qt_("The label as it appears in the document")); labelED->setText(label); @@ -81,7 +90,7 @@ docstring GuiBibitem::dialogToParams() const InsetCommandParams params(insetCode()); QString label = labelED->text(); if (!yearED->isHidden()) - label += "(" + yearED->text() + ")"; + label += "(" + yearED->text() + ")" + allAuthorsED->text(); params["key"] = qstring_to_ucs4(keyED->text()); params["label"] = qstring_to_ucs4(label); params["literal"] = literalCB->isChecked() diff --git a/src/frontends/qt4/ui/BibitemUi.ui b/src/frontends/qt4/ui/BibitemUi.ui index 01c2b7928b..a32a8c71e1 100644 --- a/src/frontends/qt4/ui/BibitemUi.ui +++ b/src/frontends/qt4/ui/BibitemUi.ui @@ -6,22 +6,22 @@ 0 0 - 400 - 123 + 467 + 170 - + - + @@ -36,7 +36,7 @@ - + @@ -62,7 +62,7 @@ - + 0 @@ -102,9 +102,26 @@ + + + + A&ll Author Names: + + + allAuthorsED + + + + + + + If you want to use an abbreviated author list (with 'et al.') as well as a full list for author-year citation, you can put the full list here and the abbreviated list above. + + + - + Pass content of the `Label' field literally to LaTeX. Check this if you want to enter LaTeX code. diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index 2060b1a1c9..64e6a31bf5 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -188,9 +188,15 @@ docstring InsetBibitem::bibLabel() const if (bp.citeEngineType() == ENGINE_TYPE_NUMERICAL) return autolabel_; docstring label = getParam("label"); - if (!label.empty() && bp.citeEngine() == "natbib") + if (!label.empty() && bp.citeEngine() == "natbib") { // Add a space before opening paren label = subst(label, from_ascii("("), from_ascii(" (")); + // and strip off long author list + docstring striplabel; + label = rsplit(label, striplabel, ')'); + if (!striplabel.empty()) + label = striplabel + ")"; + } return label.empty() ? autolabel_ : label; }