I would like to know how to center the text in a file exported from Org-mode to .odt

Example of what I want:

* TODO center text


                               * DONE center text

Bonuses if it will automatically center when I type, or press enter.

Edit: I want to do this and then export to odt.

  • 1
    Why would yoiu want that in org-mode?? Do you actually want this in exported output? – Tobias Feb 20 '16 at 17:45
  • 2
    Yes actually, I want to export my org files as odt files for scripts for games and animations. – Anti.Josh Feb 20 '16 at 18:04

Although you cannot center headings (lines starting from *'s), #+BEGIN_CENTER ~ #+END_CENTER can center parts of the document.

Usage: test.org

#+TITLE: Test

- [ ] Hoge
- [X] Fuga

Then export to ODT in your workflow. This will result in the bullet points being centered in the produced ODT file.


You can center lines with the command center-line (M-o M-s). Other options include center-paragraph and center-region.

However, you should probably not use this command on org-mode headers. Headers are only recognized as such when the asterisks begin at the first column, so centering one turns it into plain text.

  • Yes, this works, but when I export this to odt it doesn't center. I just edited my original post to include this. – Anti.Josh Feb 20 '16 at 19:05

I'm confused. Are you benefiting from centering the text in Emacs? As Dan points out, that can break a lot of Org's parsing assumptions.

If you can accept a solution that leaves the headlines left-aligned in Org but centers the text in the exported ODT, have a look at this part of the manual. Paraphrasing:

  • Create a sample example.org file and export it to ODT.
  • Open the example.odt using LibreOffice.
  • Use the Stylist (F11 on my system) to locate the target styles—you probably want Heading (for all headings) or Heading N (for some depth N)—and modify those to be center-aligned.
  • Save the modified file either as an OpenDocument Text (.odt) or OpenDocument Template (.ott) file.
  • Back in Emacs, if you want to center headlines in every exported file by default, customize the variable org-odt-styles-file and point it to the newly created file. If you only want to center headlines in a few files, insert #+ODT_STYLES_FILE: "new file" at the top of just the files you want to affect.

The solution to center the title in exported odt file,

open the exporting odt file with Emacs, in the opened buffer, select content.xml and press Enter key.

In content.xml, say you want to center the level 1 heading, find text text:h text:style-name="Heading_20_1" search and replace it with "text:h text:style-name="NewHeading_1".

then scroll back, move the focus inside tag <office:automatic-styles>, insert below code,

<style:style style:name="NewHeading_1" style:family="paragraph" style:parent-style-name="Heading_20_1">
  <style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/>

Save and exit Emacs.

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.