Next: , Previous: , Up: OpenDocument Text Exporter for Emacs’ Org Mode   [Contents][Index]


6 Applying custom styles


6.1 Applying custom styles through keywords


6.1.1 Skeletal structure of ‘styles.xml

<?xml version="1.0" encoding="UTF-8"?>
<office:document-styles>
  <office:font-face-decls>
    <!-- Stuff from your default styles file -->
  </office:font-face-decls>

  <office:styles>
    <!-- Stuff from your default styles file -->
    <!-- ODT_EXTRA_STYLES goes here -->
  </office:styles>

  <office:automatic-styles>
    <!-- ODT_EXTRA_AUTOMATIC_STYLES goes here -->
    <!-- Stuff from your regular styles file -->    
  </office:automatic-styles>

  <office:master-styles>
    <!-- Stuff from your default styles file -->
    <!-- ODT_MASTER_STYLES goes here -->
  </office:master-styles>
</office:document-styles>

6.1.2 Skeletal structure of ‘contents.xml

<office:document-content>
  <office:scripts/>
  <office:font-face-decls>
    <!-- Stuff from your default styles file -->
  </office:font-face-decls>

  <office:automatic-styles>
    <!-- Stuff from your default styles file -->
    <!-- ODT_AUTOMATIC_STYLES goes here -->
  </office:automatic-styles>

  <office:body>
    <office:text>
      <!-- Stuff from your default styles file -->
    </office:text>
  </office:body>
</office:document-content>

6.1.3 ‘ODT_EXTRA_STYLES

ODT_EXTRA_STYLES

#+ODT_EXTRA_STYLES: <style:style style:name="Text_20_body_large"
#+ODT_EXTRA_STYLES:              style:family="paragraph"
#+ODT_EXTRA_STYLES:              style:parent-style-name="Text_20_body">
#+ODT_EXTRA_STYLES:   <style:text-properties fo:font-size="150%"/>
#+ODT_EXTRA_STYLES: </style:style>

*** A regular paragraph

Nunc eleifend leo vitae magna.  Nunc eleifend leo vitae magna.
Curabitur lacinia pulvinar nibh.  Donec posuere augue in quam.
Aliquam posuere.  Nullam rutrum.  Aliquam posuere.

*** Same paragraph, in a larger font

#+ATTR_ODT: :style "Text_20_body_large"
Nunc eleifend leo vitae magna.  Nunc eleifend leo vitae magna.
Curabitur lacinia pulvinar nibh.  Donec posuere augue in quam.
Aliquam posuere.  Nullam rutrum.  Aliquam posuere.

custom-styles-1

6.1.4 ‘ODT_AUTOMATIC_STYLES

ODT_AUTOMATIC_STYLES

#+ODT_AUTOMATIC_STYLES: <style:style style:name="DropCaps"
#+ODT_AUTOMATIC_STYLES:              style:family="paragraph"
#+ODT_AUTOMATIC_STYLES:              style:parent-style-name="Text_20_body">
#+ODT_AUTOMATIC_STYLES:  <style:paragraph-properties>
#+ODT_AUTOMATIC_STYLES:   <style:drop-cap style:lines="3"/>
#+ODT_AUTOMATIC_STYLES:  </style:paragraph-properties>
#+ODT_AUTOMATIC_STYLES: </style:style>

*** A regular paragraph

Nunc eleifend leo vitae magna.  Nunc eleifend leo vitae magna.
Curabitur lacinia pulvinar nibh.  Donec posuere augue in quam.
Aliquam posuere.  Nullam rutrum.  Aliquam posuere.

*** Same paragraph, but with =Drop Caps=

#+ATTR_ODT: :style "DropCaps"
Nunc eleifend leo vitae magna.  Nunc eleifend leo vitae magna.
Curabitur lacinia pulvinar nibh.  Donec posuere augue in quam.
Aliquam posuere.  Nullam rutrum.  Aliquam posuere.

custom-styles-2

6.1.5 ‘ODT_MASTER_STYLES’ and ‘ODT_EXTRA_AUTOMATIC_STYLES

ODT_EXTRA_IMAGES
ODT_MASTER_STYLES
ODT_EXTRA_AUTOMATIC_STYLES

#+ODT_EXTRA_IMAGES: Pictures/org-mode-unicorn.png

#+ODT_EXTRA_STYLES: <style:style style:name="Header"
#+ODT_EXTRA_STYLES:              style:family="paragraph">
#+ODT_EXTRA_STYLES:   <loext:graphic-properties draw:fill="none"/>
#+ODT_EXTRA_STYLES:   <style:paragraph-properties
#+ODT_EXTRA_STYLES:       fo:margin-left="2.499cm"
#+ODT_EXTRA_STYLES:       fo:margin-right="2.499cm"
#+ODT_EXTRA_STYLES:       fo:margin-top="0cm"
#+ODT_EXTRA_STYLES:       fo:margin-bottom="0.499cm"
#+ODT_EXTRA_STYLES:       fo:text-align="center"
#+ODT_EXTRA_STYLES:       style:justify-single-word="false"
#+ODT_EXTRA_STYLES:       fo:text-indent="0cm"
#+ODT_EXTRA_STYLES:       style:auto-text-indent="false"
#+ODT_EXTRA_STYLES:       fo:background-color="transparent"
#+ODT_EXTRA_STYLES:       fo:padding-left="0cm"
#+ODT_EXTRA_STYLES:       fo:padding-right="0cm"
#+ODT_EXTRA_STYLES:       fo:padding-top="0cm"
#+ODT_EXTRA_STYLES:       fo:padding-bottom="0.199cm"
#+ODT_EXTRA_STYLES:       fo:border-left="none"
#+ODT_EXTRA_STYLES:       fo:border-right="none"
#+ODT_EXTRA_STYLES:       fo:border-top="none"
#+ODT_EXTRA_STYLES:       fo:border-bottom="0.06pt solid #000000"/>
#+ODT_EXTRA_STYLES:   <style:text-properties
#+ODT_EXTRA_STYLES:       fo:font-size="18pt" fo:font-style="italic"
#+ODT_EXTRA_STYLES:       style:font-size-asian="18pt"
#+ODT_EXTRA_STYLES:       style:font-style-asian="italic"
#+ODT_EXTRA_STYLES:       style:font-size-complex="18pt"
#+ODT_EXTRA_STYLES:       style:font-style-complex="italic"/>
#+ODT_EXTRA_STYLES: </style:style>

#+ODT_EXTRA_STYLES:  <style:style style:name="Logo" style:family="graphic"
#+ODT_EXTRA_STYLES:               style:parent-style-name="Graphics">
#+ODT_EXTRA_STYLES:    <style:graphic-properties
#+ODT_EXTRA_STYLES:        svg:width="2.311cm" fo:min-height="2.499cm"
#+ODT_EXTRA_STYLES:        svg:x="0cm" svg:y="-0.9cm" fo:margin-left="0cm"
#+ODT_EXTRA_STYLES:        fo:margin-right="0cm" fo:margin-top="0cm"
#+ODT_EXTRA_STYLES:        fo:margin-bottom="0cm" style:wrap="none"
#+ODT_EXTRA_STYLES:        style:vertical-pos="middle"
#+ODT_EXTRA_STYLES:        style:vertical-rel="paragraph-content"
#+ODT_EXTRA_STYLES:        style:horizontal-pos="left"
#+ODT_EXTRA_STYLES:        style:horizontal-rel="page-content"
#+ODT_EXTRA_STYLES:        fo:background-color="transparent"
#+ODT_EXTRA_STYLES:        draw:fill="none"/>
#+ODT_EXTRA_STYLES:  </style:style>

#+ODT_MASTER_STYLES: <style:master-page
#+ODT_MASTER_STYLES:     style:name="Standard"
#+ODT_MASTER_STYLES:     style:page-layout-name="Mpm1">
#+ODT_MASTER_STYLES:   <style:header>
#+ODT_MASTER_STYLES:     <text:p text:style-name="Header">
#+ODT_MASTER_STYLES:       <draw:frame
#+ODT_MASTER_STYLES:           draw:style-name="Logo"
#+ODT_MASTER_STYLES:           draw:name="Image1"
#+ODT_MASTER_STYLES:           text:anchor-type="paragraph"
#+ODT_MASTER_STYLES:           svg:width="2.311cm"
#+ODT_MASTER_STYLES:           svg:height="2.499cm"
#+ODT_MASTER_STYLES:           draw:z-index="0">
#+ODT_MASTER_STYLES:         <draw:image
#+ODT_MASTER_STYLES:             xlink:href="Pictures/org-mode-unicorn.png"
#+ODT_MASTER_STYLES:             xlink:type="simple"
#+ODT_MASTER_STYLES:             xlink:show="embed"
#+ODT_MASTER_STYLES:             xlink:actuate="onLoad"
#+ODT_MASTER_STYLES:             loext:mime-type="image/png"/>
#+ODT_MASTER_STYLES:     </draw:frame>Friends of the Unicorn</text:p>
#+ODT_MASTER_STYLES:   </style:header>
#+ODT_MASTER_STYLES: </style:master-page>

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

Nunc eleifend leo vitae magna.  Nunc eleifend leo vitae magna.
Curabitur lacinia pulvinar nibh.  Donec posuere augue in quam.
Aliquam posuere.  Nullam rutrum.  Aliquam posuere.

custom-styles-4

6.2 Applying custom styles through a style template

The ODT exporter ships with a set of OpenDocument styles (see Working with OpenDocument style files) that ensure a well-formatted output. These factory styles, however, may not cater to your specific tastes. To customize the output, you can either modify the above styles files directly, or generate the required styles using an application like LibreOffice. The latter method is suitable for expert and non-expert users alike, and is described here.


6.2.1 Applying custom styles - the easy way

  1. Create a sample ‘example.org’ file with the below settings and export it to ODT format.
    #+OPTIONS: H:10 num:t
    
  2. Open the above ‘example.odt’ using LibreOffice. Use the Stylist to locate the target styles - these typically have the ‘Org’ prefix - and modify those to your taste. Save the modified file either as an OpenDocument Text (‘.odt’) or OpenDocument Template (‘.ott’) file.
  3. Customize the variable ‘org-odt-styles-file’ and point it to the newly created file. For additional configuration options see Overriding factory styles.

    If you would like to choose a style on a per-file basis, you can use the ‘#+ODT_STYLES_FILE’ option. A typical setting will look like

    #+ODT_STYLES_FILE: "/path/to/example.ott"
    

    or

    #+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
    

6.2.2 Using third-party styles and templates

You can use third-party styles and templates for customizing your output. This will produce the desired output only if the template provides all style names that the ‘ODT’ exporter relies on. Unless this condition is met, the output is going to be less than satisfactory. So it is highly recommended that you only work with templates that are directly derived from the factory settings.


Next: , Previous: , Up: OpenDocument Text Exporter for Emacs’ Org Mode   [Contents][Index]