Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Org-ref citation links are not supported #9

Open
lazzalazza opened this issue Dec 1, 2021 · 9 comments
Open

Org-ref citation links are not supported #9

lazzalazza opened this issue Dec 1, 2021 · 9 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@lazzalazza
Copy link

In Spacemacs, using Org 9.5 I'm experiencing problems exporting via pandoc and csl to the docx format.
Given this MWE (test.org):

`
#+title: Sample
#+bibliography: test.bib

  • First paragraph
    Text text text.[fn:1]

  • Footnotes

[fn:1] [[cite:&deroberto1898a]]
`
and this bibliography (test.bib):

@Book{deroberto1898a, author = {{De Roberto}, Federico}, title = {Leopardi}, date = 1898, publisher = {Treves}, location = {Milano},

I get this result:

prova.docx

As you see, the cite: link is treated as a simple link and not processed as it should.

I work with Spacemacs, this is the part of my .spacemacs file where set the bibliography and the cite-export-processors.

(setq bibtex-completion-bibliography '("~/Dropbox/Standard/Bibliografia/bibliografia_generale.bib") org-cite-global-bibliography '("~/Dropbox/Standard/Bibliografia/bibliografia_generale.bib") reftex-default-bibliography '("~/Dropbox/Standard/Bibliografia/bibliografia_generale.bib")) (require 'oc-csl) (require 'oc-biblatex) (setenv "LC_ALL" "it_IT") (setq org-cite-export-processors '((beamer biblatex) (latex biblatex) (t csl "~/Dropbox/Standard/Modelli/andrea.csl")))
Maybe I should somehow specify in the file that I want to export using csl?
Thank in advance for any help.

@a-fent
Copy link
Collaborator

a-fent commented Dec 1, 2021

Thank you. Without testing, one thing jumps out at me: your citation syntax looks wrong. Org Mode (9.5) citations have only single square brackets [cite:@foo_1999] whereas your document has double, which is indeed a standard Org Mode link.

Are you perhaps using org-ref? If so you should be using it for resolving citations, not #+CITE_EXPORT etc. They are separate systems for handling citations.

Also, if you want citations in footnotes, I would suggest using a style that formats in-text citations as footnotes, rather than creating the footnotes yourself.

@lazzalazza
Copy link
Author

Hi! I have simply used the org-ref-insert-cite-link standard output, which seems to insert by default two square brackets and not a single one… Anyhow, if I use a single bracket the citation is not exported either. As you see, I haven’t been using #+cite_export in the example, but I have configured the org-cite-export-processors variable. If I remember correctly, the old org-ref-default-bibliography has recently been changed into org-cite-global-bibliography, so I think I am using org-ref to handle the citation: but of course I am no expert and I could be wrong!

@a-fent
Copy link
Collaborator

a-fent commented Dec 1, 2021

OK, that is where the problem has arisen. org-cite (built in in Org 9.5) is different from org-ref (a separate Emacs package that until recently was the main option for citations in Org), with different citation syntax and different processing. It is confusing and unfortunate but @jkitchin , the author of org-ref has reasonable reasons for maintaining his separate system for citations (and more).

The solution: use either org-cite or org-ref, but don't mix them. If you're working with CSL and .docx and don't need advanced support for cross-references, org-cite should be fine.

For org-cite, the command to insert a citation is org-cite-insert on C-c C-x @ or you can use (as I do) something like bibtex-completion to search for references to cite.

Org-ref won't work with ox-pandoc without some further configuration to resolve cite: links into a form Pandoc can understand. This could be something for the ox-pandoc documentation but it's not something I have a high priority for.

@a-fent a-fent added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 1, 2021
@a-fent a-fent changed the title Problems with citation export in Org 9.5 Org-ref citation links are not supported Dec 1, 2021
@jkitchin
Copy link

jkitchin commented Dec 1, 2021

@a-fent is correct, you should not mix org-ref and org-cite. They are separate and independent systems.

If you choose to use org-ref, you can find an example file to make a docx here https://github.com/jkitchin/org-ref/blob/master/examples/basic-csl.org#ms-word-docx-via-pandoc. You do have to use a pre-processing hook function to convert the citations via citeproc before the pandoc export.

It would likely be straightforward to have the preprocessor transform each link to a pandoc format if it was desirable to have pandoc do the citation processing instead of citeproc. It would still be a preprocessing step, but it would allow pandoc to do its work.

@lazzalazza
Copy link
Author

@a-fent @jkitchin Thank you so much! Due to some personal issues I haven't been able to work much in the last months: I am now exploring the solution that @jkitchin has suggested. I would like to keep on using his exellent org-ref package, also because I need cross-referencing to work. As I have told you, I'm a Spacemacs user and I have inserted these lines in the user-config section of my dotfile:

(require 'org-ref-refproc)
(let ((org-export-before-parsing-hook '(org-ref-cite-natmove ;; do this first
					org-ref-csl-preprocess-buffer
					org-ref-refproc)))
  (org-open-file (plist-get (org-pandoc-export-to-docx) 'output-file) 'system))

Unfortunately this doesn't seem to work. I get this error at startup:

(Spacemacs) Error in dotspacemacs/user-config: This command must be run on an org-mode buffer`

When I then try to export, org-ref-refproc is still not active. I wouldn't like this conversation to become Spacemacs-specific, but any advice would be crucial!

@jkitchin
Copy link

that code should not go in your init file. It should go in a src block in the org file you are trying to export. That code will try to export your init file, which is not what you want.

@lazzalazza
Copy link
Author

@jkitchin Ooops! I see... This is what I have done now:

#+title: Sample

* First paragraph
 Text text text.
 [[cite:&deroberto1898a]] 

#+begin_src emacs-lisp :exports none
  (require 'org-ref-refproc)
  (let ((org-export-before-parsing-hook '(org-ref-cite-natmove
	 				                                org-ref-csl-preprocess-buffer
					                                org-ref-refproc)))
     (org-open-file (plist-get (org-pandoc-export-to-docx) 'output-file) 'system))
#+end_src

This actually produces a preprocessed output.
Doing this every time one wants to export a file might seem a little overcomplicated, though... Would a once-for-all solution be thinkable?

PS. This is not directly related to the issue, but if I specify the location of my csl custom style (or that of any other style) like so:

#+csl-style: /Users/test/Dropbox/Standard/Modelli/andrea.csl

I get an error: "Wrong type argument: listp, "[NO BIBLIOGRAPHY LAYOUT IN CSL STYLE]". If you think it's the case, I might open a new issue... Thanks a lot!

@jkitchin
Copy link

The only once-for-all solutions are to wrap that in your function you can call, e.g. M-x my-export that runs those, or define your own exporter in your init file so you can do C-c C-e zz or something. See org-ref-export.el for details on how that is done.

I am not sure about the error you mention, it might be a csl error. org-ref wouldn't report that by itself.

@mgcyung
Copy link

mgcyung commented Mar 4, 2022

Maybe you can try
#+PANDOC_OPTIONS: bibliography:test.bib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Development

No branches or pull requests

4 participants