jkitchin / org-ref

org-mode modules for citations, cross-references, bibliographies in org-mode and useful bibtex tools to go with it.
GNU General Public License v3.0
1.36k stars 244 forks source link

Fail to produce bibliography and proper citations org-mode to pdf export #1042

Open nilsleh opened 2 years ago

nilsleh commented 2 years ago

Thank you for this fantastic work, being able to access, manage and work with citations inside org-mode is incredible. The last step that I cannot figure out how to achieve is exporting the org-mode file to a pdf. I am sure it is simply something that I am not understanding from the manual but I cannot figure out why.

This is my org-mode file.

#+BIND: org-export-use-babel nil
#+TITLE: test
#+AUTHOR: Author Name
#+DATE: November 3, 2022
#+LATEX: \setlength\parindent{0pt}
#+LaTeX_HEADER: \usepackage{minted}
#+LATEX_HEADER: \usepackage[margin=0.8in]{geometry}
#+LATEX_HEADER_EXTRA:  \usepackage{mdframed}
#+LATEX_HEADER_EXTRA: \BeforeBeginEnvironment{minted}{\begin{mdframed}}
#+LATEX_HEADER_EXTRA: \AfterEndEnvironment{minted}{\end{mdframed}}
#+latex_header: \usepackage[citestyle=authoryear-icomp,bibstyle=authoryear, hyperref=true,backref=true,maxcitenames=3,url=true,backend=biber,natbib=true] {biblatex}
#+LATEX_HEADER: \addbibresource{./test.bib}
#+MACRO: NEWLINE @@latex:\\@@ @@html:<br>@@
#+PROPERTY: header-args :exports both :session test :cache :results value :product postgres
#+OPTIONS: ^:nil
#+SETUPFILE: https://fniessen.github.io/org-html-themes/org/theme-readtheorg.setup
#+LATEX_COMPILER: pdflatex

* Introduction
[[cite:&hay_probabilistic_2015]] show that.

* Bibliography
[[printbibliography:]]
bibliographystyle:unsrt

This is the bibliography:

@article{hay_probabilistic_2015,
        title = {Probabilistic reanalysis of twentieth-century  sea-level rise},
        volume = {517},
        issn = {1476-4687},
        doi = {10.1038/nature14093},
        language = {eng},
        number = {7535},
        journal = {Nature},
        author = {Hay, Carling C. and Morrow, Eric and Kopp, Robert E. and Mitrovica, Jerry X.},
        month = jan,
        year = {2015},
        pmid = {25629092},
        keywords = {Uncertainty, History, 20th Century, History, 21st Century, Probability, Seawater, Bias, Climate Change, Human Activities, Oceans and Seas, Tidal Waves, Time Factors},
        pages = {481--484},
}

This is the output from running M-x org-ref in the org-mode file:

#+title: org-ref report on [[path/test.org][test.org]]

org-ref called from path/test.org

* Bibliography

- [[./test.bib]] (dialect = BibTeX)

* Miscellaneous

- org-latex-prefer-user-labels = nil
- bibtex-dialect = BibTeX
- biblatex is not required.
- biblatex is used.
- emacs-version = GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0)
 of 2022-05-31
- org-version = 9.5.5
- org-ref: Version 3.0
- org-ref.el installed at /home/nils/.emacs.d/elpa/org-ref-20221015.1308/org-ref.el
- org-ref-insert-cite-function = org-ref-cite-insert-ivy
- org-ref-insert-label-function = org-ref-insert-label-link
- org-ref-insert-ref-function = org-ref-insert-ref-link
- org-ref-cite-onclick-function = (lambda (_) (org-ref-citation-hydra/body))
- org-latex-pdf-process is defined as (pdflatex -interaction nonstopmode -output-directory %o %f bibtex %b pdflatex -interaction nonstopmode -output-directory %o %f pdflatex -interaction nonstopmode -output-directory %o %f)
- natbib is not required.
- natbib is not in org-latex-default-packages-alist or org-latex-packages-alist.
- cleveref is not required.
- cleveref is not in org-latex-default-packages-alist or org-latex-packages-alist.
- bibtex-completion installed = t
- bibtex-completion loaded = t
- org-latex-default-packages-alist
  ("AUTO" "inputenc" t ("pdflatex"))
  ("T1" "fontenc" t ("pdflatex"))
  ("" "graphicx" t)
  ("" "longtable" nil)
  ("" "wrapfig" nil)
  ("" "rotating" nil)
  ("normalem" "ulem" t)
  ("" "amsmath" t)
  ("" "amssymb" t)
  ("" "capt-of" nil)
  ("" "hyperref" nil)
-  org-latex-packages-alist
  ("" "minted")
  ("AUTO" "babel" t)
- ox-bibtex loaded = nil
- ox-bibtex loaded after org-ref = nil
- ebib loaded = nil
- ebib loaded after org-ref = nil
- cite link definition:
("cite" :complete
 #[128 "\302\300\303\301\"\"\207"
       [org-ref-cite-link-complete
        ("cite")
        apply append]
       6 "

(fn &rest ARGS2)"]
 :follow org-ref-cite-follow :face org-ref-cite-face :help-echo org-ref-cite-tooltip :export
 #[128 "\302\300\303\301\"\"\207"
       [org-ref-cite-export
        ("cite")
        apply append]
       6 "

(fn &rest ARGS2)"]
 :activate-func org-ref-cite-activate)

* LaTeX setup

latex is installed at /usr/bin/latex
pdflatex is installed at /usr/bin/pdflatex
bibtex is installed at /usr/bin/bibtex
biblatex is installed at nil
makeindex is installed at /usr/bin/makeindex
makeglossaries is installed at /usr/bin/makeglossaries

* Warnings
- No (org-ref) Warnings found.
* Utilities

- [[elisp:(progn (find-file "/path/test.org") (ispell))][Spell check document]]
- [[elisp:(progn (find-file "/path/test.org") (org-ref))][recheck document with org-ref]]

In my emacs init file I have the following:

(setq org-latex-pdf-process '("pdflatex -interaction nonstopmode -output-directory %o %f"
                              "bibtex %b" "pdflatex -interaction nonstopmode -output-directory %o %f"
                              "pdflatex -interaction nonstopmode -output-directory %o %f"))

So to export to pdf I am attempting to run C-c C-e l o from test.org. There are no errors being produced when the pdf is created, however, the citation is not formatted and the the bibliography does not show up, i.e: Screenshot from 2022-11-03 11-17-37

Thank you in advance.

jkitchin commented 2 years ago

It sounds like maybe your latex process is not calling biblatex/biber.

Try: (setq org-latex-pdf-process (list "latexmk -shell-escape -bibtex -f -pdf %f"))

that seems to work for me.

image
nilsleh commented 2 years ago

That indeed does fix it, thank you for the fast reply. I now realize that it was also a suggested option in the manual, but I somehow missed that, apologies.

AtomicNess123 commented 1 year ago

I am running into the same problem even having this lilne on my initfile:

(setq org-latex-pdf-process (list "latexmk -shell-escape -bibtex -f -pdf %f"))

My buffer test.org looks like this:

#+STARTUP: overview
#+STARTUP: indent
# #+OPTIONS: toc:2
#+OPTIONS: date:nil
#+LATEX_COMPILER: xelatex
#+LATEX_CLASS: article
#+OPTIONS: broken-links:t

#+TITLE: Title
#+AUTHOR: author1^{*,a}, aauthor2^{b,c}

*SUMMARY
[[cite:&Dirac1994]]

[[cite:&Dirac2000]]

* REFERENCES
[[bibliography:/Users/atomic ness/Documents/Dropbox/BibTex/mypaper.bib]]
[[bibliographystyle:journalZ]]
[[printbibliography:]]

LOG OUTPUT:

LaTeX Warning: Citation `Dirac1991' on page 1 undefined on input line _.
LaTeX Warning: Citation `Dirac2000' on page 1 undefined on input line _.

(./test.bbl)
! Undefined control sequence.
l.46 \printbibliography

? 
! Emergency stop.
l.46 

End of file on the terminal!
jkitchin commented 1 year ago

printbibliography requires you to use biblatex. From the look of your org file, you can probably just remove that line. The bibliography link is where the bibliography will go.

It looks like there is a space in the bibliography path. That sometimes causes problems.

You should see if the examples here work: https://github.com/jkitchin/org-ref/tree/master/examples

AtomicNess123 commented 1 year ago

Thanks. I had a look at several examples.

I am uncertain about what Latex options to set up at the beginning of the org buffer (never used Latex before).

I just have these that I copied from somewhere:

#+LATEX_COMPILER: xelatex
#+LATEX_CLASS: article
#+LATEX: \printbibliography

Not sure if #+LATEX: \printbibliography is necessary.

Also uncertain about whether it is better to use bibLatex and how to make Emacs use it.

I changed my REFERENCES section like this:

[[bibliography:/Users/atomicness/Documents/Dropbox/BibTex/mypaper.bib]]
[[bibliographystyle:unsrt]]

Got a similar error message:

! Undefined control sequence.
l.30 \printbibliography

? 
! Emergency stop.
l.30 

End of file on the terminal!

I just want to write my paper in Orgmode and then export to PDF with all the org-ref functionality.

jkitchin commented 1 year ago

you can't just copy things from places and hope they work. you are mixing bibtex and biblatex here, which does not work. As I suggested earlier, remove #+LATEX: \printbibliography. And, see if the org-ref examples work for you. If they do slowly adapt one of them to your document, one step at a time, until your document works.

AtomicNess123 commented 1 year ago

Thanks.

When you mentioned earlier to remove printbibliographyi thought you meant [[printbibliography:]], not the latex line.

Now I have removed it and it works.