1

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]].

2 Answers 2

1

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.

5
  • 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.
    – M. Toya
    Dec 5, 2018 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)
    – Daniel
    Dec 5, 2018 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)
    – M. Toya
    Dec 5, 2018 at 15:30
  • maybe update to pandoc 2. It's been out for years
    – Daniel
    Dec 5, 2018 at 17:11
  • It still fail with pandoc 2.5. Something else must be missing on my box.
    – M. Toya
    Dec 6, 2018 at 14:34
0

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

#+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]].

I don't have access to Microsoft Office. And I am unable to confirm or reject what the original poster says.

I can confirm that I did experience problems when I imported the ODT file created by org-9.5.3 in to Google Docs. The image doesn't appear and there appears some stray text in figure number. See screenshot below for details.

What worked for me was to use the The enhanced ODT exporter together with the #+ODT_APP: docx keyword. You can install the enhanced ODT exporter using instructions at Getting Started with ODT export (OpenDocument Text Exporter for Emacs’ Org Mode).

It looks like the #+ODT_APP: docx is a way to generate a Microsoft Word-compatible or Google Docs-compatible ODT output.

Down below, first I show the working org snippet and how it renders when imported in to Google Docs, and next I show the org snippets that do not render well when imported in to Google Docs.

With Enhanced ODT exporter ox-odt-9.5.3.436 and with #+ODT_APP: docx

#+title: With Enhanced ODT exporter and ODT_APP keyword

#+ODT_APP: docx

This file is exported with /enhanced ~ox-odt~/:
https://github.com/kjambunathan/org-mode-ox-odt

and with

#+begin_src org
,#+ODT_APP: docx
#+end_src

#+ATTR_ODT: :width 10
#+CAPTION: Caption text get hidden by image
#+LABEL: fig:label_image
[[file:./org-mode-unicorn.png]]

See in figure [[fig:label_image]].

With ox-odt-9.5.3.436 and with #+ODT_APP: docx

With Enhanced ODT exporter ox-odt-9.5.3.436

#+title: With Enhanced ODT exporter

This file is exported with /enhanced ~ox-odt~/:
https://github.com/kjambunathan/org-mode-ox-odt

#+ATTR_ODT: :width 10
#+CAPTION: Caption text get hidden by image
#+LABEL: fig:label_image
[[file:./org-mode-unicorn.png]]

See in figure [[fig:label_image]].

With ox-odt-9.5.3.436

On Vanilla Emacs Org-9.5.3

#+title: on-vanilla-emacs

This file is exported with ~ox-odt~ that comes with ~org-9.5.3~.

#+ATTR_ODT: :width 10
#+CAPTION: Caption text get hidden by image
#+LABEL: fig:label_image
[[file:./org-mode-unicorn.png]]

See in figure [[fig:label_image]].


Captioned Image on Plain Vanilla Emacs Org-9.5.3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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