here’s a new, more flexible way to do bibliographies in Typst: Pergamon, a package for typesetting bibliographies that is inspired by BibLaTeX.
The key novelty of Pergamon is that the entire bibliography system is implemented within Typst, rather than relying on CSL. This enables a number of advantages:
Styles are very configurable and can be tweaked by passing different arguments to Pergamon. I have reimplemented the standard BibLaTeX styles; you can also implement your own - they’re just Typst functions.
Like in Alexandria, you can split your document into refsections with separate bibliographies.
Like in blinky, you can let paper titles be typeset as hyperlinks (but more robustly than in blinky).
You can typeset a publication list for your CV that contains all the references in your Bibtex file, or you can filter them with a Typst function that selects which references should be shown.
You can selectively highlight individual references in the bibliography, and the highlighting can look however you want because it’s just a Typst function.
… and I’m sure many other things that I haven’t thought of yet.
To get a sense of what this looks like, you can check out this example, which will typeset into this PDF. Here’s a minimal example:
#import "@preview/pergamon:0.1.0": *
// use the BibLaTeX "numeric" style
#let style = format-citation-numeric()
// load a BibTeX file
#add-bib-resource(read("bibliography.bib"))
// start a refsection
#refsection(format-citation: style.format-citation)[
// here's a citation:
#cite("bender20:_climb_nlu")
// print the bibliography for this refsection
#print-bibliography(
format-reference: format-reference(reference-label: style.reference-label),
label-generator: style.label-generator
)
]
Pergamon is ready for use, but I have focused on the features that I care about personally, so I’m sure there is a lot of room for improvement. Please feel free to discuss it here or submit issues on Github and help me improve it!
I don’t have time to look over this in detail right now, but since it sounds like you are replicating much of BibLaTeX’s functionality, does this mean your citatoins/bibliographies handle year disambiguation? Because so far, even with modifid .CSL files, that is currently a problem in Typst’s built-in citation handling:
I certainly haven’t implemented all of BibLaTeX’s functionality yet, but yes, year disambiguation works in both the alphabetic and authoryear citation styles.
You can also specify the order in which the entries are sorted in the bibliography through an option. You can either specify a Biblatex-style sorting string like “nyt”, or you can pass a Typst function that maps the bib entry to something sortable.
Sweet! Yours will probably be my default then until whatever this year disambiguation issue is gets sorted out.
Your package will also make the transition for LaTeX users much smoother. Honestly, it might be a package that should be listed on the “Guide for LaTeX Users” page.
Thank you for the kind words! They mean a lot coming from you.
I was very grateful that you already figured out how to do multiple bibliographies through label prefix addition in Alexandria - that saved me a lot of work when I implemented my refsections. I’m a little proud that Pergamon handles them a little more transparently - you don’t have to specify the prefix yourself, and you don’t have to add the prefix when you cite the papers. But the basic idea is of course just yours.
yeah, Alexandria’s API is probably not ideal in that regard. Although refsections sounds like bibliographies can only be used in disjunct parts of the document with Pergamon, is that correct?
fwiw, I have written down some thoughts about multiple bibliography handling here: https://typst.app/project/rOOEGr1WPuYxg25tAkEz09. I would be interested in how much or little this matches what Pergamon does. Also, if you have thoughts in general you could chime in at the Bibliography forge on Discord
Hi, thank you for the pointer to the Discord channel - I had no idea it existed, or that these discussions were going on. I’ll go and say hi on the channel
I read your note on multiple bibliographies. Perhaps you’d be interested in checking out how I addressed these exact points in Pergamon:
I tacitly assume that there are no duplicate keys when you import multiple bibliographies (but I don’t generate errors right now if there are).
Pergamon doesn’t use the @ symbol to cite papers, but if it did, I would argue that using the same label for a bib entry and a heading should just not be allowed. Users have control over both their bib keys and their heading labels, so we could leave it up to them to resolve such conflicts.
One bibliography per chapter is trivial - just put each chapter in its own refsection.
Different refsections can have different citation styles.
Filtering of bib entries can be defined simply by passing a Typst function that returns true on the entries that the bibliography should contain.
I have thought about adding a mechanism in which each reference remembers from which Bibtex file it was loaded, so we could filter by source file, but haven’t implemented it yet. It would not be difficult.
Of course, all of this is under the assumption that you can live without CSL, which may be a tall order if the citation style your journal requires exists in CSL but would require work to build for Pergamon.