0

I am using Xubuntu Linux and I like to use Emacs Org mode for all my writing, and then export to Libreoffice. At first the default style.xml file set the page style to A4 and used centimeters instead of inches. This changed after I logged into a root account and opened Libreoffice, setting my defaults to en-US, etc. I also made a go at editing the style.xml file to replace cm measurements with in measurements. I really had no clue what I was doing. Things seem to be working well now, but if I need to create a new system installation, I fear that I will lose these settings. Is there an easier way to make these adjustments. i.e. change everything from the start to US norms as opposed to EU defaults? Setting #+LANGUAGE: en-US had no effect in my org file; I understand this is primarily for html files.

1
  • have you tried setting the export styles file to something other than the default? i suspect if you use #+ODT_STYLES_FILE: to point to your current open office default template, or to a new one of your choosing, it will pick up your local settings. see orgmode.org/manual/Applying-custom-styles.html for more. mostly you wouldn't want to use the default template anyway, you can make much nicer looking documents by exporting using your own.
    – martian
    Feb 5, 2022 at 11:43

1 Answer 1

1

Exporting the below Org snippet will produce US letter-sized documents, and it will be in English/US locale. For this snippet to work, you need to install the The enhanced ODT exporter with M-x package-install.

#+LANGUAGE: en_US

#+odt_extra_automatic_styles: <style:page-layout style:name="DefaultPageLayout"
#+odt_extra_automatic_styles:                    style:page-usage="mirrored">
#+odt_extra_automatic_styles:   <style:page-layout-properties fo:margin-bottom="2cm"
#+odt_extra_automatic_styles:                           fo:margin-left="2cm"
#+odt_extra_automatic_styles:                           fo:margin-right="2cm"
#+odt_extra_automatic_styles:                           fo:margin-top="2cm"
#+odt_extra_automatic_styles:                           fo:page-height="27.94cm"
#+odt_extra_automatic_styles:                           fo:page-width="21.59cm"
#+odt_extra_automatic_styles:                           style:footnote-max-height="0cm"
#+odt_extra_automatic_styles:                           style:layout-grid-base-height="0.706cm"
#+odt_extra_automatic_styles:                           style:layout-grid-color="#c0c0c0"
#+odt_extra_automatic_styles:                           style:layout-grid-display="false"
#+odt_extra_automatic_styles:                           style:layout-grid-lines="20"
#+odt_extra_automatic_styles:                           style:layout-grid-mode="none"
#+odt_extra_automatic_styles:                           style:layout-grid-print="false"
#+odt_extra_automatic_styles:                           style:layout-grid-ruby-below="false"
#+odt_extra_automatic_styles:                           style:layout-grid-ruby-height="0.353cm"
#+odt_extra_automatic_styles:                           style:num-format="1"
#+odt_extra_automatic_styles:                           style:print-orientation="portrait"
#+odt_extra_automatic_styles:                           style:writing-mode="lr-tb">
#+odt_extra_automatic_styles:     <style:footnote-sep style:adjustment="left"
#+odt_extra_automatic_styles:                   style:color="#000000"
#+odt_extra_automatic_styles:                   style:distance-after-sep="0.101cm"
#+odt_extra_automatic_styles:                   style:distance-before-sep="0.101cm"
#+odt_extra_automatic_styles:                   style:line-style="solid"
#+odt_extra_automatic_styles:                   style:rel-width="25%"
#+odt_extra_automatic_styles:                   style:width="0.018cm" />
#+odt_extra_automatic_styles:   </style:page-layout-properties>
#+odt_extra_automatic_styles:   <style:header-style />
#+odt_extra_automatic_styles:   <style:footer-style>
#+odt_extra_automatic_styles:     <style:header-footer-properties fo:background-color="transparent"
#+odt_extra_automatic_styles:                                     fo:margin-left="0cm"
#+odt_extra_automatic_styles:                                     fo:margin-right="0cm"
#+odt_extra_automatic_styles:                                     fo:margin-top="0.499cm"
#+odt_extra_automatic_styles:                                     fo:min-height="0.6cm"
#+odt_extra_automatic_styles:                                     style:dynamic-spacing="false" />
#+odt_extra_automatic_styles:   </style:footer-style>
#+odt_extra_automatic_styles: </style:page-layout>

#+odt_extra_automatic_styles: <style:style style:name="DefaultFooter"
#+odt_extra_automatic_styles:              style:parent-style-name="Footer"
#+odt_extra_automatic_styles:              style:family="paragraph">
#+odt_extra_automatic_styles:   <style:paragraph-properties fo:text-align="center"
#+odt_extra_automatic_styles:                               style:justify-single-word="false" />
#+odt_extra_automatic_styles: </style:style>


#+odt_master_styles: <style:master-page style:name="Standard"
#+odt_master_styles:                    style:page-layout-name="DefaultPageLayout">
#+odt_master_styles:   <style:footer>
#+odt_master_styles:     <text:p text:style-name="DefaultFooter">
#+odt_master_styles:       <text:page-number text:select-page="current"/>
#+odt_master_styles:     </text:p>
#+odt_master_styles:   </style:footer>
#+odt_master_styles: </style:master-page>

Some text


The style configuration will look a bit overwhelming, at first. You can learn about it in

  1. Create a stylesheet for your OpenDocument files, and inline the XML definitions right in your Org file–Think HTML_HEAD, or HTML_HEAD_EXTRA but for ODT / DOCX files

  2. Applying custom styles through keywords .

Btw, the units used in styles.xml doesn't matter--it can either be in ins or cms. What you need to do is to configure your LibreOffice UI to display the measurements in ins instead of cms. See Selecting Measurement Units .

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.