I want to customize how a link is prettified. Specifically, I want Org-Ref's cite links to display the bibiliography key.

A cite link looks like:

[[cite:my-bib-key][pg. 2]]

The default prettified display looks like:

pg. 2

How can I tweak org-mode to get this display instead:

@my-bib-key: pg. 2

2 Answers 2


That is a nice solution. I expanded this a bit here. It matches all the cite types and recolorizes the link. It doesn't do the manipulation to put @ and a space in, which can be done with the 'display property, but it add some complexity with extra managed properties that doesn't seem warranted to me.

(defun org-ref-make-org-link-cite-key-visible (&rest _)
  "Make the org-ref cite link visible in descriptive links."

    (let ((s (match-string 1))
      (beg (match-beginning 0))
      (end (match-end 0))
      (cite-re (format "^\\(%s:\\)"
               (regexp-opt (-sort
                    (lambda (a b)
                      (> (length a) (length b)))

      (when (and s (string-match cite-re s))
    (setq cite-type (match-string 1 s))
    (remove-text-properties beg end
     beg end
     `(face (:foreground ,org-ref-cite-color)))))))

(advice-add 'org-activate-bracket-links :after #'org-ref-make-org-link-cite-key-visible)

This has been pushed to org-ref, so it should be default behavior now. Thanks for sharing your approach!


I have a mostly working version. Org is pretty clever about how it fontifies links. It just hides the parts of the link when org-descriptive-links is non-nil. It does this using the buffer-invisibility-spec. The function that does all the heavy lifting is org-activate-bracket-links

My solution is remove the invisible property from the cite-key part of the URL by advising org-activate-bracket-links.

(defun my:make-org-link-cite-key-visible (&rest _)
  "Make the org-ref cite link visible in descriptive links."
  (when (string-prefix-p "cite:" (match-string 1))
    (remove-text-properties (+ (length "cite:") (match-beginning 1))
                            (match-end 1)

(advice-add 'org-activate-bracket-links :after #'my:make-org-link-cite-key-visible)

Unfortunately, there's no space between the key and the description so it looks like:

my-bib-keypg. 2

I'll look at using text properties to fix that, but that's a decent bit of complexity.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.