Prose-style citation and custom CSLs

Hello all,

I’m writing a document that has a bibliography, whose style is defined via a custom CSL file (part of a style template that I adapted for my document/project: splendid-mdpi – Typst Universe ).

I have a small problem with the bibliography style I use: whenever I #cite(..., style: "prose"), I expect to get something like:

“F. Lastname et al. [3]”

but instead I get:

“F1. Lastname1; F2. Lastname2; F3. Lastname3 [3]”.

This issue doesn’t manifest with built-in bibliography styles, like APA7; when I use those, I get the behaviour I expect. I only experience the issue with the custom CSL template I use.

I’d like to adjust things, so I can obtain the prose style citation I want.

While I’m aware of alternatives/solutions based on #show rules, like the one documented at How to cite in prose using only author's last name?, I’d like to fix my issue at the CSL file level, since its content is under my control.

So, my question is: can anyone point me to resources/doc. to understand what part of the CSL spec. controls the output generated by Typst when one uses #cite(..., style: "prose")? This is so I can adjust the CSL myself and perhaps even propose the changes as a pull request to the author of the original template.

Thanks for reading,

Does this work?

#show cite.where(form: "prose"): set cite(style: "prose.csl")
#cite(<a>, form: "prose")

#bibliography(
  bytes(
    ```bib
    @book{a,
      date = {2000},
      author = {First Last1 and First Last2 and First Last3},
      title = {Book},
    }
    ```.text,
  ),
  style: "ieee",
)
<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" version="1.0" class="in-text">
  <info>
    <title/>
    <id/>
    <category citation-format="numeric"/>
  </info>
  <citation et-al-min="3" et-al-use-first="1" initialize-with=".">
    <layout>
      <text variable="citation-number" prefix="[" suffix="]"/>
    </layout>
  </citation>
  <bibliography>
    <layout>
      <text value="(irrelevant)"/>
    </layout>
  </bibliography>
</style>

Explanation

There isn’t a dedicated <layout> in CSL that controls cite(…, form: "prose").
Instead, Typst collects info from the CSL style and constructs the citation with a special logic. Refer to StyleContext::do_citation in hayagriva’s source code for the details.

The key points in this case are as follows.

  • Name attrs on <citation> controls how names are formatted.

    • et-al-min="3" and et-al-use-first="1" keep only the first author if there’re at least three authors.
    • initialize-with="." renders First as F. (abbreviated with a dot).
  • <category citation-format="numeric"/> tells Typst that this is not an author-date style, so Typst will use the provided citation <layout> properly.