Changes

Jump to navigation Jump to search
2,813 bytes added ,  09:08, 30 July 2015
new page, first save
< [[Tables_Overview]] | [[source:tabl-xtb.lua|tabl-xtb.lua]]

=Extreme Tables=

This is just an excerpt from the [http://www.pragma-ade.com/general/manuals/xtables-mkiv.pdf xtables manual].

“Extreme Tables” (xtable) are a variant of the “natural tables” ([[TABLE]]). They are suited for tables that span several pages. The used two-pass mechanism isn’t simple, but fast. It works only in ConTeXt MkIV, because it’s Lua-based.

=List of commands=

* {{cmd|definextable|[name][parent]]}}
* {{cmd|setupxtable|[settings]}} or {{cmd|setupxtable|[defined name][settings]}}
* {{cmd|startxtable}} (with defined name or settings)
* {{cmd|startxtablehead}}
* {{cmd|startxrowgroup}}
* {{cmd|startxrow}}
* {{cmd|startxcellgroup}}
* {{cmd|startxcell}}

=Simple sample=

<texcode>
\startxtable
\startxrow
\startxcell one
\startxcell two
\stopxrow
\startxrow
\startxcell alpha \stopxcell
\startxcell beta \stopxcell
\stopxrow
\stopxtable
</texcode>

Since xtables are a bunch of nested {{cmd|framed}}s, you can style each unit with the known parameters.

xtables can be nested. Sub-tables inherit the properties of their enclosing cell.

=XML=

The following example demonstrates that we can use this mechanism in xml too. The example was provided by Thomas Schmitz. First we show how a table looks like in xml:

<xmlcode>
<table>
<tablerow>
<tablecell>
One
</tablecell>
<tablecell>
Two
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<b>Three</b>
</tablecell>
<tablecell>
Four
</tablecell>
</tablerow>
</table>
</xmlcode>

We need to map these elements to setups:
<texcode>
\startxmlsetups xml:testsetups
\xmlsetsetup{main}{b|table|tablerow|tablecell}{xml:*}
\stopxmlsetups
\xmlregistersetup{xml:testsetups}
</texcode>

The setups themselves are rather simple as we don’t capture any attributes.

<texcode>
\startxmlsetups xml:b
\bold{\xmlflush{#1}}
\stopxmlsetups
\startxmlsetups xml:table
\startembeddedxtable
\xmlflush{#1}
\stopembeddedxtable
\stopxmlsetups
\startxmlsetups xml:tablerow
\startxrow
\xmlflush{#1}
\stopxrow
\stopxmlsetups
\startxmlsetups xml:tablecell
\startxcell
\xmlflush{#1}
\stopxcell
\stopxmlsetups
</texcode>

We now process the example. Of course it will also work for files.

<texcode>
\xmlprocessbuffer{main}{test}{}
</texcode>

=Ye olde syntax=

For the impatient a small additional module is provided that remaps the natural table commands onto extreme tables:
<texcode>
\usemodule[ntb-to-xtb]
</texcode>

After that:
<texcode>
\bTABLE \bTR
\bTD[background=color,backgroundcolor=red] one \eTD
\bTD[width=2cm] two \eTD
\eTR
\bTR
\bTD[width=5cm] alpha \eTD
\bTD[background=color,backgroundcolor=yellow] beta \eTD
\eTR \eTABLE
</texcode>

Navigation menu