# Citekey variable?

**URL:** <https://discourse.citationstyles.org/t/citekey-variable/1651>\
**Category:** CSL Evolution\
**Created:** [June 8, 2020, 12:51am UTC](https://discourse.citationstyles.org/t/citekey-variable/1651 "2020-06-08T00:51:35Z")\
**Posts on this page:** 17\
**Page:** 2

<div class="post-metadata">

**Author:** ![Sebastian\_Karcher](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/sebastian_karcher/32/176_2.png) [@Sebastian\_Karcher](https://discourse.citationstyles.org/u/Sebastian_Karcher)\
**Post date:** [June 8, 2020, 3:01pm UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/21 "2020-06-08T15:01:59Z")

</div>

> [@Denis\_Maier](#):
>
> That said, I still don’t really understand what the intended purpose of a citekey variable would be that `id` can not cover. Can someone give an example?

It’s not about not “cover”. it’s about causing implementation issues given existing uses of `id`. E.g., if, say, Mendeley uses a UUID for id that’s used for connecting citations to sources, it can’t just map it to citekey.

Edit: oh, I think I missed the question, which is: why should the citekey be available to CSL styles other than as a citekey? That’s because it’d greatly facilitate traveling between Word and plaintext applications. Has come up a number of times as a request: You could author in Word, then set the citations to citekey and easily convert to LaTeX.

---

<div class="post-metadata">

**Author:** ![Denis\_Maier](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Denis\_Maier](https://discourse.citationstyles.org/u/Denis_Maier)\
**Post date:** [June 8, 2020, 3:15pm UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/22 "2020-06-08T15:15:10Z")

</div>

> [@Sebastian\_Karcher](#):
>
> Edit: oh, I think I missed the question, which is: why should the citekey be available to CSL styles other than as a citekey? That’s because it’d greatly facilitate traveling between Word and plaintext applications. Has come up a number of times as a request: You could author in Word, then set the citations to citekey and easily convert to LaTeX.

Ok, that’s a good use case. It could be possible to do the conversion with pandoc, and extract even the citations with some filter trickery. @retorquere has written a pandoc lua filter that goes the opposite way: produce a word file with linked zotero citations from a markdown source with pandoc style citations. So maybee …

---

<div class="post-metadata">

**Author:** ![Denis\_Maier](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Denis\_Maier](https://discourse.citationstyles.org/u/Denis_Maier)\
**Post date:** [June 8, 2020, 3:26pm UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/23 "2020-06-08T15:26:40Z")

</div>

Let’s say we added `citekey` as a variable for use in style, what would that mean for CSL JSON export? Will that citekey variable replace `id or will we have both variables?

---

<div class="post-metadata">

**Author:** ![Sebastian\_Karcher](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/sebastian_karcher/32/176_2.png) [@Sebastian\_Karcher](https://discourse.citationstyles.org/u/Sebastian_Karcher)\
**Post date:** [June 8, 2020, 3:35pm UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/24 "2020-06-08T15:35:36Z")

</div>

Zotero’s CSL JSON current exports the item URI as id. Only BBT’s CSL JSON uses the citekey. I think leaving that to implementers (i.e. Emiliano and Zotero) is perfectly fine; I don’t see why we would need to prescribe this either way.  
edit: I guess what we do want to prescribe is that they have both and they can but needn’t be identical?

---

<div class="post-metadata">

**Author:** ![Denis\_Maier](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Denis\_Maier](https://discourse.citationstyles.org/u/Denis_Maier)\
**Post date:** [June 8, 2020, 3:40pm UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/25 "2020-06-08T15:40:21Z")

</div>

> [@Sebastian\_Karcher](#):
>
> Zotero’s CSL JSON current exports the item URI as id.

Really? I have just done that, but no URI in id… (maybe BBT patches the standard export translators?)  
Same with bibtex by the way…

(I’m using Juris-M, but I don’t think that should make a difference concerning this.)

---

<div class="post-metadata">

**Author:** ![retorquere](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/retorquere/32/203_2.png) [@retorquere](https://discourse.citationstyles.org/u/retorquere)\
**Post date:** [June 8, 2020, 4:12pm UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/26 "2020-06-08T16:12:09Z")

</div>

Maybee… [https://retorque.re/zotero-better-bibtex/installation/preferences/hidden-preferences/#citeprocnotecitekey](https://retorque.re/zotero-better-bibtex/installation/preferences/hidden-preferences/#citeprocnotecitekey)

Additionally, BBTs Better CSL exporters replace the id with the citekey, but I don’t touch the CSL as it moves through zotero, except for that hidden Pref above, and I don’t touch the standard CSL export.

---

<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:** [June 9, 2020, 4:03am UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/27 "2020-06-09T04:03:05Z")

</div>

Zotero and Mendeley both use their own “uri” field to manage items in document. Dan Stillman recently commented somewhere that they really only include an “id” field because it is required by spec.

(I haven’t checked out Mendeley’s new citation plugin, but I’d be surprised if this had changed.)

pandoc and citation.js seem to be the major consumers of the `id` field. pandoc treats it as a citekey.

citation.js unfortunately seems to treat `citation-label` as a citekey before falling back to `id` as a citekey: [https://github.com/citation-js/citation-js/blob/master/packages/plugin-bibtex/src/output/label.js](https://github.com/citation-js/citation-js/blob/master/packages/plugin-bibtex/src/output/label.js). We should recommend they change that behavior regardless.

Does anyone have a document with Papers citation data in it or know if their data model is documented somewhere?

---

<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:** [June 9, 2020, 4:04am UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/28 "2020-06-09T04:04:05Z")

</div>

If a `citekey` field were added to the data schema, would it also need to be in the CSL style schema? My thought would be “no”.

---

<div class="post-metadata">

**Author:** ![Dan\_Stillman](https://avatars.discourse-cdn.com/v4/letter/d/ecb155/32.png) [@Dan\_Stillman](https://discourse.citationstyles.org/u/Dan_Stillman)\
**Post date:** [June 9, 2020, 7:34am UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/29 "2020-06-09T07:34:11Z")

</div>

> [@bwiernik](#):
>
> Dan Stillman recently commented somewhere that they really only include an “id” field because it is required by spec.

(I think that was `schema`, not `id`.)

In a word processor document, Zotero currently uses the numeric itemID for `id`. But what we do there isn’t really relevant — we can adjust as necessary. We embed URIs in the document that we use to reliably link to items.

When exporting CSL-JSON generally, however, we use a URI for `id`. While we don’t currently use that in any other way, it’s worth noting that, if `id` became a user-editable citekey, there wouldn’t be a guaranteed-permanent reference back to the Zotero item from the CSL-JSON entry. That might be an argument for keeping `id` as an application-provided identifier and adding a separate `citekey` field that was meant to be exposed to the user.

This sort of depends on your view of the world:

1. In a BibTeX-based workflow (as I understand it), you basically make sure that the citation key is set before any export and never touch it again, so the citekey effectively functions as a permanent identifier.

2. If you view CSL-JSON as a data exchange format, a user-editable field, even if it’s semi-permanent, isn’t the same as an application-enforced identifier that’s guaranteed never to change.

3. If you view CSL-JSON as primarily focused on citations, a citekey field, even if user-editable, might make sense as the primary identifier, similar to BibTeX, and permanent linking to internal database entries is simply out of scope.

I don’t have a strong opinion on this. I’d be inclined to go with (2) on principle, but in Zotero we don’t recommend CSL-JSON as a recommended data exchange format beyond citation processing, and that’s not going to change, so (3) seems like a reasonable position.

---

<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:** [June 9, 2020, 9:57am UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/30 "2020-06-09T09:57:00Z")

</div>

I’ve obviously been thinking in terms of 3, but I also in the end don’t have a strong opinion.

If we want to allow 2, then makes sense to add the new variable.

But what about a label style that prints the citekey as the label? That key then needs to be unique within the document.

---

<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:** [June 9, 2020, 1:40pm UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/31 "2020-06-09T13:40:21Z")

</div>

I guess in my view, I mainly see CSL-JSON as filling a similar role as a .bib file for BibTeX.

An option could be to add a citekey variable to the CSL-JSON spec, with the indication that it could be used to in the same manner as a BibTeX citekey with id as a fallback if citekey is unavailable.

That would involve primarily minor changes with two players:

1. pandoc adding citekey as primary source for the citation key. This would be easy enough as existing documents relying on id would still work.
2. citation.js switching citation-label to citekey, which they should anyway.

> But what about a label style that prints the citekey as the label? That key then needs to be unique within the document.

I think this is something we should explicitly not do. Showing the citekey in the document is the realm of un-rendering a citation back into its raw identifier. That’s not a label style ala DIN 1950. If anything, it would a separate recommended API to produce a cite placeholder ala that used by pandoc or Sebastian/Frank’s ODF Scan plug-in for Zotero.

---

<div class="post-metadata">

**Author:** ![Sebastian\_Karcher](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.citationstyles.org/sebastian_karcher/32/176_2.png) [@Sebastian\_Karcher](https://discourse.citationstyles.org/u/Sebastian_Karcher)\
**Post date:** [June 9, 2020, 1:53pm UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/32 "2020-06-09T13:53:06Z")

</div>

+1 for me on this — this seems like the most pragmatic approach to me with very little downsides. Also agree with the 2nd part – that’s why we have citation-label as a separate variable.

---

<div class="post-metadata">

**Author:** ![Denis\_Maier](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Denis\_Maier](https://discourse.citationstyles.org/u/Denis_Maier)\
**Post date:** [June 9, 2020, 2:06pm UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/33 "2020-06-09T14:06:57Z")

</div>

Good for me as well.

---

<div class="post-metadata">

**Author:** ![Denis\_Maier](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Denis\_Maier](https://discourse.citationstyles.org/u/Denis_Maier)\
**Post date:** [June 11, 2020, 8:12pm UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/34 "2020-06-11T20:12:39Z")

</div>

It seems we have some sort a consensus here. I’'ll add an issue to the schema repo issue tracker with @bwiernik’s idea.  
We can still discuss details there, but I want to make sure this doesn’t gets lost.

---

<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:** [June 14, 2020, 5:59am UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/35 "2020-06-14T05:59:11Z")

</div>

Bruce has already opened a PR

---

<div class="post-metadata">

**Author:** ![Denis\_Maier](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Denis\_Maier](https://discourse.citationstyles.org/u/Denis_Maier)\
**Post date:** [June 14, 2020, 6:59pm UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/36 "2020-06-14T18:59:32Z")

</div>

Really? Where? I don’t find it.

---

<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:** [June 14, 2020, 8:26pm UTC](https://discourse.citationstyles.org/t/citekey-variable/1651/37 "2020-06-14T20:26:29Z")

</div>

Nevermind; no, I didn’t add a PR.

[Previous page](https://discourse.citationstyles.org/t/citekey-variable/1651.md?page=1)
