Good Bye! List Tables
; Hello! Transcluded Tables
In an earlier post, I talked about how to Create tables with paragraph-like content in Org mode, with the least amount of hassle.
In that post, I recommended using a List Table
.
A List Table
is essentially a two-level Org
list which gets transformed in to a Table
.
The problem with the List Tables
is that you have to imagine your table as a two-level list and compose them as such. This mapping of table in to a list is a tedious process. My own experience suggests that you would spend a fair amount of time indenting and re-indenting your list items.
I recently discovered that you no longer need to use a List Table to create a table with multi-paragraph content. You only need a Transcluded Table.
What is a Trascluded Table
The enhanced OpenDocument exporter describes a transcluded table as below:
When the
org-odt-experimental-features
hastransclude-sole-footnote-references-in-a-table
feature enabled, a table cell whose content is a sole footnote reference will be typeset as if it held the associated footnote definition. For simplicity, let us call these"Transcluded Tables"
.
The definition is a bit cryptic, and this post will strive to unravel Transcluded Tables
for you.
For now, it suffices to note that a transcluded table
is an Org
table and it has extra semantics on how the body text of a table cell is sourced. In other words, a transcluded table
looks like just any other Org
table, and unlike with Org
tables, the cell contents are as easy to edit as regular text. While composing your table, you no longer have to narrow your columns or grapple with your table overflowing outside of your display area or wrapping over like a serpentine monster.
Without further ado, let us get started!
Objective: Create a Program Schedule for a Conference
This article will explore how to create how to create a table with multi-paragraph content, and spanned cells using Emacs Org mode
.
Specifically, you will be creating the following table.
Figure 1: Conference Schedule created with a Transcluded Table
Note that the above table
- has multi-paragraph content
- has cells that span multiple rows and/or columns
- has columns that are aligned vertically to middle of the cell
Note that none of the above three features are possible with plain vanilla Emacs
and Org mode
. You need the enhanced ODT exporter, if you need transcluded tables
.
Step 1: Pre-requisites
Install the enhanced ODT exporter.
I am using the version ox-odt-9.5.3.467.tar
. See this link for detailed instruction.
Step 2: Enable Transcluded Table
In order to use the Transcluded Table
you need to enable it. So, add the following to your user-init-file
, and restart Emacs
.
(add-to-list 'org-odt-experimental-features
'transclude-sole-footnote-references-in-a-table)
Step 3: Create an Org
file with following content
(add-to-list 'org-odt-experimental-features
'transclude-sole-footnote-references-in-a-table)
#+CAPTION: LibreLorem Conference 2022 Program Schedule #+ATTR_ODT: :col-cookies "| m4 | m3 | m9 | m9 |" #+ATTR_ODT: :style "GriddedTable" #+ATTR_ODT: :span "@1$1{1:2}" #+ATTR_ODT: :span "@3$1{6:1}" #+ATTR_ODT: :span "@5$3{2:2}" #+ATTR_ODT: :span "@7$4{2:1}" |--------------+--------+--------------------------+--------------------------| | | | *Room 1* | *Room 2* | |--------------+--------+--------------------------+--------------------------| | *Day & Date* | *Time* | [fn:session-and-speaker] | [fn:session-and-speaker] | |--------------+--------+--------------------------+--------------------------| | [fn:day1] | 9:00 | [fn:day1room1slot1] | | |--------------+--------+--------------------------+--------------------------| | | 11:00 | [fn:day1room1slot2] | [fn:day1room2slot2] | |--------------+--------+--------------------------+--------------------------| | | 13:00 | [fn:day1lunchbreak] | | |--------------+--------+--------------------------+--------------------------| | | 13:30 | | | |--------------+--------+--------------------------+--------------------------| | | 14:00 | [fn:day1room1slot3] | [fn:day1room2slot3and4] | |--------------+--------+--------------------------+--------------------------| | | 16:00 | [fn:day1room1slot4] | | |--------------+--------+--------------------------+--------------------------| [fn:session-and-speaker] #+ATTR_ODT: :style "Text_20_body_20_bold" Session #+ATTR_ODT: :p-style "Text_20_body_20_bold" - Speaker(s) [fn:day1lunchbreak] #+begin_center --- Lunch Break --- #+end_center [fn:day1] #+ATTR_ODT: :style "Text_20_body_20_bold" #+begin_bold _Day 1_ Monday,\\ June 20, 2022 #+end_bold [fn:day1room1slot1] Welcome & Introduction Information about Conference & City Welcome from University Authorities - Sponsors: Pariatur Officia & Sed Veniam [fn:day1room1slot2] In occaecat elit, non labore nulla veniam, quis - Proident Cupidatat [fn:day1room1slot3] Deserunt amet, nisi ad elit, elit, ipsum ipsum - In Consectetur [fn:day1room1slot4] Reprehenderit sit veniam, mollit esse labore et officia excepteur nisi - Sint Irure [fn:day1room2slot1] Qui duis dolor mollit dolor tempor quis duis - Eiusmod Sint [fn:day1room2slot2] Ipsum ea magna sint id deserunt et fugiat - Elit Quis [fn:day1room2slot3and4] Certificate Workshop - Minim Exercitation - Cillum Ipsum
Step 4: Export it to OpenDocument format
You can export the Org
file to OpenDocument
/ LibreOffice
format with C-c C-e o O
.
If everything goes alright, you will see the get this table.
I am a bit lost; Can you explain what is happening the Org
file?
Down below you see an annotated version of the above Org
file.
Pay particular attention to
- how a table cell is mapped to its content through footnotes
- The footnote references in a cell tell the exporter where to source the body text of a table cell.
- the
:span
lines - If you have ever created a
HTML
table with cells that haverowspan
s and acolspan
s, you will be at home here. - the
:col-cookies
line - The syntax closely mirrors the
col cookies
that you see in anOrg
cell. The only novel bit is them
.m
corresponds to align cell contents vertically to the middle of the cell. The alternatives tom
aret
andb
.
Conclusion
A Transcluded Table
has many advantages over and above a List Table
.
- They look like any other
Org Table
- An
Org
footnote can contain structurally complex content. This means that you can put even a table within an table cell - With
:span
lines, it is possible to create real-world tables even your income tax ones
A Transcluded Table
has its disadvantages:
- Constructing a transcluded table requires a clear plan
- Getting the
:span
lines is effortful; It requires multiple trials and errors to get the details right.
Before I sign off, here is a challenge for you …
A Challenge to the Reader
Using information in this post, you can create the following spiral
using an Org
table. Would you like to give it a try?
The “art work ” above is stunning, but its guts is un-inspiring …
#+ATTR_ODT: :rel-width 40 #+ATTR_ODT: :style "GriddedTable" #+ATTR_ODT: :span "@1$1{4:1} @1$2{1:4}" #+ATTR_ODT: :span "@2$2{2:1} @2$3{1:2} @2$5{4:1}" #+ATTR_ODT: :span "@3$4{2:2}" #+ATTR_ODT: :span "@4$2{1:2}" #+ATTR_ODT: :span "@5$1{1:4}" |---+---+---+---+---| | | | | | | |---+---+---+---+---| | | | | | | |---+---+---+---+---| | | | | | | |---+---+---+---+---| | | | | | | |---+---+---+---+---| | | | | | | |---+---+---+---+---|