1. Tables 🔗

NML support for tables is still very limited, though it is possible to build complex layouts like this one:

First column Second column
Centered B C
1 2

(1) Sample table

Given by the following code

:TABLE {sample_table} Sample table
| **First column**       |:hspan=2: **Second column** |
|:align=center: Centered | B            | C           |
|:hspan=2: 1                            | 2           |

When a line starts with | it is considered as the start of a table. Other |'s delimit the cells of a table row. You can also use :TABLE {refname} Title before the first line of the table, to make the table into a referenceable element. Tables declared like this are displayed as media.

2. Cell Properties 🔗

On each cell of a table, you may specify properties for the cell, row, column or table. Properties are specified between :'s at the start of a cell. It is not possible to redefine an already present property (e.g setting the table text-alignment twice). Below are the supported properties:

3. Tables to Lua 🔗

You can export a table to use it inside a lua snippet. Using :TABLE[export_as=table1] will make the table available to lua as nml.tables.table1.

Example:

Using Lua, you can perform computations on table rows, cells, etc.

Length Occurences
1.15 357
1.20 143
1.23 72

Average = 1.1725699300699

Which is given by:

1
:TABLE[export_as=measures]
2
| Length | Occurences |
3
| 1.15   | 357        |
4
| 1.20   | 143        |
5
| 1.23   | 72         |
6
@<main
7
function weighted_average(table, i, j)
8
	local weighted_sum = 0
9
	local total = 0
10
	for rowIndex, row in pairs(table) do
11
		if rowIndex ~= 1 then
12
			weighted_sum = weighted_sum + row[i] * row[j];
13
			total = total + row[j]
14
		end
15
	end
16
	return weighted_sum / total
17
end
18
>@
19

20
Average = %<" weighted_average(nml.tables.measures, 1, 2)>%

4. Current limitations 🔗

Current known limitations for tables, may change in the future: