Open paulvickers opened 8 years ago
jekyll-scholar renders bibliographies using <ol>
tags, so the numbering you see is added by HTML/CSS simply because those are ordered lists. Therefore, to answer your question, I doubt that it's possible to achieve continuous numbering across multiple lists with CSS.
To accomplish this, you'll have to turn off the numbers in your CSS and instead insert the numbers in your template. You'll need a custom template for that; we expose the index of each item in the current batch to template as index
so you'd have to add that to some global state at the moment to keep count across multiple groups. Ideally, we should expose a group-global index/count to the template, but that's currently not implemented.
There are some things you can control in HTML:
Ah, that's pretty cool, I wasn't aware that this can be done in HTML. (But yes, you'd still have to use a custom template, even to set the <ol>
attributes)
+1, @inukshuk Is there a way to get the number of entry returned by query? such as: {% bibliography --query @*[year = {{ pub_year }} && status != review && status != press] %}
Do you mean the total number of entries? Or the respective number of each entry in the list?
For the former, you would have to add your tag bibliography-count
or something like that which takes the query and returns the length.
For the latter, we're exposing the index to citeproc, but not to the template it seems. Would be easy to do (but it would still be the index in the current group).
I'm not sure if this is related, but I'm also trying to get custom numbering. Seems like the jekyll-scholar-extras
repo had that option. But I can't make it work.
I've been searching for information on how to modify the CSL to do the custom numbering, e.g., add a global counter or even create a different number per type of publication (like J1, J2, C1, C2, and so on).
Any pointer or readings for a newcomer to jekyll and CSL?
I managed to use inverse continuous numbering (over the groups by years) by doing a reset on the superior <h1 class="bibliography" style="counter-reset:bibitem 10">
And then enforcing manually
ol.bibliography > li:before{content: counter(bibitem) ".";}
ol.bibliography > li {counter-increment: bibitem -1;}
The only thing that is still manual is the reset to 10 (which corresponds to 9 Items); so the ony thing I am missing is a command printing the number of items a bibliography
call would print.
Furthermore one can of course use any html element to reset the counter to a value, not only an h1
.
@kellertuer Forgive the naive question, but where do you put this CSS? What file?
In your favourite .css
file containing the style of your webpage, the two css-lines should be entered
ol
is a numbered list, >
refers only to direct children (so not grand children). And the
<h1 class="bibliography" style="counter-reset:bibitem 10">
(or any other element containing the style=
part) should be entered in jekyll directly before your call of {% bibliography %}
I hope this helps. As soon as I have a working example online, i will gladly share it here :)
Thanks for that. I tried it and now I'm getting double numbers in the ol element like this:
2017
Journal articles
2. 84. Title, author...
1. 83. Title, author...
Book Chapters
2. 82. Title, author...
1. 81. Title, author..
etc.
???
Oh, I forgot to turn off the numbers in ol
; i'm sorry (the first CSS line appends the 2., 1.,... in front of li)
You have to add the line
ol.bibliography { list-style-type: none; }
to turn the (old) numbers off.
Fabulous, thanks! I do so little with CSS that none of it ever gets retained in my head. :-)
@kellertuer There is a bibliography_count
tag that would return the number of publications. Could you try that and see if it helps?
Thanks, that looks quite promising, Is that already available by update? I'm at 5.10.3 in my installation. I think it should work as you say, since I only have print the number +1 at above mentioned counter-reset:bibitem
. I'll post an update here if it does; thanks for your work :)
Oh, that was faster that I imagined – got 5.11.0 and that included the new tag. Thanks @rseac for implementation. To be complete I now do
{% capture numJournalPapers %}
{% bibliography_count --group_by year --group_order descending %}
{% endcapture %}
<h1 class="bibliography" style="counter-reset:bibitem {{numJournalPapers|plus:1}}">Journal Papers</h1>
{% bibliography --group_by year --group_order descending %}
Together with the CSS style above
ol.bibliography { list-style-type: none; }
ol.bibliography > li:before{content: counter(bibitem) ".";}
ol.bibliography > li {counter-increment: bibitem -1;}
This way the years (which are in h2
tags) do as they should and only on h1
a reset happens – which is automatically to the right value now with your extension. Awesome!
This way, adding a paper to the standard file (from config) directly extends this list, without further ado. That's really neat (in the previous version above you had manually to adapt the number in h1
).
The result can be seen on my homepage, see http://ronnybergmann.net/publications.html
@kellertuer: This is great to see. Would you be able to create an independent example illustrating your technique and contributing to jekyll-scholar-examples?
Oh, that looks like a neat repository, to have a few more “How to do this” in jekyll-scholar
since the example written above took me a little bit to accomplish. Maybe one could even get the examples to also display CSS and Rub code in the compiled example – but I'll think about that and open an issue over there :)
When grouping publications by year, the numbering restarts with each year, e.g.:
Is there a simple way of:
Thus: