i write poetic texts in org mode and i'd like to be able to export them to odt with their horizontal spacing preserved if possible.

it's poetry but not of the traditional kind. text is often heavily indented or spread all over the place. at present i indent text with M-i, which runs tab-to-tab-stop and inserts 8 spaces at at time.

on exporting to odt, all spacing is lost, my lines are left justified. i tried using verse blocks, but it outputs in monospace, and only indents my lines about 2-3 spaces, rather than say the 40 or 50 i have inserted.

ideally i'd like to be able to do anything i might do in a word processor in emacs, and have it preserved on export, if possible.

EDIT: i run emacs 26.1, org-mode 9.3

  • I would suggesting using the verse block, and changing the font in the XML style file.
    – jagrg
    Mar 24, 2020 at 0:42
  • BTW I get exactly the same number of spaces in both files (Org mode version 9.3.6).
    – jagrg
    Mar 24, 2020 at 0:42
  • @jagrg you mean you get same number of spaces in your exported odt file as an org file? // i have wrestled long to become zen master of custom styles for odt exports, but alas to date no dice. i must continue on the long, mysterious climb.
    – martian
    Mar 24, 2020 at 2:58
  • Yes, same number of spaces. Maybe include the steps you tried that failed. All I did was copy OrgOdtStyles.xml to some other directory and replace "Preformatted_20_Text" with "Text_20_body" on the line that says "OrgVerse". I think you also have to add #+odt_styles_file: "/path/to/copied/OrgOdtStyles.xml" to the Org file.
    – jagrg
    Mar 24, 2020 at 14:26
  • didn't work for me. if i enclose the text in verse blocks, it actually only leaves a single space. and it does so if i change the font as you suggested. i haven't done any config on my exporter. I just C-c C-e o O... thanks for showing me the xml file though, that's handy to work from.
    – martian
    Mar 24, 2020 at 19:50

2 Answers 2


i write poetic texts in org mode and i'd like to be able to export them to odt with their horizontal spacing preserved if possible.

Could you copy-paste the poetic text (i.e., the actual org snippet) that you are exporting?

on exporting to odt, all spacing is lost, my lines are left justified.

The Org exporter strips the leading whitespace COMMON to all lines. i.e., The leading COMMON whitespace chars in a verse block are insignificant

  • if ALL lines in the verse are indendented by 8 spaces, then the Org exporter treats the verse block as if it had ZERO leading indentation

  • if ALL BUT ONE line is indented by 8 spaces, and the lone one is indented by 6 spaces, then all lines in the exported verse block will be indented by TWO SPACES, save for that lone line which would have NO indentation.

That said, the easiest way for you to achieve what you want is to use the FORK of the ODT exporter (See Project Summary (OpenDocument Text Exporter for Emacs’ Org Mode)).

The keyword you are looking for is#+ODT_EXTRA_STYLES (See Applying custom styles (OpenDocument Text Exporter for Emacs’ Org Mode))

Here is a sample snippet and the corresponding output

#+odt_preferred_output_format: pdf

#+odt_extra_styles: <style:style style:name="Text_20_body" style:display-name="Text body" style:family="paragraph" style:parent-style-name="Standard" style:class="text">
#+odt_extra_styles:  <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.212cm" loext:contextual-spacing="false">
#+odt_extra_styles:   <style:tab-stops/>
#+odt_extra_styles:  </style:paragraph-properties>
#+odt_extra_styles:  <style:text-properties style:font-name="Courier New1" fo:font-family="&apos;Courier New&apos;" style:font-style-name="Regular" style:font-family-generic="modern" style:font-pitch="fixed" fo:font-size="16pt"/>
#+odt_extra_styles: </style:style>

#+odt_extra_styles: <style:style style:name="OrgVerse" style:family="paragraph" style:parent-style-name="Preformatted_20_Text" style:master-page-name="">
#+odt_extra_styles:  <loext:graphic-properties draw:fill="none" draw:fill-color="#729fcf"/>
#+odt_extra_styles:  <style:paragraph-properties fo:margin-left="0.499cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false" style:page-number="auto" fo:background-color="transparent" fo:padding="0cm" fo:border="none" style:shadow="none">
#+odt_extra_styles:   <style:tab-stops>
#+odt_extra_styles:    <style:tab-stop style:position="1.0cm"/>
#+odt_extra_styles:   </style:tab-stops>
#+odt_extra_styles:  </style:paragraph-properties>
#+odt_extra_styles:  <style:text-properties style:font-name="Comic Sans MS" fo:font-family="&apos;Comic Sans MS&apos;" style:font-style-name="Regular" style:font-family-generic="script" style:font-pitch="variable" fo:font-size="12pt"/>
#+odt_extra_styles: </style:style>

This is a poem by Rudyard Kipling

If you can keep your head when all about you
    Are losing theirs and blaming it on you,
If you can trust yourself when all men doubt you,
    But make allowance for their doubting too;
If you can wait and not be tired by waiting,
    Or being lied about, don’t deal in lies,
Or being hated, don’t give way to hating,
    And yet don’t look too good, nor talk too wise:

(In the above verse block, the indented line uses a SINGLE TAB)

Screenshot of ODT export

Btw, as you might have guessed, the user manual for the FORKED VERSION of ODT exporter is Top (OpenDocument Text Exporter for Emacs’ Org Mode).


so after many gloomy moons of poetic gloom, i worked out my issue, which i hereby declare to all posterity:

setting org-export-preserve-breaks to t, breaks the export of whitespace, even in org-verse blocks.

org-export-preserve-breaks is also set by \n:t in the export template.

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.