0

One can currently open a pdf of a citation in a latex document via the following steps:

  • open a latex document in emacs with installed packages auctex, reftex, ivy-bibtex, and pdf-tools
  • move cursor onto \cite{einstein_relativity_1905}
  • use reftex to jump to the corresponding entry in the bibliography file (reftex-view-crossref)
  • switch to other window where the .bib file appears
  • use ivy-bibtex to open the pdf (org-ref-open-bibtex-pdf)

How would one go about automating the last three steps without first opening the .bib file?

2 Answers 2

1

From the docstring of reftex-view-crossref, we find that we can find and jump to the .bib file by passing 2 as arg to that function. Subsequently, we can just call (org-ref-open-bibtex-pdf) to open the associated .pdf file.

We can combine these steps in a custom command:

(defun my-open-citation-at-point ()
  (interactive)
  (reftex-view-crossref 2)
  (org-ref-open-bibtex-pdf))

If it does not work directly, then check if you have defined the bibtex-completion-pdf-field and the bibtex-completion-bibliography.

1

As an alternative solution, calling ivy-bibtex while on top of the reference opens the correct entry in ivy-bibtex and after Enter it jumps to the .pdf document in the same frame but without opening the .bib file. Depending on the use case, this sometimes might be preferred.

In case it is preferred to open the file in another window, add to your emacs configuration

(setq bibtex-completion-pdf-open-function #'find-file-other-window)

3
  • This looks like a better/simpler solution then mine. I did not know about it... Commented Nov 14, 2022 at 17:12
  • I also just found out about it by accident. It is not documented. But I think it is not actually better - in most cases, one wants to have the tex file in one window and the pdf in the other which your solution does automatically
    – HRSE
    Commented Nov 14, 2022 at 18:43
  • Yes true, but my solution opens the bib file of course. On the other hand my solution does not depend on Ivy. B.t.w, when using ivy-bibtex, you can open the pdf in another window by setting bibtex-completion-pdf-open-function to find-file-other-window. Well, you choose the 'accepted' answer, but I would fully understand if you made it this answer... anyway, good luck! (actually, I only now notice that this is your own answer) Commented Nov 14, 2022 at 19:53

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.