Cannot specify PMID/PMCID through BibLaTeX input
Hi, Some scientific grants require PMCID or PMID fields in citations. They are defined as standard variables in the CSL spec. Zotero provides a nice CSL for NLM grant proposals that works fine creating a bib with its GUI.
However, PMCID/PMIDs are not shown when using the above CSL file in Typst. I've tried in the online app (example: https://typst.app/project/rFgaiSlKEcITlBZVkRVwkD), and locally using Typst version 0.12.0.
Seems related to #91 and #162. My naive take... the respective variables are defined in src/csl/taxonomy.rs, but not in src/interop.rs.
Thanks for all the dev effort! Please let me know if you need any more info.
The PMID/PMCID fields are not supported in biblatex (or bibtex). See (§3.14.7 of the biblatex documentation for how you should encode this in biblatex.
Your example works fine if you write a hayagriva file directly.
Thanks for the quick fix and response! I can confirm I'm able to include PMID and PMCIDs when using a haragriva file. To note for you and/or future users:
- When exporting a bibliography in Zotero, the default BibLaTex and BibTeX options do not place PMIDs in the eprint field. I had to use the Better BibTex extension's 'Better BibLaTex' option. This was part of my issue.
- NIH training grants (see page 43 in the instructions) prefer PMCIDs over PMIDs when available, but articles with PMCIDs will always also have a PMID.
- When using a hayagriva file this logic from the above CSL file works if both are included in the
serial-numberfield. - AFAICT only one eprint entry is allowed.... which defaults to the PMID when exporting as described above. PMCID remains in its own field, which means it'd be ignored even with the above fix.
- When using a hayagriva file this logic from the above CSL file works if both are included in the
TLDR: Both PMID and PMCIDs should be added to serial-number, but I can't see how that's possible without hacking around the specs.
I noticed another small problem. Please let me know if I should rename this issue to something more generic or create a new issue.
In src/csl/rendering/mod.rs, it seems PMID/PMCIDs are automatically turned into hyperlinks (e.g. PMCID: PMC11410365). This feels like something that should be handled by the style sheet, not hard-coded, especially because hypertext is usually not allowed in NIH grant applications.
Okay, hopefully that's all the small pain points! Thanks again, using Typst for my application would be quite nice.
Happy to help!
I noticed another small problem. Please let me know if I should rename this issue to something more generic or create a new issue.
In
src/csl/rendering/mod.rs, it seems PMID/PMCIDs are automatically turned into hyperlinks (e.g. PMCID: PMC11410365). This feels like something that should be handled by the style sheet, not hard-coded, especially because hypertext is usually not allowed in NIH grant applications.
I think opening a new issue for this would be good. That seems like a more generell issue.
As was observed, the hayagriva file format does support including PMID and PMCID separately as part of serial-number. Translating the .bib file in the example using the hayagriva CLI (or this website) and manually adding pmid and pmcid like so:
test_article:
type: article
title: Title
author: Doe, Jane
date: 2024-12
page-range: 1–99
url: https://example.org/
serial-number:
pmcid: PMC3985
pmid: 54678
parent:
type: periodical
title: Testing Journal
volume: 3
...causes the PMID and PMCID to be properly displayed and picked up by the styles.
So the problem is strictly related to conversion from .bib.
The PMID/PMCID fields are not supported in biblatex (or bibtex). See (§3.14.7 of the biblatex documentation for how you should encode this in biblatex.
If I understood correctly from my initial research, using eprint and eprinttype is mandated by the BibLaTeX standard as you mention, but BibTeX doesn't appear to provide any specifically parseable alternative by default, so a non-standard PMID field would be required, which seems to explain why zotero-betterbibtex uses it for BibTeX (https://github.com/retorquere/zotero-better-bibtex/blob/c617185750df065f597a54b447a5b71f690777e4/translators/bibtex/entry.ts#L829-L840), but not for BibLaTeX. Still, technically hayagriva strives to support BibLaTeX, so I believe using eprint and eprinttype is the way to go, noting that it can't support some form of "passthrough" as it needs to convert fields to CSL variables.
However, the BibLaTeX standard does not mention anything about PMCID either, which is interesting (noting that consequently zotero-betterbibtex, near the linked snippet, does not translate the PMCID field at all). We'd have to consider that, and perhaps add an exception to biblatex to allow a PMCID field as a consequence.
In src/csl/rendering/mod.rs, it seems PMID/PMCIDs are automatically turned into hyperlinks (e.g. PMCID: PMC11410365). This feels like something that should be handled by the style sheet, not hard-coded, especially because hypertext is usually not allowed in NIH grant applications.
Technically, this can be ignored by users of hayagriva. Indeed, adding the following show rule to your Typst example, before the bibliography, strips the hyperlinks from the bibliography's output, so you can use this:
#show bibliography: it => {
show link: it => it.body
it
}
#bibliography(...)
I'll keep this open while we decide regarding the inclusion of the non-standard PMID and PMCID fields.
However, it is at least now possible to cite from PubMed sources and have styles recognize the PMID, according to the BibLaTeX standard, with eprint / eprinttype as below.
@article{test_article,
title = {Title},
volume = {3},
url = {https://example.org},
pages = {1--99},
journaltitle = {Testing Journal},
author = {Doe, Jane},
date = {2024-12},
eprint = {54678},
eprinttype = {pubmed},
}
Thank you both for the work on this! I finally had a chance to try it out, using both Hayagriva CLI v0.8.1 and Typst release candidate 0.13.0. Both now work as expected.
~~One thing to note: The Zotero extension described above associates the PMID value with eprinttype = {pmid}, rather than eprinttype = {pubmed}.~~
- Turns out the above is already known and very recently addressed within the extension
- In the interim, a quick
seddoes just fine.
Oh, and thanks for the code snippet re stripping hyperlinks in Typst. It still does feel odd to me that the 'backend' bibliography tool would apply its own formatting outside of what's defined in a user-provided CSL. Not to nit-pick; it's only b/c having 'hidden' (clickable and/or not full url) external links in official grant submissions can hypothetically flag your application (you're not allowed to provide information outside the page limits, security concerns, etc.). So I'd say not linking by default would make more sense.
Otherwise than that and however you decide to handle the odd PMCID case, this looks good to me!