pandoccslpandoc-citeproc

Organizing references by year in Pandoc when generating HTML


I am relatively new with Pandoc and I am trying to generate an HTML file with my publications to put up on my website. I'd like to have the publication list numbered and organized by year first, with the most recent first and the oldest last.

I can get the numbering fine with the proper csl file, but I can't get the year sorting. The problem is that I'm not first author in all my publications, so what ends up happening is that they are organized alphabetically first and then by date, which is not what I want.

I can get the result I want when generating a PDF by using biblatex with the option sorting=ydnt (Year (Descending), Name, Title), but since Pandoc doesn't use biblatex to generate a list of references to HTML, I can't use this tactic here.

The only way I can see how to possibly solving this is to get a citation style in the Zotero style repo that does what I want, but I haven't been able to find one. So I'm trying to modify one to do it, but without success.

This answer teaches a way to change the sorting style, so I'm trying to manually change the sorting style of the Proceedings of the Royal Society B style. Specifically I'm changing

    <sort>
      <key variable="citation-number"/>
    </sort>

to

    <sort>
      <key macro="issued" sort="descending"/>
      <key macro="author"/>
    </sort>

But that doesn't work (probably because that only changes the sorting of the text citations, not the reference list). I've tried a couple of other things, but I can't find something that works!

This doesn't matter much I guess, but I'm using Pandoc 2.7.3, citeproc version 0.16.2 and the file that I'm running on is:

---
bibliography: selectedpubs.bib
nocite: '@*'
linestretch: 1.5
fontsize: 12pt
output:
  html:
    output: pubpage.html
    filter: pandoc-citeproc
    csl: prsb2.csl
...

The file prsb2.csl is just the Proceedings of the Royal Society B csl.


Solution

  • You have the right idea, but misunderstood the linked thread. Instead of changing the sort keys for the citation, you'll want to add sorting to the bibliography, i.e.

    <bibliography second-field-align="flush" et-al-min="11" et-al-use-first="10">
       <sort>
          <key macro="issued" sort="descending"/>
          <key macro="author"/>
        </sort>
    <layout>
    

    Instead of modifying a style, you could also use the APA-CV style that already exsits on the repository