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

Problems rendering superscripts correctly for in-text citations when exporting to ODT #160

Closed
matogoro opened this issue Apr 14, 2024 · 6 comments
Assignees

Comments

@matogoro
Copy link

Describe the bug

Hi,

I'm having trouble getting citar and citeproc-el to render certain superscripted citations properly when exporting to ODT (using org-cite). Basically, the generated ODT document shows the underlying org shorthand (^{1}) rather than a proper superscripted citation.

Unsurprisingly, only CSL styles that rely on superscript citations (e.g., nature.csl, american-medical-association.csl, etc.) are affected. This is not an issue with certain CSL styles that don't require superscript numbers (e.g., springer-vancouver.csl).

Some things I've noticed:

  • regardless of how in-text citations are displayed, bibliographies render correctly according to the style file
  • exporting to HTML displays the superscripts properly—it's only ODT that has issues
  • standard superscripted text (i.e., where I just type the shorthand in org-mode) renders correctly in the ODT file—only the superscripted citations don't get converted
  • I've been able to export to superscripted references to ODT successfully before using org-ref, so this makes me believe that something is not being piped to the ox-odt exporter appropriately

To Reproduce

A (stripped down) version of my configuration is below:

(use-package citeproc)

(use-package citar
  :custom
  (org-cite-global-bibliography '("~/Multimedia/Literature/SciLi/index.bib"))
  (org-cite-insert-processor 'citar)
  (org-cite-follow-processor 'citar)
  (org-cite-activate-processor 'citar)
  (citar-bibliography org-cite-global-bibliography)
  (citar-citeproc-csl-styles-dir "~/Documents/Zettelkasten/Templates/Text/CSL/styles")
  (citar-citeproc-csl-locales-dir "~/Documents/Zettelkasten/Templates/Text/CSL/locales")  ; cloned official CSL locales repository
  (citar-format-reference-function #'citar-citeproc-format-reference)
  :hook
  (LaTeX-mode . citar-capf-setup)
  (org-mode . citar-capf-setup))

In the manuscript buffer, I execute citar-citeproc-select-csl-style and select the appropriate CSL file (e.g., Nature). I also put in the following header to ensure the proper CSL file is loaded:

#+CITE_EXPORT: csl ~/Documents/Zettelkasten/Templates/Text/CSL/american-medical-association.csl

I export using org-export-dispatch to ODT, and the in-text citations of the resultant ODT file are displayed as ^{1} when viewed in LibreOffice.

Expected behavior
Correct rendering of superscript citations in exported ODT files. Any help would be greatly appreciated!

Emacs version:
GNU Emacs 29.3
Org 9.7-pre

@andras-simonyi
Copy link
Owner

andras-simonyi commented May 4, 2024

Hello, thanks a lot for the detailed report and apologies for responding only now. I can confirm the problem, which is caused, I think, by the space present between the citation in superscript and the previous word or punctuation. The best solution would be to check during Org export whether a citation starts with text in superscript and eliminate any leading space if that is the case (actually, something similar is already done for note citations). I will try to fix the problem in the Org CSL export processor in the near future.

@andras-simonyi
Copy link
Owner

I've merged a pull request now (#161), which should solve the core rendering problem. I have also prepared a couple of citeproc and Org (oc-csl) patches that together delete the spaces before superscript citations -- I'll try to apply them shortly, although the Org patch might take a bit of time because of the mailing list discussions.

@andras-simonyi andras-simonyi self-assigned this May 5, 2024
@andras-simonyi
Copy link
Owner

...the citeproc part (#162 ) has been merged, the Org patch is WIP.

@andras-simonyi
Copy link
Owner

I've also pushed the Org patch onto main so with the latest citeproc-el and Org development version these superscript citations should be properly exported to any supported format including odt.

@matogoro
Copy link
Author

matogoro commented May 5, 2024

This is amazing. Thank you so much for your hard work!

For reference, the solution in the thread linked by @kjambunathan also works for my particular use-case, but it's great to having this in Org mainstream as well.

Hopefully this helps other folks with strict editing requirements.

@andras-simonyi
Copy link
Owner

Thanks, I've looked into @kjambunathan's solution and it seems to be using the dedicated org-odt citeproc-el formatter which is in certain respects still a work in progress -- eventually I intend to integrate it into oc-csl too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants