reddit / emacs

Exporting Org Mode citations to LaTeX

danderzei · 2022-12-28 03:37
Hi, I am migration from org-ref to using the built-in citations in Org Mode. I am having some trouble properly exporting to LaTeX / PDF. This is my MWE: #+title: Testing org-cite \LaTeX export #+latex_header: \usepackage{natbib} #+bibliography: r4h2o.bib #+options: toc:nil #+cite_export: natbib Hello World! This is a citation: [cite:@alghamdi_2022_clas] #+print_bibliography: +end_export I get an error message: "Unknown processor natbib" Exporting with the basic exporter works fine. CSL is also problematic. The Org Mode manual is a bit cryptic on this functionality. Anyone can help fixing this issue? P.S: I used a clean Emacs instance (emacs -q), no config.
danderzei · 2022-12-28 05:56
I solved my own problem - it seems to work when using this config: (require 'oc-natbib) Plus usual setup for LaTeX export ... Doh!
yantar92 · 2022-12-28 08:06
oc-natbib should be automatically loaded in such scenarios starting from Org 9.6
danderzei · 2022-12-28 08:16
That's what I thought ... go figure. The [Org manual](https://orgmode.org/manual/Citation-handling.html) actually states that this needs to be done. Lesson: read the manual before digging in the source code ;)
yantar92 · 2022-12-28 08:27
We just forgot to remove this clause in Org 9.6 :)
danderzei · 2022-12-28 09:25
I am still a bit confused. I can get it to work fine with the `#+cite_export: natbib apalike aythoryear` token for each file. Setting the `org-cite-export-processors` is still a bit elusive. This is what I constructed: (setq org-cite-export-processors '((latex . '(natbib "apalike" "authoryear")) (t . basic))) I get an error. Do you know how to properly set this variable?
yantar92 · 2022-12-28 09:28
There is no such variable. You need to set org-cite-export-processors. Also, you don't need all that "." and extra quotes inside.
danderzei · 2022-12-28 09:34
P.S. I am on 9.5.2.
yantar92 · 2022-12-28 09:48
The online manual is for the last release. Keep it in mind.
danderzei · 2022-12-28 09:57
New version: (setq org-cite-export-processors '((latex (natbib apalike authoryear)) (t basic))) Error: "Invalid cite export processor definition: ((natbib apalike authoryear))"
yantar92 · 2022-12-28 10:33
I suggest you to read the docstring: F1 v org-cite-export-processors <RET> (setq org-cite-export-processors '((latex natbib "apalike" "authoryear") (t basic)))
danderzei · 2022-12-28 10:39
I figured it out (updated to 9.6). (setq org-cite-csl-styles-dir "~/Documents/library/" org-cite-export-processors '((latex natbib "apalike" "authoryear") (t csl "apa6.csl"))) I got confused by the reference to "triplet" in the docstring. Works a treat now. Thanks for the tips!
danderzei · 2022-12-28 11:06
I read it closely, but it is confusing.
yantar92 · 2022-12-28 11:29
Are you confused because `(a b c)` list is the same with `(a . (b c))` in Elisp?
danderzei · 2022-12-28 11:49
I must found that out, thanks. Documentation in Emacs can be cryptic. The docstring could easily be improved for clarity.
yantar92 · 2022-12-28 11:52
Feel free to suggest an improvement by dropping an email to Org mailing list. See https://orgmode.org/manual/Feedback.html#Feedback