Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot specify PMID/PMCID through BibLaTeX input #260

Open
RyanVidegar-Laird opened this issue Dec 13, 2024 · 7 comments · Fixed by #261
Open

Cannot specify PMID/PMCID through BibLaTeX input #260

RyanVidegar-Laird opened this issue Dec 13, 2024 · 7 comments · Fixed by #261

Comments

@RyanVidegar-Laird
Copy link

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.

@Drodt
Copy link
Contributor

Drodt commented Dec 15, 2024

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.

@RyanVidegar-Laird
Copy link
Author

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-number field.
    • 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.

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.

@RyanVidegar-Laird
Copy link
Author

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.

@Drodt
Copy link
Contributor

Drodt commented Dec 16, 2024

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.

@PgBiel PgBiel linked a pull request Feb 1, 2025 that will close this issue
@PgBiel
Copy link
Contributor

PgBiel commented Feb 1, 2025

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(...)

@PgBiel PgBiel changed the title CSL Styles that use PMID/PMCID do not work Cannot specify PMID/PMCID through BibTeX input Feb 1, 2025
@PgBiel PgBiel changed the title Cannot specify PMID/PMCID through BibTeX input Cannot specify PMID/PMCID through BibLaTeX input Feb 1, 2025
@PgBiel
Copy link
Contributor

PgBiel commented Feb 1, 2025

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},
}

@PgBiel PgBiel reopened this Feb 1, 2025
@RyanVidegar-Laird
Copy link
Author

RyanVidegar-Laird commented Feb 18, 2025

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}.

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants