Captions and figure references by label are lost when converting .odt to .docx with Open Office. Captions get hidden under the image and truncated by a box. Numeric references are replaced by “Illustration”.

Is there a way to export to .docx from org-mode and preserve these feature?

MWE:

#+ATTR_ODT: :width 10
#+CAPTION: Caption text get hidden by image
#+LABEL: fig:label_image
[[file:./Carl_Spitzweg.jpg]]



See in figure [[fig:label_image]].

Yes there is. The best way to achieve this is to export first to latex, and then use pandoc to convert the latex to Word. There is, luckily, a library that does this already: [ox-word][1]. You'll have to manually install it, since it's not in MELPA. It's part of an Emacs distribution called scimax.

Once you've downloaded it:

(use-package ox-word
:load-path "path/to/dir"
:after ox)

And then C-c C-e w p to export to Word. Figures and references will work just fine.

use-package is a macro that can be installed with MELPA: https://github.com/jwiegley/use-package.

  • Is it possible to use this feature in a simple way, without using the full scimax distribution? From my “own” emacs I got mapcar: Symbol’s function definition is void: org-ref-find-bibliography. From within scimax, I got lost and export seemed to also fail. – Alfred M. Dec 5 at 11:28
  • The instructions I wrote tell you how to use it without the scimax distribution. Just copy the ox-word file from the scimax distribution and put it somewhere in your path, then use to code above to load it. The thing is that ox-word depends on org-ref, another tool you should definitely get familiar with. Install that first. (The dependency should be listed on ox-word, but it's not. Good catch) – dangom Dec 5 at 11:54
  • I now stumble upon pandoc: nil: openFile: does not exist (No such file or directory) if: Wrong type argument: stringp, nil. (pandoc -v yields pandoc 1.19.2.1) – Alfred M. Dec 5 at 15:30
  • maybe update to pandoc 2. It's been out for years – dangom Dec 5 at 17:11
  • It still fail with pandoc 2.5. Something else must be missing on my box. – Alfred M. Dec 6 at 14:34

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.