typst / hayagriva

Rusty bibliography management.
Apache License 2.0
319 stars 48 forks source link

Fails to accurately print nonnumeric page numbers #170

Open jkunimune opened 4 months ago

jkunimune commented 4 months ago

Currently Hayagriva converts all page numbers to integers before using them in the bibliography. This is a problem because many journals these days don't number their pages sequentially and include letters in the "page numbers". Right now Hayagriva truncates nonnumeric letters, which leaves the citations incomplete.

For example, Review of Scientific Instruments issues each article it publishes a unique six-digit alphanumeric code and uses that in lieu of a page number. See Rev. Sci. Instrum. 87, 11E201 (2016), which is article 11E201. The pages of the PDF are numbered 11E201-1 through 11E201-7, and the autogenerated BibTeX file contains pages = {11E201}. Putting this BibTeX file into Hayagriva truncates the page number to "11".

I think in general if pages (or page-range in YAML) is a string that doesn't contain dashes, it should print that string as-is rather than casting it to an integer and treating it as a starting page.

There's a similar issue with Physics of Plasmas, which uses fully numeric article codes but gives a lot of them leading zeros. See Phys. Plasmas 29, 072711 (2022) (the pages of the PDF are numbered 072711-1 through 072711-13), which has its page number shortened to 72711 by Hayagriva. The loss of leading zeros is not as bad as the loss of the alphabetical characters since there's at least enough information to find the article, but it's still nonideal, as the journal wants you to cite it with the leading zero, and BibTeX formats it with the leading zero.

Example YAML file:

~~~yaml bachmann16: type: article author: ["Bachmann, B.", "Hilsabeck, T.", "Field, J.", "Masters, N.", "Reed, C.", "Pardini, T.", "Rygg, J. R.", "Alexander, N.", "Benedetti, L. R.", "Döppner, T.", "Forsman, A.", "Izumi, N.", "LePape, S.", "Ma, T.", "MacPhee, A. G.", "Nagel, S. R.", "Patel, P.", "Spears, B.", "Landen, O. L."] parent: title: Rev. Sci. Instrum. volume: 87 date: 2016 page-range: "11E201" doi: "10.1063/1.4959161" kunimune22: type: article author: ["Kunimune, J. H.", "Rinderknecht, H. G.", "Adrian, P. J.", "Heuer, P. V.", "Regan, S. P.", "Séguin, F. H.", "Gatu Johnson, M.", "Bahukutumbi, R. P.", "Knauer, J. P.", "Bachmann, B. L.", "Frenje, J. A."] parent: title: Phys. Plasmas volume: 29 date: 2022 page-range: "072711" doi: "10.1063/5.0096786" ~~~ With the "american-physics-society" style built into Typst, this produces > [1] B. Bachmann et al., Rev. Sci. Instrum. **87**, 11 (2016) > [2] J. H. Kunimune et al., Phys. Plasmas **29**, 72711 (2022) But it should produce > [1] B. Bachmann et al., Rev. Sci. Instrum. **87**, 11E201 (2016) > [2] J. H. Kunimune et al., Phys. Plasmas **29**, 072711 (2022)
Code-Mozart commented 3 months ago

I have the same issue as the Springer journal also uses page identifiers.