org-mode section numbers (when exported to html) by default starts count from 1, however it is traditional in computer science to start counting from zero. How to make org-mode section numbers start counting from 0 instead of 1?

  • 1
    Is this question about exporting to HTML?
    – db48x
    Commented Feb 10, 2017 at 0:25

2 Answers 2


Plain lists are turned into HTML by the function org-html-plain-list, which calls org-html-begin-plain-list. org-html-begin-plain-list outputs the <ol> tag, and has a provision for outputting a start attribute as well, but org-html-plain-list doesn't use it. Interestingly, in the version of org-mode that I happen to have (which is 6 months old), there's a commented out section of code that looks like someone was thinking about implementing this:

(defun org-html-plain-list (plain-list contents info)
  "Transcode a PLAIN-LIST element from Org to HTML.
CONTENTS is the contents of the list.  INFO is a plist holding
contextual information."
  (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
     (type (org-element-property :type plain-list)))
    (format "%s\n%s%s"
        (org-html-begin-plain-list type)
        contents (org-html-end-plain-list type))))

It looks like it would look for a COUNTER property nearby in the org file. Of course, that would still make you put something in for every single list you used, but it would be a start.

What you could do is use add-advice to override org-html-begin-plain-list, so that it always outputs a start="0" attribute on ordered lists. You might double-check what the latest version of org-mode does as well; perhaps they've improved it.


This is a hack, but you can mostly get the numbering right by making the first section unnumbered.

In other words, this source file:

* Foo
* Bar
* Baz

will result in this table of contents:

  • Foo
  • 1. Bar
  • 2. Baz

It's not super ideal, but it's the best I've been able to do without hacking the org-mode source code.

  • 1
    I guess that as an additional hack you could simply change heading "* Foo" to be "* 0. Foo", and that would give the OP the zeroth list item he wanted.
    – tkp
    Commented Jul 31, 2023 at 20:32

Your Answer

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

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