Reference import, Bookends, BibTeX and cite keys

This is only of note for those who want to or must use BibTeX. It is also useful if one writes final output in LaTeX, using local install or a tool like Overleaf. In that context, the link for (body) text cites to reference list items is the ref’s BibTeX cite key.

The cite key is stored after the opening { in the BibTeX item data up to and not including the comm at the end of the line. Here is an example as seen in BBEdit) where the cite key has been underlined in red in the screen grab:

untitled text 618 2025-01-13 10-45-52

I’m importing references from Bookends where the export format is set to BibTeX, so the dragged reference sets the Tinderbox-generated note’s $Text to the BibTeX code. The later includes the cite key but I really want it as an attribute value.

So, I make a String-type user attribute CiteKey and add it to the built-in prototype ‘Reference’ Displayed Attributes. Now I add this to the prototype’s $Edict:

$Text.skipTo("{").captureTo(",","CiteKey");

This ensures the BibTeX cite key is now $CiteKey ready fro me to use as a cite in my LaTeX source text like so: \cite{joyce:1994:ss}.

Of course if you want $Text for a different purpose, e.g. to show the full Abstract (already in $Abstract and a Displayed Attribute), then you could add a line to the edict:

$Text.skipTo("{").captureTo(",","CiteKey");
$Text = $Abstract;

Don’t want to lose the BibTeX code? Add another String-type attribute BibTeXCode and make the prototype’s $Edict this:

$Text.skipTo("{").captureTo(",","CiteKey");
$BibTeXCode = $Text;
$Text = $Abstract;

Of course if you already use code in the prototype’s edict, you would add the abovce to the existing code!

HTH :slight_smile:

†. Is it ‘citekey’ or ‘cite key’? Both get used interchangeably but—(in a BibTeX context—only to describe the same thing.

‡. Actually my slightly customised version of the data (i.e. field choices) but this doesn’t afect the overall

1 Like

I also checked, RIS and it doesn’t have a specific key for a cite key. RIS is an old system, unmaintained as a format, and is unlikely to updated. Wikipedia has several versions of the RIS format fields so there is likely nothing stopping you for data for personal use, mapping an unused RIS field to your RM app’s citekey field. Thus if relying on default RIS-based data during drag/drop to Tinderbox, the citekey info could come through to $ReferenceRIS.

Looking at the RIS tag list, it looks like C8 (custom tag #8) is unused by any significant standard interchange. For Bookends users, if editing your RIS mapping in the Formats Manager (via the app’s Biblio menu) the Bookends ‘Citekey’ field is addressed as u1.

Curiosity—the thief of time. Well I tried in Bookends, editing like so:

Caution: in the edit shown above you must put two spaces between ‘C8’ label and the hyphen, but only one space between hyphen and the ‘u1’ value string. Why this difference, I don’t know. But, that is what the format uses and as regex is likely used under the hood the number of spaces may matter (it appeared to in my early testing where I used only one space in the first position).

Now, even if the preview/review format (i.e. what ends up as $Text in the Tinderbox reference note’s $Text isn’t RIS or BibTeX code, the source cite key data is in $ReferenceRIS (regardless). Excellent news, but how/why? It appears that regardless of the display format selected in Bookends —i.e. what you see in the ‘Formatted Reference’ panel at the bottom of the main Bookends window view, the RIS always gets pulled across in the modified drag/drop method. As editing a format in Bookends updates the default/stored mapping for that format, our edit thus enhances the ‘silent’ RIS data transfer to add a citekey.

So, assuming you have a $CiteKey attribute and have edited the Bookends ‘RIS’ format to include the C8 key (as above) then the code to push the citekey value to $CiteKey is:

$ReferenceRIS.skipTo("C8  - ").captureLine("CiteKey");

Even better than my first try but I’ll leave both version as some may prefer the BibTeX-only route. Anyway, I’m so glad I figured out this trick as it will save much time for a current paper i’m involved in writing.

Here is my text file: Citekey-parse.tbx (196.2 KB). This lets you test a reference dragged from a suitably modified Bookends app. One stamp extracts the citekey into $Text, the other into the desired $CiteKey. The first was used when testing this technique. the note to stamp is outline #1 ‘Siren Shapes’. Note #2 shows the code stored in $ReferenceRIS of note #1.

Side note: I’ve also checked and there seems little downside to making this RIS mapping edit in Bookends, as the later does not export RIS field ‘C8’ if Bookends has no citekey (‘u1’) value in the current record. And, as noted previously, the RIS ‘C8’ key appears to have no known specific mapping.

1 Like