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

Incorrect formatting of collapsed in-text citations when using collapse and after-collapse-delimiter attribute in CSL #154

Open
csimide opened this issue Apr 15, 2024 · 1 comment

Comments

@csimide
Copy link

csimide commented Apr 15, 2024

I have encountered an issue with the collapsing behavior of consecutive citation numbers in in-text citations when using the bibliography function in Typst. Using the citation style "gb-7714-2015-numeric", the relevant CSL code for citation rendering is as follows:

<citation collapse="citation-number" after-collapse-delimiter=",">
  <layout vertical-align="sup" delimiter="," prefix="[" suffix="]">
    <text macro="citation-layout"/>
  </layout>
</citation>

According to this style, in-text citations should be rendered as superscript numbers enclosed in square brackets, e.g., [1]. If multiple references are cited at the same location, their numbers should be separated by commas, e.g., [1,3,5]. If the cited reference numbers are consecutive, they should be collapsed, e.g., [1-3,5]. Zotero also renders in-text citations in this manner.

However, in Typst, the collapsing behavior does not work as expected. When citing multiple consecutive references at the same location, Typst displays them as [1,3] instead of the expected [1-3]. Similarly, when citing references 1, 2, 3, and 5 at the same location, Typst renders them as [1,3,5] instead of the expected [1-3,5].

1 - @TestBook_1
2 - @TestBook_2
3 - @TestBook_3
4 - @TestBook_4
5 - @TestBook_5

Test 1: Expected #super[[1-3,5]] Actual @TestBook_1 @TestBook_2 @TestBook_3 @TestBook_5

Test 2: Expected #super[[1,3,5]] Actual @TestBook_1 @TestBook_3 @TestBook_5

Test 3: Expected #super[[1-3]] Actual @TestBook_1 @TestBook_2 @TestBook_3

#bibliography("ref.bib", style: "gb-7714-2015-numeric")

image

Through testing, I found that in Typst/hayagriva the after-collapse-delimiter attribute in the CSL file controls the delimiter used for collapsing consecutive numbers. Changing after-collapse-delimiter="," to after-collapse-delimiter="-" results in the expected behavior, displaying [1-3,5].

However, according to the CSL 1.0.2 documentation - Cite Collapsing, the after-collapse-delimiter attribute is described as:

Specifies the cite delimiter to be used after a collapsed cite group.

Based on the example provided in the documentation, I think this attribute should control the comma (,) in [1-3,5], not the hyphen (-). I have tested other numeric citation styles with the collapse attribute and observed similar issues.

I kindly request guidance on whether this behavior is intended or if there is a potential issue with the collapsing implementation in Typst/hayagriva.

@reknih
Copy link
Member

reknih commented May 8, 2024

This is indeed a bug, thank you for spotting! A PR would be most appreciated.

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

No branches or pull requests

2 participants