If I export an org mode document to odt that contains a combination of numbered items and paragraphs the exported document does not retain the correct numbering. For example,

1. Question 1
2. Question 2
Text here...
3. Question 3

The exported file, looks like this:

1. Question 1
2. Question 2
Text here...
1. Question 3

These are my org export options:

    (setq org-export-with-section-numbers nil)
    (setq org-export-with-toc nil)
    (setq org-export-with-author nil)
    (setq org-html-validation-link nil)
    (setq org-export-preserve-breaks t)
    (setq org-export-with-broken-links t)

I am running Emacs 27 on Debian 10 and Org mode version 9.1.9

  • I upgraded Org to version 9.2.6 and it did not fix this issue for me. Installing the latest developmental version of Org did fix the problem, but this developmental version has other issues, which led me to remove it. I have therefore not found a working solution thus far to this problem. – Raoul Comninos Nov 25 '19 at 17:32

You don't have one list here: you have two. The Text here... is a separate paragraph and that's not something you can have within a single list. The best that you can do, I think, is to tell your second list numbering to start with 3 (see the [@3] construct below), but note that if you add a third element to the first list, you will need to tweak the beginning number of the second list manually:

1. Question 1
2. Question 2
Text here...
3. [@3]Question 3

See the manual for details.

EDIT: as the OP points out in the comments, this does not work in 9.1.9. The bug was fixed about a year ago:

commit eb806aa50331ac221a0544c3ebc375ac5af63413
Author: Mark A. Hershberger <USER@SOMEWHERE.com>
Date:   Fri Oct 19 09:19:38 2018 -0400

    ox-odt: Add support for text:start-value

    * lisp/ox-odt.el (org-odt-item): Support starting lists at a set
    number via "text:start-value".  Without this, ODF files just restart
    numbering when they should continue with the specified number.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 75f404fb3..2a6e9fcef 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -48,6 +48,7 @@ system than the main Org document.  For example:

 *** New values in clock tables' step: =month= and =year=
+*** ODT export handles numbers cookies in lists
 *** New cell movement functions in tables
 ~S-<UP>~, ~S-<DOWN>~, ~S-<RIGHT>~, and ~S-<LEFT>~ now move cells in
 the corresponding direction by swapping with the adjacent cell.
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 70ef9de2e..66be39f2e 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -1966,10 +1966,12 @@ contextual information."
 CONTENTS holds the contents of the item.  INFO is a plist holding
 contextual information."
   (let* ((plain-list (org-export-get-parent item))
+    (count (org-element-property :counter item))
     (type (org-element-property :type plain-list)))
     (unless (memq type '(ordered unordered descriptive-1 descriptive-2))
       (error "Unknown list type: %S" type))
-    (format "\n<text:list-item>\n%s\n%s"
+    (format "\n<text:list-item%s>\n%s\n%s"
+       (if count (format " text:start-value=\"%s\"" count) "")
        (if (org-element-map item 'table #'identity info 'first-match)

This fix went in to 9.1.15. IOW, upgrade!

  • This made no difference to the numbering in the odt file. The example your furnished exported just the same as did mine above. – Raoul Comninos Nov 19 '19 at 16:27
  • I tested with ODT, HTML and LaTeX: they all work as stated. Did you save the file after you modified it? – NickD Nov 19 '19 at 16:40
  • I tested this again. It does work for HTML and LaTeX but not for ODT on my system. I did save the file, and even turned your example into an org file, without success. – Raoul Comninos Nov 19 '19 at 19:00
  • This is indeed a bug in 9.1.9 - I'm running 9.2.6 where it has been fixed. You might consider upgrading. I'll add the info to the answer. – NickD Nov 19 '19 at 19:28
  • What does M-x org-version say? Also, how did you upgrade (git, Melpa, other)? If you upgraded with git, try git show eb806aa50331ac221a0544c3ebc375ac5af63413 to see whether the commit is included. Otherwise, check lines 1958-1972 of lisp/ox-odt.el against the lines in the patch in my edited post. – NickD Nov 19 '19 at 20:01

So far the only workaround for this problem for me has been to install org-mode-ox-odt package which exports to odt without any problem.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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