Jürgen Spitzmüller wrote: > Yes, that would be a good idea (also \nocite{key} in the citation > dialog would be useful).
The attached adds basic \nocite functionality (as citation style option) to the citation dialog; the inset then actually reads \nocite{key} (as I wasn't able to come up with anything better; suggestions welcome), while the citation style option in the dialog is "Add to bibliography only". This also fixes a bug I've stumbled across while working on it: In a document with citations, after changing the bibliography style (eg from plain to natbib or from natbib to jurabib), the citation style shown in the citation dialog is different from the actual inset. This is fixed by having initialiseParams re-evaluate getCitationStyles each time the dialog is opened no matter what -- which is required for the \nocite functionality anyway. If there's interest, I'll also roll out a patch for 1.5. Regarding a \nocite{*} option: what about enabling the "Contents" combo in the BibTeX dialog also for non-sectioned bibliographies, just without the "all uncited references" option? Bernhard
Index: src/BiblioInfo.h =================================================================== --- src/BiblioInfo.h (Revision 21664) +++ src/BiblioInfo.h (Arbeitskopie) @@ -36,6 +36,7 @@ enum CiteStyle { CITE, + NOCITE, CITET, CITEP, CITEALT, Index: src/BiblioInfo.cpp =================================================================== --- src/BiblioInfo.cpp (Revision 21664) +++ src/BiblioInfo.cpp (Arbeitskopie) @@ -321,6 +321,10 @@ str = from_ascii("[#ID]"); break; + case biblio::NOCITE: + str = _("Add to bibliography only."); + break; + case biblio::CITET: str = author + " [#ID]"; break; @@ -378,6 +382,10 @@ str = author + "/<" + _("before") + '>'; break; + case biblio::NOCITE: + str = _("Add to bibliography only."); + break; + case biblio::CITET: str = author + " (" + year + ')'; break; @@ -443,15 +451,15 @@ char const * const citeCommands[] = { - "cite", "citet", "citep", "citealt", "citealp", "citeauthor", - "citeyear", "citeyearpar" }; + "cite", "nocite", "citet", "citep", "citealt", "citealp", + "citeauthor", "citeyear", "citeyearpar" }; unsigned int const nCiteCommands = sizeof(citeCommands) / sizeof(char *); CiteStyle const citeStyles[] = { - CITE, CITET, CITEP, CITEALT, CITEALP, -CITEAUTHOR, CITEYEAR, CITEYEARPAR }; + CITE, NOCITE, CITET, CITEP, CITEALT, +CITEALP, CITEAUTHOR, CITEYEAR, CITEYEARPAR }; unsigned int const nCiteStyles = sizeof(citeStyles) / sizeof(CiteStyle); @@ -525,7 +533,7 @@ switch (engine) { case ENGINE_BASIC: - nStyles = 1; + nStyles = 2; start = 0; break; case ENGINE_NATBIB_AUTHORYEAR: Index: src/insets/InsetCitation.cpp =================================================================== --- src/insets/InsetCitation.cpp (Revision 21664) +++ src/insets/InsetCitation.cpp (Arbeitskopie) @@ -45,7 +45,7 @@ vector<string> const init_possible_cite_commands() { char const * const possible[] = { - "cite", "citet", "citep", "citealt", "citealp", + "cite", "nocite", "citet", "citep", "citealt", "citealp", "citeauthor", "citeyear", "citeyearpar", "citet*", "citep*", "citealt*", "citealp*", "citeauthor*", "Citet", "Citep", "Citealt", "Citealp", "Citeauthor", @@ -100,7 +100,7 @@ string output; switch (engine) { case biblio::ENGINE_BASIC: - output = default_str; + output = input; break; case biblio::ENGINE_NATBIB_AUTHORYEAR: @@ -198,7 +198,9 @@ cite_type = cite_type.substr(0, cite_type.size() - 1); docstring before_str; - if (!before.empty()) { + if (cite_type == "nocite") + before_str = from_ascii("\\nocite{"); + else if (!before.empty()) { // In CITET and CITEALT mode, the "before" string is // attached to the label associated with each and every key. // In CITEP, CITEALP and CITEYEARPAR mode, it is attached @@ -218,8 +220,10 @@ } docstring after_str; - if (!after.empty()) { - // The "after" key is appended only to the end of the whole. + // The "after" key is appended only to the end of the whole. + if (cite_type == "nocite") + after_str = from_ascii("}"); + else if (!after.empty()) { after_str = ", " + after; } @@ -254,6 +258,10 @@ else label += author + sep_str; + // nocite + } else if (cite_type == "nocite") { + label += *it + sep_str; + // (authors1 (<before> year); ... ; // authors_last (<before> year, <after>) } else if (cite_type == "citet") { @@ -327,7 +335,8 @@ } } - if (!before_str.empty() && (cite_type == "citep" || + if (!before_str.empty() && (cite_type == "nocite" || + cite_type == "citep" || cite_type == "citealp" || cite_type == "citeyearpar")) { label = before_str + label; @@ -401,10 +410,8 @@ docstring label; biblio::CiteEngine const engine = buffer.params().getEngine(); - if (engine != biblio::ENGINE_BASIC) { - label = getNatbibLabel(buffer, getCmdName(), getParam("key"), - before, after, engine); - } + label = getNatbibLabel(buffer, getCmdName(), getParam("key"), + before, after, engine); // Fallback to fail-safe if (label.empty()) Index: src/frontends/qt4/GuiCitation.cpp =================================================================== --- src/frontends/qt4/GuiCitation.cpp (Revision 21664) +++ src/frontends/qt4/GuiCitation.cpp (Arbeitskopie) @@ -243,8 +243,8 @@ textBeforeLA->setEnabled(!basic_engine && haveSelection); textAfterED->setEnabled(haveSelection); textAfterLA->setEnabled(haveSelection); - citationStyleCO->setEnabled(!basic_engine && haveSelection); - citationStyleLA->setEnabled(!basic_engine && haveSelection); + citationStyleCO->setEnabled(haveSelection); + citationStyleLA->setEnabled(haveSelection); string const & command = params_.getCmdName(); @@ -298,12 +298,10 @@ QStringList sty = citationStyles(curr); - bool const basic_engine = (getEngine() == biblio::ENGINE_BASIC); + citationStyleCO->setEnabled(!sty.isEmpty()); + citationStyleLA->setEnabled(!sty.isEmpty()); - citationStyleCO->setEnabled(!sty.isEmpty() && !basic_engine); - citationStyleLA->setEnabled(!sty.isEmpty() && !basic_engine); - - if (sty.isEmpty() || basic_engine) + if (sty.isEmpty()) return; citationStyleCO->insertItems(0, sty); @@ -453,7 +451,6 @@ return; vector<biblio::CiteStyle> const & styles = citeStyles_; - string const command = biblio::CitationStyle(styles[choice], full, force) .asLatexStr(); @@ -590,17 +587,9 @@ biblio::CiteEngine const engine = buffer().params().getEngine(); - bool use_styles = engine != biblio::ENGINE_BASIC; - bibkeysInfo_.fillWithBibKeys(&buffer()); - if (citeStyles_.empty()) - citeStyles_ = biblio::getCiteStyles(engine); - else { - if ((use_styles && citeStyles_.size() == 1) || - (!use_styles && citeStyles_.size() != 1)) - citeStyles_ = biblio::getCiteStyles(engine); - } + citeStyles_ = biblio::getCiteStyles(engine); return true; } Index: src/tex2lyx/text.cpp =================================================================== --- src/tex2lyx/text.cpp (Revision 21664) +++ src/tex2lyx/text.cpp (Arbeitskopie) @@ -104,9 +104,9 @@ } -char const * const known_latex_commands[] = { "ref", "cite", "label", "href", - "index", "printindex", "pageref", "url", "vref", "vpageref", "prettyref", - "eqref", 0 }; +char const * const known_latex_commands[] = { "ref", "cite", "nocite", "label", + "href", "index", "printindex", "pageref", "url", "vref", "vpageref", + "prettyref", "eqref", 0 }; /*! * natbib commands.