emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jambunathan K <kjambunathan@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: [odt] Support for table templates (was Re: org->odt/html table export: adjusting default behaviour?)
Date: Wed, 14 Sep 2011 15:26:45 +0530	[thread overview]
Message-ID: <81ehzj1m76.fsf_-_@gmail.com> (raw)
In-Reply-To: <81pqjtqife.fsf@gmail.com> (Jambunathan K.'s message of "Fri, 26 Aug 2011 03:10:05 +0530")

[-- Attachment #1: Type: text/plain, Size: 522 bytes --]


> 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.)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: table-template.org --]
[-- Type: text/x-org, Size: 4150 bytes --]

#+TITLE:     table-template.org
#+AUTHOR:    Jambunathan K
#+EMAIL:     kjambunathan@gmail.com
#+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 #3: table-template.odt --]
[-- Type: application/vnd.oasis.opendocument.text, Size: 9841 bytes --]

[-- Attachment #4: Type: text/plain, Size: 889 bytes --]



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.


  parent reply	other threads:[~2011-09-14  9:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-25 15:12 org->odt/html table export: adjusting default behaviour? Matt Price
2011-08-25 15:36 ` Matt Price
2011-08-25 21:40 ` Jambunathan K
2011-08-26 14:24   ` Matt Price
2011-08-28 22:33     ` Jambunathan K
2011-08-28 22:40       ` [PATCH 1/2] Parse and store both col align and col width spec for later use Jambunathan K
2011-08-28 22:41       ` [PATCH 2/2] org-odt.el: Put table style and col sizes under direct user control Jambunathan K
2011-09-14  9:56   ` Jambunathan K [this message]
2011-08-25 22:01 ` org->odt/html table export: adjusting default behaviour? Jambunathan K
2011-08-26 14:13   ` Matt Price

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=81ehzj1m76.fsf_-_@gmail.com \
    --to=kjambunathan@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).