From: Julien Rioux Date: Tue, 14 May 2013 19:50:13 +0000 (+0200) Subject: Compute and output numbers for numerical citations. X-Git-Tag: 2.1.0beta1~232 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=bfc731de452ff0dce6fe6c32f316af4dbd5e78ae;p=lyx.git Compute and output numbers for numerical citations. --- diff --git a/lib/layouts/basic.module b/lib/layouts/basic.module index 5cd393babd..5c2867a16f 100644 --- a/lib/layouts/basic.module +++ b/lib/layouts/basic.module @@ -30,7 +30,7 @@ CiteFormat default !startlink {!!} !endlink {!!} - !cite %!startlink%{%label%[[%label%]][[#%key%]]}%!endlink%%!nextcite% + !cite %!startlink%{%label%[[%label%]][[{%numericallabel%[[%numericallabel%]][[#%key%]]}]]}%!endlink%%!nextcite% !nextcite {%next%[[%!sep% %!cite%]]} !nexthashkey {%next%[[%!sep% #%key%%!nexthashkey%]]} diff --git a/lib/layouts/natbib.module b/lib/layouts/natbib.module index 56c6d00243..2848fb9bb0 100644 --- a/lib/layouts/natbib.module +++ b/lib/layouts/natbib.module @@ -89,15 +89,15 @@ CiteFormat numerical !sep , !close ] - !citet %!abbrvauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%#%key%%!endlink%]]}%!nextcitet% - !citealt %!abbrvauthor% %!textbefore%{%dialog%[[#ID]][[%!startlink%#%key%%!endlink%]]}%!nextcitealt% + !citet %!abbrvauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet% + !citealt %!abbrvauthor% %!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitealt% - !hashkey {%dialog%[[#ID]][[%!startlink%#%key%%!endlink%%!nexthashkey%]]} + !hashkey {%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nexthashkey%]]} !nextcitet {%next%[[%!close%%!sep% %!citet%]]} !nextcitealt {%next%[[%!sep% %!citealt%]]} !nexthashid {%next%[[%!sep% #ID%!nexthashid%]]} - !nexthashkey {%next%[[%!sep% %!startlink%#%key%%!endlink%%!nexthashkey%]]} + !nexthashkey {%next%[[%!sep% %!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nexthashkey%]]} cite %!open%%!textbefore%%!hashkey%%!textafter%%!close% citep %!open%%!textbefore%%!hashkey%%!textafter%%!close% diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index dfc29bb330..ed66802269 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -682,6 +682,8 @@ docstring BibTeXInfo::getValueForKey(string const & oldkey, Buffer const & buf, ret = label_; else if (key == "modifier" && modifier_ != 0) ret = modifier_; + else if (key == "numericallabel") + ret = cite_number_; else if (key == "abbrvauthor") // Special key to provide abbreviated author names. ret = getAbbreviatedAuthor(buf, false); diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 3cb28da126..014dcd6929 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -4313,8 +4313,10 @@ void Buffer::updateBuffer(UpdateScope scope, UpdateType utype) const DocumentClass const & textclass = master->params().documentClass(); // do this only if we are the top-level Buffer - if (master == this) + if (master == this) { + textclass.counters().reset(from_ascii("bibitem")); reloadBibInfoCache(); + } // keep the buffers to be children in this set. If the call from the // master comes back we can see which of them were actually seen (i.e. diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index 5241859ac2..bb87925930 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -204,6 +204,9 @@ void InsetBibitem::read(Lexer & lex) docstring InsetBibitem::bibLabel() const { + BufferParams const & bp = buffer().masterBuffer()->params(); + if (bp.citeEngineType() == ENGINE_TYPE_NUMERICAL) + return autolabel_; docstring const & label = getParam("label"); return label.empty() ? autolabel_ : label; } @@ -307,6 +310,17 @@ void InsetBibitem::collectBibKeys(InsetIterator const & it) const BibTeXInfo keyvalmap(false); keyvalmap.key(key); keyvalmap.label(label); + + BufferParams const & bp = buffer().masterBuffer()->params(); + Counters & counters = bp.documentClass().counters(); + docstring const bibitem = from_ascii("bibitem"); + if (bp.citeEngineType() == ENGINE_TYPE_NUMERICAL || getParam("label").empty()) { + if (counters.hasCounter(bibitem)) + counters.step(bibitem, InternalUpdate); + string const & lang = it.paragraph().getParLanguage(bp)->code(); + keyvalmap.setCiteNumber(counters.theCounter(bibitem, lang)); + } + DocIterator doc_it(it); doc_it.forwardPos(); keyvalmap[from_ascii("ref")] = doc_it.paragraph().asString( @@ -321,7 +335,7 @@ void InsetBibitem::updateBuffer(ParIterator const & it, UpdateType utype) BufferParams const & bp = buffer().masterBuffer()->params(); Counters & counters = bp.documentClass().counters(); docstring const bibitem = from_ascii("bibitem"); - if (getParam("label").empty()) { + if (bp.citeEngineType() == ENGINE_TYPE_NUMERICAL || getParam("label").empty()) { if (counters.hasCounter(bibitem)) counters.step(bibitem, utype); string const & lang = it.paragraph().getParLanguage(bp)->code();