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


3 Getting Started with ODT export


3.1 Pre-requisites for ODT export

The ODT backend depends on the following programs

ProgramPurpose
‘zip’1To produce OpenDocument files
‘unzip’2To unzip custom styles
‘identify’3To identify the size of an inline image
‘latex’4To compile LaTeX fragments to ‘dvi’ images
‘dvisgm’5To convert ‘dvi’ images to ‘svg’
‘dvipng’6To convert ‘dvi’ images to ‘png’
‘convert’7To convert inline ‘pdf’ to ‘png’
‘latexmlmath’8To convert LaTeX math snippets to MathML
‘mathtoweb’9〃

Of these, ‘zip’ is essential. Rest are optional.


3.2 Installation

You can install the OpenDocument Text export backend using the Emacs package manager. The archive URL for the package is https://kjambunathan.github.io/elpa/.

A typical configuration look like this

(custom-set-variables
 '(package-archives
   (quote
    (("gnu" . "https://elpa.gnu.org/packages/")
     ("ox-odt" . "https://kjambunathan.github.io/elpa/")))))

In the ‘*Packages*’ buffer, packages from this archive show up as below

ox-odt                 9.2.6.263  ... OpenDocument Text Exporter for Org Mode

3.3 Configuration

Here is a sample configuration.

(custom-set-variables
 '(org-odt-convert-process "LibreOffice")
 '(org-odt-preferred-output-format "docx")
 '(org-odt-transform-processes
   '(("Optimize Column Width of all Tables"
      "soffice" "--norestore" "--invisible" "--headless"
      "macro:///OrgMode.Utilities.OptimizeColumnWidth(%I)")
     ("Update All"
      "soffice" "--norestore" "--invisible" "--headless"
      "macro:///OrgMode.Utilities.UpdateAll(%I)")
     ("Reload"
      "soffice" "--norestore" "--invisible" "--headless"
      "macro:///OrgMode.Utilities.Reload(%I)")))
 '(org-latex-to-mathml-convert-command
   "java -jar %j -unicode -force -df %o %I")
 '(org-latex-to-mathml-jar-file
   "/home/kjambunathan/Downloads/mathtoweb.jar"))

(require 'ox-odt)

;; (setcdr (assq 'system org-file-apps-defaults-gnu) "xdg-open %s")
(setcdr (assq 'system org-file-apps-gnu) "xdg-open %s")

(advice-add 'org-open-file :around
            (lambda (orig-fun &rest args)
              ;; Work around a weird problem with xdg-open.
              (let ((process-connection-type nil))
                (apply orig-fun args))))

Above configuration sets up the ODT backend as follows:

  1. Use ‘"LibreOffice"’ (i.e., ‘soffice’ executable) as the document converter
  2. Generate a ‘docx’ document for every ‘odt’ document
  3. Process the ‘odt’ document with a set of LibreOffice Basic Macros to
    • Optimize the column width of all tables
    • Update cross-references, table of contents etc.
    • (if you are already viewing a past version of a ‘odt’ file), re-load the new file in the same application window.
  4. Tell where your ‘mathtoweb’ executable is located, and how it is invoked.
  5. (if you are using a GNU system) open the ‘odt’ document with your preferred OpenDocument viewer, presumably ‘LibreOffice’.

Footnotes

(1)

Info-ZIP

(2)

Info-ZIP

(3)

ImageMagick

(4)

TeX Live

(5)

TeX Live

(6)

dvipng

(7)

ImageMagick

(8)

LaTeXML

(9)

https://sourceforge.net/projects/mathtoweb/. See also MathToWeb.


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