Citation style allowing to define my own citation labels?

Hello!

For internal documents I want to use a citation style, where the citation labels are user-defined.

For LaTeX I did this by using BetterBibTex to create the citation keys, customize and pin them where needed, and using "latex makebst" to create a custom style, that used cite keys as the citation labels.

For Word processor support, the closest I can find is the DIN 1502-2 style, which uses the "citation-label" variable and is similar to the "abbrev" BibTeX style.

Is there any such option available?
«1
  • @emilianoeheyns What is the setting in BBT to add the citekey to the CSL data?
  • That overwrites the csl note field. If there is a better field I'd love to hear about it. This was the least-damaging option I could think of.
  • That overwrites the csl note field. If there is a better field I'd love to hear about it. This was the least-damaging option I could think of.
  • edited December 17, 2021
    Thanks, that works.

    Though the CSL file linked in the BBT manual does not work, so I created my own. Looks like I did something wrong. It worked now.

    However, I noticed that when exporting to "CSL Json", the cite key is already included as "id" field (see example below), yet when trying to use the "id" in a CSL format, it becomes a numeric ID.

    Any idea, where that discrepancy comes from?

    [
    {
    "id": "wiki:RungeKutta",
    "type": "entry-encyclopedia",
    "abstract": "In numerical analysis, the Runge–Kutta methods (English: (listen) RUUNG-ə-KUUT-tah) are a family of implicit and explicit iterative methods, which include the well-known routine called the Euler Method, used in temporal discretization for the approximate solutions of ordinary differential equations. These methods were developed around 1900 by the German mathematicians Carl Runge and Wilhelm Kutta.",
    "container-title": "Wikipedia",
    "language": "en",
    "note": "wiki:RungeKutta",
    "source": "Wikipedia",
    "title": "Runge–Kutta methods",
    "URL": "https://en.wikipedia.org/w/index.php?title=Runge–Kutta_methods&oldid=1037873708",
    "accessed": { "date-parts": [ [ "2021", 9, 14 ] ] },
    "issued": { "date-parts": [ [ "2021", 8, 9 ] ] }
    }
    ]

    For reference, I am not citing Wikipedia in a publication, but in an internal literature- document.

  • edited December 17, 2021
    Though the CSL file linked in the BBT manual does not work, so I created my own.
    Others have used this successfully, so I don't have any insights on why it did not work for you.
    However, I noticed that when exporting to "CSL Json", the cite key is already included as "id" field
    That's an export by Better CSL JSON, not the default CSL JSON exporter. The default CSL JSON exporter does not have these citekeys.
    Any idea, where that discrepancy comes from?
    I put the key there because for export it makes sense to have a meaningful key that refers to the item which can be used in eg markdown. But for the zotero-internal use, they need to refer to the actual items in your database, and Zotero only knows those by their itemID.
  • edited December 17, 2021
    There seems to be an unexpected limitation here: If the citation key contains a ":" (e.g. here "wiki:RungeKutta"), then the output of
    <text variable="note"/>
    will be
    [CSL STYLE ERROR: reference with no printed form.]

    Regarding the example style, upon accepting installation directly through the in-browser popup, it worked. So, it seems like I did something wrong before.

  • Could that be this problem?
  • Could that be this problem [#1960]?
    Seems unrelated. My latest BBT update is from December 15th, i.e. newer than when that ticket was reported "working" by the original reporter.
  • Then I don't know why that same style doesn't work for you. But if you have one that works, can I get a copy? Could prevent the same thing to happen to others.
  • Sorry, I got two separate issues conflated here.

    Your style only didn't work, because I did something wrong when installing and got an error message. Just installing directly from the in-browser prompt of the extension worked.

    A separate issue is that apparently punctuation in the cite key can break something, as in the screenshot. In that case, if I use <text macro="citation-key"/> instead of <text variable="note"/> with

      <macro name="citation-key">
    <text value="#"/>
    <choose>
    <if match="any" variable="note">
    <text variable="note" form="short"/>
    </if>
    <else>
    <text variable="citation-label"/>
    </else>
    </choose>
    </macro>

    it "works", but with the unwanted fall-back label only. I.e. it looks like the : in the cite key somehow messes up the export into the "note" field.

  • I don't know why citeproc would trip on a : being in the note field.
  • That’s probably citeproc’s Key: Value syntax (it does not limit extraction to only valid CSL fields)

    CSL 1.0.2, launching officially on Jan 1, has citation-key and citation-label variables, so embedding the key in Extra with citation-key would be good
  • That is an excellent diagnosis. That leaves the question whether there is a better field to stuff this in in the interim.

    I can just add the new format as an variant of the existing behavior. Any idea on when Zotero would upgrade to 1.0.2?
  • CSL 1.0.2 just adds new terms, types, and variables, so nothing to upgrade on Zotero’s side.

    If a key is stored as
    Citation key: Key:withColon

    I think it should work
  • edited December 17, 2021
    That is great, because that is already the format I use for pinned keys. So all I'd need to do then is do an on-the-fly pseudo-pin when the CSL is being generated. And then styles could just use the citation-key variable, today? The citeproc in Zotero already supports this?
  • Yes, it should be usable right now
  • Fantastic. @"Bauer.KD", if you open an issue on github, I'll get you a test build.
  • Citation label would be the preferred variable for actual appearance in a document ala WiHe21, so maybe an option to pin with that variable?
  • Citation label would be the preferred variable for actual appearance in a document ala WiHe21, so maybe an option to pin with that variable?
    Probably not, because citation-label is distinct from citation-key. The use of citation keys as labels is useful for internal documents and drafts, but it probably should not interfere with how the label looks in other citation styles. (Though currently only one style in the repository actually uses citation-label as the label).
  • I have created https://github.com/retorquere/zotero-better-bibtex/issues/2002 for the colon issue, since it may be separate. Writing the one for using citation-key now.
  • They're the same issue
  • edited December 17, 2021
    https://github.com/retorquere/zotero-better-bibtex/issues/2003 for support of `citation-key'.
    They're the same issue
    At least, support for citation-key would make the colon issue irrelevant, unless it also shows up there. It is anyway strange, that the colon makes problems when stored in the "Note" field for encoding the key, but not when e.g. part of a title. I can only guess, that the colon is somehow escaped when stored in the .title, but not when assigned to .note in better-bibtex.ts:108.
  • The colon behavior is that citeproc-js allows extra CSL variables to be stored in `note`. This is to enable additional fields to be added to items in Zotero when a type lacks a certain field (eg, DOI for many types). The syntax for that is
    Key: Value

    citeproc-js does not restrict this extraction to only valid CSL variables, so if you have a key like
    Citation: Key

    Then, that is going to get extracted as the `Citation` variable, not left in `note`
  • So the correct solution here would be to write
    citation-key: key:with-colon
    to the "note" field?

    Or maybe for backwards compatibility if citeprocNoteKey is enabled,

    citation-key: key:with-colon
    note: key:with-colon
  • Yes exactly.

    Citation key: key:with-colon

    Would also work
  • edited December 18, 2021
    Does not seem to work, see https://github.com/retorquere/zotero-better-bibtex/issues/2002#issuecomment-997175030

    The note field contains Citation-key: SOMEKEY now in that test build, but it does not translate into an accessible <text variable="citation-key"/>.

    Which makes it even stranger, that having : in the citation key breaks the "note" field in the release version of BBT with "citeprocNoteKey=True".
  • @bwiernik having Citation Key: something set in extra does not seem to lead to the citation-key variable being available to the style.
  • Okay, might need an update in Zotero for that spelling. citation-key will work
Sign In or Register to comment.