2

Using org-ref and helm-bibtex I can insert a reference into my org file that will be displayed as a link in the shape of cite:kaufmann_eigensolver_2007. I can hit RET and get a menu from helm-bibtex with common actions on that citation.

The goal

What I'd like is to be able to directly open the PDF given in the file field of the bibtex entry (supplied by Zotero).

The problem

When picking "Open PDF" in the helm-bibtex menu I get the message "no pdf found for <key>"

My configuration

I have set up better-bibtex to export by Zotero library to a bib file. The entries look like this:

@incollection{kaufmann_eigensolver_2007,
  title = {Eigensolver {{Methods}} for {{Progressive Multidimensional Scaling}} of {{Large Data}}},
  ...,
  file = {C\:\\Users\\Ben\\Zotero\\storage\\Q2YBABVH\\Brandes and Pich - 2007 - Eigensolver Methods for Progressive Multidimension.pdf},
  ...
}

My config looks like this

  ;; configure bibtex layer
  (setq org-ref-default-bibliography '("/Users/Ben/Dropbox/Library.bib")
        org-ref-bibliography-notes "/Users/Ben/Dropbox/org/org-ref-notes.org")


  (setq bibtex-completion-bibliograph "/Users/Ben/Dropbox/Library.bib")
  (setq bibtex-completion-pdf-field "file")
  (setq bibtex-completion-pdf-open-function
        (lambda (fpath)
          (debug)
          (start-process "open" "*open*" "open" fpath)))

What I've tried

  • Changing the PDF file name to accomodate the bibtex key (kaufmann_eigensolver_2007.pdf)
  • Manually editing the file field and try different variations of double/single/forward/backward slashes
  • Some basic debugging but I have to say im pretty lust on how to use debug in emacs.
  • Looking at the source code of the relevant function of helm-bibtex but I cant really make sense of it.
ngmir
  • 121
  • 5
  • I have this exact same issue on Linux, where the filepaths are correctly listed in my bib file (e.g. `file = {/home/japhir/Zotero/storage/8KDWAK4W/Eiler2007EPSL.pdf},`. I've set `(setq bibtex-completion-pdf-field "file")` because the bibtex key starts with `file`. Still, when I `(bibtex-completion-find-pdf-in-field "Eiler2007")` it returns `nil`. Have you made progress? – Japhir Apr 27 '20 at 13:05
  • I think I resolved mine, might be relevant to you as well! These functions all come from helm-bibtex/ivy-bibtex etc., where it says to configure `bibtex-completion-bibliography` see https://github.com/tmalsburg/helm-bibtex#minimal-configuration. – Japhir Apr 27 '20 at 13:12

2 Answers2

2

I had the same problem. In my case, it was fixed by setting org-ref-get-filename-function:

(setq org-ref-get-pdf-filename-function
      (lambda (key) (car (bibtex-completion-find-pdf key))))
Stefan
  • 26,154
  • 3
  • 46
  • 84
  • Thank you for this tip. For me, it was sufficient to set `org-ref-get-pdf-filename-function` to `org-ref-get-pdf-filename-helm-bibtex` – bashfuloctopus Jul 14 '20 at 17:48
1

You seem to be on a MAC, but the PDF key in the bibtex contains a Windows path. Maybe Zotero should export differently?

Not sure if this helps but I setup the variable

(setq bibtex-completion-library-path "~/cloud/Papers/")

to the path which contains all my papers. And then the bibtex entries only have the name of the file (with no path) in them.

Given your setup you could debug by calling both

(bibtex-completion-pdf-open-function <fullpath>)

(bibtex-completion-pdf-open-function (concat <dirpath> <pdfname>))

trying to substitute in the appropriate values.

BTW I don't think you need to change the PDF open function unless you have specific reasons to do so.

MassimoLauria
  • 200
  • 1
  • 8
  • thanks a lot for looking at this! I am in fact on Windows. It was just that entering paths in the unix format works sometimes so I stuck with that. I'll look into your other suggestions. – ngmir Apr 03 '20 at 13:11
  • Setting `org-ref-pdf-directory "/Users/Ben/Papers"` and `bibtex-completion-library-path "/Users/Ben/Papers"` and then putting the paper (named by bibtex key) there lets me open it via helm-bibtex. But it seems the `file` field is not taken into account at all. I guess I'll have to learn how to use the debugger to see where it goes wrong.... – ngmir Apr 03 '20 at 13:22
  • What if you use exactly the same setup but you do not name the PDF as the paper bibtex key, and also put the PDF name without path in the bibtex entry? – MassimoLauria Apr 03 '20 at 13:25
  • It (still) uses the bibtex key to (successfully) find the file in ~/Papers – ngmir Apr 03 '20 at 14:42
  • If you change both (1) the name of some PDF file and (2) the `file` field in the corresponding bibtex entry, accordingly? Can you open that file? I only use `bibtex-completion`, I don't know if `org-ref` changes its setup. – MassimoLauria Apr 03 '20 at 22:30
  • No, it only finds the PDF if it is named according to the bibtex key and in the `~/Papers` directory. -- I'll really just have to see what is actually happening 'under the hood' and what `org-ref` and `bibtex-completion` do and if I need both. Thanks a lot for your help anyways. – ngmir Apr 10 '20 at 07:47