Customize display of cite links

In my field, it is common to use author-year combinations or simply years as links to references. For example, an article might say:

An alternative was presented by Lewis (1968) and Stalnaker (1974).

The years link to bibliography entries. Can I replicate something like this in my notes? Ideally, I’d like to have the following:

(1) When selecting a link from bibtex-completion, I’m offered a choice of using the year or author+year as link text.

(2) The link is then inserted as ‘[[cite:lewis1986counterpart][1968]’, for example, which displays as just ‘1968’. (At the moment, it displays in full, with all the brackets.)

Is that already possible?

Two things:

First, org is a structured format (like latex, or markdown), and citations are no different. Output presentation is more the focus of export or conversion.

But if you really want this …

… I think display config is handled by org-ref, so you’d want to check there.

BTW, the examples you gave would use the citet command.

Theoretically, it could be possible, but I agree with @bruce: do you really need to have them show in the proper format in your org files? As long as they get extended properly in your exports, wouldn’t be all right to just have the citekey, which contains the same information?

Thanks. That’s the response I’ve seen elsewhere to this kind of questions. It makes sense for writing articles, where the end product is the exported pdf. But my zettelkasten notes are not written to be exported. They are meant to be read as org files, so I’d like them to be as readable as possible.

(There are other aspects to this as well. For example, I want LaTeX formulas and equations to be rendered properly, rather than shown as source, etc. Basically, I want the org file to look as much as an exported article as possible.)

cf. LaTeX preview in org

The problem is that, with Org-roam, we’re trying to stay true to Org-mode’s internals as much as possible, or to the default behaviour of the packages we employ, one of which is Org-ref. Org-ref provides us with the cite: links, which have their own formatting, and if we were to modify the way they work, it’d break compatibility with vanilla Org-mode and Org-ref.

Now, we can do it purely cosmetically, i.e., by fontifying the text with another version which might be retrieved via bibtex-completion, but this either introduces taxing operations upon loading/saving the file, or it has us modify the way cite: links work to display a description. The latter option could be discussed upstream.

Is it feasible (as in, a reasonable FR) for org-ref to add ability to hover over a cite link and get a preview of the formatted reference?

Nevermind; already does this :slight_smile:

@zaeph - any ideas why this isn’t working for me? Is there anything that org-roam is doing that would interfere with it, as it’s supposed to be default?

I never got the tool-tip to work in org-ref, well before org-roam existed. Don’t know why.

1 Like

Maybe we need to report it, if we can narrow down what’s going on?

You can if you want to :wink: The minibuffer message has always worked, and I personally never really cared about the tooltip. I always chalked it up to one of those things that is supposed to function in his video but a lot of people had trouble with. Drag and drop PDF’s and url’s were others I remember being a common issue for people but I never bothered with them.

Maybe when org gets the new native citation support, this stuff will work there!

I believe that org-ref has citename: and citeyear: options as well. I couldn’t find it in the online docs but it’s referenced in the github issues section.

Uh, that’s weird. It’s working all right on my end, minus the weird formatting issues because of the lack of support for the CSL, i.e., the inclusions of all the {{…}} meant to preserve capitals.

The bulk of our efforts with ORB so far have been with bibtex-completion, potentially reflects the usage discrepancy we have. I could look into it, but we’ve got more pressing matters to address with Org-roam for now.

1 Like

Thanks @zaeph, I agree it might be an upstream issue, but I’m not sure it belongs to org-ref or bibtex-completion.

bibtex-completion actually has an option to insert author-year links: bibtex-completion-format-citation-org-apa-link-to-PDF, which display roughly the way I want. But the link leads to a PDF, so it breaks access to my bibliography notes etc.

In a reddit post (that I can’t find anymore), jkitchin said links of the form [[cite:key][Author (Year)] would be in principle possible, but they would break exporting. I’m happy to break exporting, and I don’t see any other clash with org-ref. What I don’t understand is why these links don’t “fold in”, i.e. why ‘[[cite:key][text]]’ does not display as ‘text’.

I suppose it’s because cite: takes precedence in the fontification over org-links.

I’m 90% sure it’s coming from Org-ref. I don’t remember seeing code for this in bibtex-completion.

It looks like org-ref sets its :display parameter to nil which doesn’t fold. Add this to your config and it should work:

 :display 'org-link)

@alan: yes this works, thanks! Now I’d only need to find a way to automatically insert links in this format.

1 Like

@zaeph Am I wrong that org-ref has the capability to cite just the Author or Year? This recent issue on org-ref GitHub has jkitchin saying “There is definitely a citeyear and citeauthor defined in org-ref-natbib-types which should be included in org-ref-cite-types .” Or does that only apply to citation exporting rather than editor display?

@cobblepot I would guess everything refers to export. The bibtex key is used to point to the citation for all of the link types, but the types define different export options.

(setq org-ref-default-citation-link "citeyear") can be used to default to a certain type when inserting links, but it won’t look different in the editor.

Like @diagonallemma, I also care far more about org-mode readability than I do about exporting. For me, it works if I start making the link by opening the bibfile.

I put the cursor anywhere in the bibentry I want to link to. Then I do:

M-x org-store-link

and go to the .org file where I want to paste the link, and then:

M-x org-insert-link

The minibuffer displays the cite: link. If I hit return, it diplays a prototype link text. I edit that to taste and hit return. Then a folded cite: link appears in the org file.

This bulky procedure is cobbled together from this org-ref issue. I’ve never understood why it couldn’t be simpler, but the org maintainer says this is as good as it gets – he’s super-responsive, so if you want to know more, he’ll likely answer your question.

1 Like

I will mention here, since it may have impact on this in the future: org will soon be getting native citation support. Part of that discussion could result in more robust ability to configure rendering.