reddit / emacs

Org-Cite, Citar and Latex in Org-Mode problems

BarryLeFreak_1 · 2022-09-05 11:29
So I've recently declared config bankruptcy and started a new config file from scratch. Unfortunately, because I've relied on a cobbled together config for the longest time, I have run into some problems with an important part of my workflow. After spending a few frustrated hours trying to solve the problem myself, I need to come to y'all for help. I'm not a gifted Elisp programmer so please don't yell at me. For uni, I've been using org-mode to write papers which are exported as PDFs. I've developed a fairly good template that uses a bunch of raw Latex. I use Zotero to handle my references, which then exports to a .bib file in my project folder with BetterBibTex. I used ivy-bibtex to find the citation in the local .bib file then inserted a raw \\autocite latex command (because it works better with the other raw latex formatting commands). This is then exported with latexmk (`(org-latex-pdf-process (list "latexmk -f -pdf %f -output-directory=export"))` ) and pdflatex. Before you ask: I cannot use AucTex because it crashes with aspell (I'm on Windows) and I prefer writing in org mode. Redoing my config, I wanted to move away from Ivy and towards Vertico/Marginalia/Orderless etc because I am a bit tired of having to configure Ivy specific functions and ivy-bibtex was not maintained super actively from memory. I set up Citar, Citar-Embark etc according to the github readme and [this guide](https://kristofferbalintona.me/posts/202206141852/). I can include portions of my config if needed. Here's my test.org file (I have removed most of the #+include statements as they are mostly preamble header code, cover pages etc) #+title: Test Test #+latex_class: article #+latex_class_options: [a4paper, 12pt] #+latex_header: \rhead{Test Test} #+latex_header: \usepackage[backend=bibtex, style = authoryear-comp]{biblatex} % For IEEE numbered headings, use [backend=bibtex,block = ragged, style = numeric, sortcites] #+latex_header: \bibliography{test2.bib} #+latex_compiler: pdflatex * Table of contents #+begin_export latex \makeatletter \renewcommand \tableofcontents{% \@starttoc{toc}% } \makeatother %This removes the "Content" heading from table of contents \pagenumbering{roman} \tableofcontents \clearpage #+end_export * Introduction \pagenumbering{arabic} \begin{multicols}{2} Test test test. Cited by \end{multicols} * Cite section This cite seems to work? [cite:@AssessingChinaEnergy] * References \printbibliography[heading=none] Specific Citar and Org-Mode Questions: 1. How do I get org-cite/Citar to refer to the local bib file? In ivy-bibtex, there are two separate commands for searching local and global bibliographies. I have citar-bibliography set in my config for a universal file, but I'd rather not use this as it becomes a headache to look through all the references. I tried using `#+bibliography:test2.bib` as an alternative to the template above and that didn't work either. 2. How do I get Citar to insert \\autocite and other raw LaTeX commands? I'd rather use those commands since it allows me to have better control over formatting. 3. I tried `#+cite_export: biblatex` as described in the manual instead of the usepackage statement but it gives the error "unknown processor biblatex". 4. Using C-c b (org-cite-insert) in the multicols Introduction section doesn't work ("unable to insert citation here"). It seems to work in headings without any Latex code like the Cite section heading but then it (a) doesn't export properly (it comes out as (,)) and (b) searches the wrong bibliography file even with `#+bibliography:test2.bib` and C-c C-c in the header. Maybe Citar/org-cite doesn't work the same way? General questions: 1. What's generally the best way to use Latex in org mode? I want to take advantage of all the Latex commands and resources online while still being able to use the folding and editing features of org-mode. As mentioned before, I tried AucTex but it crashes aspell. I am aware that a lot of the stuff in my templates are pretty janky. 2. How do I configure Citar and org-cite to use local bibliography files? 3. Am I missing something with the config side? I have been watching a bunch of videos and read a few guides but they usually miss out on the Citar side of things.
bdarcus · 2022-09-05 12:16
1. Citar handles local and global bib files transparently. So long as `org-cite` knows about them (and `#+bibliography: test.bib` works for me for the local bibs), Citar will use them. 2. You don't, unless you want to customize it (which you can do; just need to write your own [major-mode function(s)](https://github.com/emacs-citar/citar#major-mode-adapters) for that; but if you want this type of low-level control, maybe just write in LaTeX?). By default, Citar only focuses on `org-cite` in org. 3. Are you using a recent version of org? There were some changes a few months ago that should autoload the processors. But there's no harm in explicitly loading them via `use-package` etc. 4. Citar defers to org on where citations are allowed (the warning comes from org). And org restricts that, typically for technical reasons. But sometimes a restriction can be an oversight, since this is pretty new code, in which case you can query the org list. You might look at the Doom biblio module, even if you don't want to use Doom, since it's all configured to work well there (with very little code). ​ >Maybe Citar/org-cite doesn't work the same way? In general, no, since Citar pretty much defers to org for anything I can think of: syntax, parsing, inserting, exporting, knowing what files to load, etc. Let me know if any of that is unclear.