emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [odt] Support for table templates (was Re: org->odt/html table expor


From: Jambunathan K
Subject: [O] [odt] Support for table templates (was Re: org->odt/html table export: adjusting default behaviour?)
Date: Wed, 14 Sep 2011 15:26:45 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (windows-nt)

> If you need really prettier tables you can rely on Table->Autoformat.

I felt some sort of templating mechanism would be useful for odt
tables[1]. To this end, I have pushed some changes which honors ODF-1.2
spec[2].

The attached table-template.org and table-template.odt should serve as
an illustrative example of what is possible with the odt exporter. 

Note that you need to modify automatic-styles that are in
contrib/odt/styles/OrgOdtContentTemplate.xml. (Please consult the
comments in the attached org file.)

#+TITLE:     table-template.org
#+AUTHOR:    Jambunathan K
#+EMAIL:     address@hidden
#+DESCRIPTION:
#+KEYWORDS:
#+LANGUAGE:  en
#+OPTIONS:   H:3 num:t toc:t \n:nil @:t ::t |:t ^:nil -:t f:t *:t <:t
#+OPTIONS:   TeX:t LaTeX:dvipng skip:nil d:nil todo:t pri:nil tags:not-in-toc

#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
#+LINK_UP:   
#+LINK_HOME: 
#+XSLT:


* Customization

#+begin_src emacs-lisp
  (setq org-export-odt-table-styles
        '(("TableWithHeaderRowAndColumn" "Custom"
           ((use-first-row-styles . t)
            (use-first-column-styles . t)))
          ("TableWithFirstRowandLastRow" "Custom"
           ((use-first-row-styles . t)
            (use-last-row-styles . t)))))
#+end_src

  See docstring of =org-export-odt-table-styles= for more
  information. Also unzip the exported odt file and inspect the
  _content.xml_ for _automatic-styles_ starting with keyword _Custom_.

* Table Templates Illustrated

** Regular Org Table
   This table has no *#+ATTR_ODT:* associated with it.


    |     Labels | C1          | C2            |           C3 |
    |------------+-------------+---------------+--------------|
    |          / | <           | >             |           <> |
    |        <r> | <l>         | <c>           |          <r> |
    | R1 (Right) | R1C1 (Left) | R1C2 (Center) | R1C3 (Right) |
    |         R2 | R2C1        | R2C2          |         R2C3 |
    |------------+-------------+---------------+--------------|
    |         R3 | R3C1        | R3C2          |         R3C3 |
    |         R4 | R4C1        | R4C2          |         R4C3 |
    |------------+-------------+---------------+--------------|
    |         R5 | R5C1        | R5C2          |         R5C3 |
    |         R6 | R6C1        | R6C2          |         R6C3 |
    |         R7 | R7C1        | R7C2          |              |
    |------------+-------------+---------------+--------------|


** Table using header row and column styles
   This table uses table template named _Custom_ and selects the
   following styles:
   - first row
   - first column

#+ATTR_ODT: TableWithHeaderRowAndColumn
    |     Labels | C1          | C2            |           C3 |
    |------------+-------------+---------------+--------------|
    |          / | <           | >             |           <> |
    |        <r> | <l>         | <c>           |          <r> |
    | R1 (Right) | R1C1 (Left) | R1C2 (Center) | R1C3 (Right) |
    |         R2 | R2C1        | R2C2          |         R2C3 |
    |------------+-------------+---------------+--------------|
    |         R3 | R3C1        | R3C2          |         R3C3 |
    |         R4 | R4C1        | R4C2          |         R4C3 |
    |------------+-------------+---------------+--------------|
    |         R5 | R5C1        | R5C2          |         R5C3 |
    |         R6 | R6C1        | R6C2          |         R6C3 |
    |         R7 | R7C1        | R7C2          |              |
    |------------+-------------+---------------+--------------|

** Table using first row and last row styles
   This table also uses the same table template named _Custom_ and
   selects the following styles:
   - first row
   - last row

#+ATTR_ODT: TableWithFirstRowandLastRow
    |     Labels | C1          | C2            |           C3 |
    |------------+-------------+---------------+--------------|
    |          / | <           | >             |           <> |
    |        <r> | <l>         | <c>           |          <r> |
    | R1 (Right) | R1C1 (Left) | R1C2 (Center) | R1C3 (Right) |
    |         R2 | R2C1        | R2C2          |         R2C3 |
    |------------+-------------+---------------+--------------|
    |         R3 | R3C1        | R3C2          |         R3C3 |
    |         R4 | R4C1        | R4C2          |         R4C3 |
    |------------+-------------+---------------+--------------|
    |         R5 | R5C1        | R5C2          |         R5C3 |
    |         R6 | R6C1        | R6C2          |         R6C3 |
    |         R7 | R7C1        | R7C2          |              |
    |------------+-------------+---------------+--------------|

Attachment: table-template.odt
Description: table-template.odt


Footnotes: 

[1] I find the Org's regular way of drawing the grid lines a bit out of
the normal (scholarly?). Internally, I needed some control over the
table cells for supporting numbered equations (which uses tables). Also
a user will prefer "Top-aligned" content for text-intensive tables and
"Centre-aligned" content for text-sparse tables.

[2] LibreOffice's Autoformat facility for tables is richer than what
ODF-1.2 templating mechanism provides for. Unfortunately it is difficult
to configure by hand (as is required for the odt exporter). Honestly
speaking, I had to spend quite a good amount of time tinkering with
automatic styles used with the attached files and I am certain that any
sort of in-built advanced templating mechanism within the odt exporter
would be, what to say, utter madness. I really wish LibreOffice
supported custom styles for table related components.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]