# Citation-label formatting

**URL:** https://discourse.citationstyles.org/t/citation-label-formatting/1585
**Category:** CSL Development
**Created:** [November 29, 2019, 7:52pm UTC](https://discourse.citationstyles.org/t/citation-label-formatting/1585 "2019-11-29T19:52:02Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![bwiernik](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/bwiernik/32/438_2.png) [@bwiernik](https://discourse.citationstyles.org/u/bwiernik)
#### Post date: [November 29, 2019, 7:52pm UTC](https://discourse.citationstyles.org/t/citation-label-formatting/1585/1 "2019-11-29T19:52:02Z")

</div>

Currently, CSL assumes that `citation-label` is provided as flat text by the supplying client. For `label` citation styles, styles differ regarding their preferred citation label, however (e.g., see [https://forums.zotero.org/discussion/80232/citation-label-trying-to-prepare-iste-stylesheet#latest](https://forums.zotero.org/discussion/80232/citation-label-trying-to-prepare-iste-stylesheet#latest)). The main differences are whether to use 3 or 4 letters to define the label, whether to include a year, and how to handle disambiguation and items without authors.

Currently, citeproc-js has a hardcoded pattern: `Aaaa00:AaAa00:AaAA00:AAAA00`. Jursim has a preference to customize this pattern. Other clients could add similar preferences, but this seems like something that may best be handled by CSL rather than an ad-hoc solution determined by clients.

There was this discussion a while back when citeproc-js added its default format, but that discussion seemed to assume that `citation-label` referred to a BibTeX key, not a rendered citation label ala DIN 1505-2 or similar styles.

If this isn’t something we want to define in CSL, it seems like at least the processors might want to include a hook for generating or supplying `citation-label`, in the same way that citeproc-js does. @cormacrelf

---

<div class="post-metadata">

### Author: ![cormacrelf](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@cormacrelf](https://discourse.citationstyles.org/u/cormacrelf)
#### Post date: [November 30, 2019, 3:40am UTC](https://discourse.citationstyles.org/t/citation-label-formatting/1585/2 "2019-11-30T03:40:12Z")

</div>

If by client you mean processor, then I think I follow. The most obvious thing I can think of is a format string, not unlike formatting dates with “%Y” etc. Some more style guide requirements would help design one that can do them all.

---

<div class="post-metadata">

### Author: ![bwiernik](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/bwiernik/32/438_2.png) [@bwiernik](https://discourse.citationstyles.org/u/bwiernik)
#### Post date: [December 1, 2019, 1:18pm UTC](https://discourse.citationstyles.org/t/citation-label-formatting/1585/3 "2019-12-01T13:18:05Z")

</div>

citeproc-js uses the format `Aaaa00:AaAa00:AaAA00:AAAA00`

> <https://github.com/Juris-M/propachi-vanilla/issues/4>
>
> @fbennett citeproc-js currently has the formatting for citeproc.opt.trigraph property defaulting to Aaaa00:AaAa00:AaAA00:AAAA00. Since neither Zotero nor Mendeley (nor other users of...

---

<div class="post-metadata">

### Author: ![cormacrelf](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@cormacrelf](https://discourse.citationstyles.org/u/cormacrelf)
#### Post date: [December 3, 2019, 12:46am UTC](https://discourse.citationstyles.org/t/citation-label-formatting/1585/4 "2019-12-03T00:46:59Z")

</div>

Is that a well-known format string that I’m just unfamiliar with? How does it work?

---

<div class="post-metadata">

### Author: ![bwiernik](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/bwiernik/32/438_2.png) [@bwiernik](https://discourse.citationstyles.org/u/bwiernik)
#### Post date: [December 4, 2019, 11:03pm UTC](https://discourse.citationstyles.org/t/citation-label-formatting/1585/5 "2019-12-04T23:03:38Z")

</div>

Sorry, it’s (Format for items with one author):(Formats for items with two authors):(Three authors):(Four or more authors). “A” indicates first letter of an author’s family name, “a” indicates subsequent letters of that author’s family name, “00” indicates the final two digits of the year. So “AaAa00” means “The first and second letter of each author’s name, followed by the last two digits of the date.”

---

<div class="post-metadata">

### Author: ![cormacrelf](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@cormacrelf](https://discourse.citationstyles.org/u/cormacrelf)
#### Post date: [March 11, 2020, 6:08pm UTC](https://discourse.citationstyles.org/t/citation-label-formatting/1585/6 "2020-03-11T18:08:41Z")

</div>

> <https://github.com/cormacrelf/citeproc-rs/blob/3909a107b9449e38f69bd346c125d92b5aa0728f/crates/proc/src/citation_label.rs>

Parsed and rendered. Generalises to more or fewer than the 1, 2, 3,or 4 names. No configuration API available for the processor yet, but that’s soon to change I think, and I would also be happy to make a feature flag for an attribute to configure it in CSL.

---

<div class="post-metadata">

### Author: ![bwiernik](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/bwiernik/32/438_2.png) [@bwiernik](https://discourse.citationstyles.org/u/bwiernik)
#### Post date: [March 11, 2020, 7:20pm UTC](https://discourse.citationstyles.org/t/citation-label-formatting/1585/7 "2020-03-11T19:20:05Z")

</div>

There are at least a few variations on trigraph/label styles in use. I wonder whether it might be a good idea for CSL to provide a simple syntax for customizing them within a label style?

---

<div class="post-metadata">

### Author: ![cormacrelf](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@cormacrelf](https://discourse.citationstyles.org/u/cormacrelf)
#### Post date: [March 12, 2020, 12:28am UTC](https://discourse.citationstyles.org/t/citation-label-formatting/1585/8 "2020-03-12T00:28:30Z")

</div>

Seems like the only sane place would be here:

```xml
<style label-format="Aaaa00:AaAA00:...">
</style>

```

With this to activate it for now:

```xml
  <features>
    <feature name="label-format" />
  </features>

```

It strikes me that mine won’t interpret characters that aren’t A/a/0 as literals to get the space in `ABC 00`, etc. Maybe allow literal A/a/0 with a backslash. It will put a year-suffix on the end, not in the code linked there but a label is a “year” for that purpose. Do people want anything else? Maybe people want the actual citekeys that they use? Not sure I’d ever want that, also probably unlikely in the Zotero community as default is autogenerated only, but maybe people still writing BibTeX would. Maybe people want to pull the `citation-label` variable from the input references as an override. I have actually implemented that already, it rings a bell as being in the test suite. That’s all I can think of.

---

<div class="post-metadata">

### Author: ![bwiernik](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/bwiernik/32/438_2.png) [@bwiernik](https://discourse.citationstyles.org/u/bwiernik)
#### Post date: [March 13, 2020, 12:38am UTC](https://discourse.citationstyles.org/t/citation-label-formatting/1585/9 "2020-03-13T00:38:47Z")

</div>

I would say that is this something that would probably be added as a new node type, like `names`, etc.

---

<div class="post-metadata">

### Author: ![Bruce\_D\_Arcus1](https://avatars.discourse-cdn.com/v4/letter/b/4bbf92/32.png) [@Bruce\_D\_Arcus1](https://discourse.citationstyles.org/u/Bruce_D_Arcus1)
#### Post date: [May 21, 2022, 8:38pm UTC](https://discourse.citationstyles.org/t/citation-label-formatting/1585/10 "2022-05-21T20:38:21Z")

</div>

Just wondering what happened to this?

---

<div class="post-metadata">

### Author: ![bwiernik](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/bwiernik/32/438_2.png) [@bwiernik](https://discourse.citationstyles.org/u/bwiernik)
#### Post date: [May 21, 2022, 11:09pm UTC](https://discourse.citationstyles.org/t/citation-label-formatting/1585/11 "2022-05-21T23:09:55Z")

</div>

This is done [schema/csl-citation-label-format.rnc at v1.1 · citation-style-language/schema · GitHub](https://github.com/citation-style-language/schema/blob/v1.1/schemas/styles/csl-citation-label-format.rnc)
