Table
You can build custom tables using the Table type.
Argument 1: cells
The table's content is given as an AbstractMatrix of Cells:
using SummaryTables
cells = [Cell("$col$row") for row in 1:5, col in 'A':'E']
Table(cells)| A1 | B1 | C1 | D1 | E1 |
| A2 | B2 | C2 | D2 | E2 |
| A3 | B3 | C3 | D3 | E3 |
| A4 | B4 | C4 | D4 | E4 |
| A5 | B5 | C5 | D5 | E5 |
Keyword: header
You can pass an Int to mark the last row of the header section. A divider line is placed after this row.
using SummaryTables
cells = [Cell("$col$row") for row in 1:5, col in 'A':'E']
Table(cells; header = 1)| A1 | B1 | C1 | D1 | E1 |
| A2 | B2 | C2 | D2 | E2 |
| A3 | B3 | C3 | D3 | E3 |
| A4 | B4 | C4 | D4 | E4 |
| A5 | B5 | C5 | D5 | E5 |
Keyword: footer
You can pass an Int to mark the first row of the footer section. A divider line is placed before this row.
using SummaryTables
cells = [Cell("$col$row") for row in 1:5, col in 'A':'E']
Table(cells; footer = 5)| A1 | B1 | C1 | D1 | E1 |
| A2 | B2 | C2 | D2 | E2 |
| A3 | B3 | C3 | D3 | E3 |
| A4 | B4 | C4 | D4 | E4 |
| A5 | B5 | C5 | D5 | E5 |
Keyword: footnotes
The footnotes keyword allows to add custom footnotes to the table which do not correspond to specific Annotated values in the table.
using SummaryTables
cells = [Cell("$col$row") for row in 1:5, col in 'A':'E']
Table(cells; footnotes = ["Custom footnote 1", "Custom footnote 2"])| A1 | B1 | C1 | D1 | E1 |
| A2 | B2 | C2 | D2 | E2 |
| A3 | B3 | C3 | D3 | E3 |
| A4 | B4 | C4 | D4 | E4 |
| A5 | B5 | C5 | D5 | E5 |
| Custom footnote 1 Custom footnote 2 | ||||
Keyword: rowgaps
It can be beneficial for the readability of larger tables to add gaps between certain rows. These gaps can be passed as a Vector of Pairs where the first element is the index of the row gap and the second element is the gap size. The size is an Em or Pt length like 0.8em or 8pt, or a bare number interpreted as points. The em and pt unit constants are imported with using SummaryTables: em, pt.
using SummaryTables
using SummaryTables: em
cells = [Cell("$col$row") for row in 1:9, col in 'A':'E']
Table(cells; rowgaps = [3 => 0.8em, 6 => 0.8em])| A1 | B1 | C1 | D1 | E1 |
| A2 | B2 | C2 | D2 | E2 |
| A3 | B3 | C3 | D3 | E3 |
| A4 | B4 | C4 | D4 | E4 |
| A5 | B5 | C5 | D5 | E5 |
| A6 | B6 | C6 | D6 | E6 |
| A7 | B7 | C7 | D7 | E7 |
| A8 | B8 | C8 | D8 | E8 |
| A9 | B9 | C9 | D9 | E9 |
Keyword: colgaps
It can be beneficial for the readability of larger tables to add gaps between certain columns. These gaps can be passed as a Vector of Pairs where the first element is the index of the column gap and the second element is the gap size, given like the rowgaps sizes above.
using SummaryTables
using SummaryTables: em
cells = [Cell("$col$row") for row in 1:5, col in 'A':'I']
Table(cells; colgaps = [3 => 0.8em, 6 => 0.8em])| A1 | B1 | C1 | D1 | E1 | F1 | G1 | H1 | I1 |
| A2 | B2 | C2 | D2 | E2 | F2 | G2 | H2 | I2 |
| A3 | B3 | C3 | D3 | E3 | F3 | G3 | H3 | I3 |
| A4 | B4 | C4 | D4 | E4 | F4 | G4 | H4 | I4 |
| A5 | B5 | C5 | D5 | E5 | F5 | G5 | H5 | I5 |
Keyword: linebreak_footnotes
By default, footnotes are printed on a separate line each. They can be printed in a single paragraph by setting linebreak_footnotes = false.
This parameter can also be set as a global default to apply the setting across all tables.
using SummaryTables
cells = [Cell("$col$row") for row in 1:5, col in 'A':'I']
Table(cells; footnotes = ["Footnote 1.", "Footnote 2."])| A1 | B1 | C1 | D1 | E1 | F1 | G1 | H1 | I1 |
| A2 | B2 | C2 | D2 | E2 | F2 | G2 | H2 | I2 |
| A3 | B3 | C3 | D3 | E3 | F3 | G3 | H3 | I3 |
| A4 | B4 | C4 | D4 | E4 | F4 | G4 | H4 | I4 |
| A5 | B5 | C5 | D5 | E5 | F5 | G5 | H5 | I5 |
| Footnote 1. Footnote 2. | ||||||||
Table(cells; footnotes = ["Footnote 1.", "Footnote 2."], linebreak_footnotes = false)| A1 | B1 | C1 | D1 | E1 | F1 | G1 | H1 | I1 |
| A2 | B2 | C2 | D2 | E2 | F2 | G2 | H2 | I2 |
| A3 | B3 | C3 | D3 | E3 | F3 | G3 | H3 | I3 |
| A4 | B4 | C4 | D4 | E4 | F4 | G4 | H4 | I4 |
| A5 | B5 | C5 | D5 | E5 | F5 | G5 | H5 | I5 |
| Footnote 1. Footnote 2. | ||||||||
Keywords: rule widths and paddings
The widths of the table's rules and the spacing around its cells can be set with these keywords, which are also available as global defaults:
outer_rule_widthsets the width of the rules above and below the table.inner_rule_widthsets the width of the rules below the header and above the footer.cell_rule_widthsets the width of the rules drawn for cells withborder_bottom = true.column_paddingsets the horizontal space between adjacent columns.row_paddingsets the vertical space between adjacent rows.
Each takes a length, either relative to the font size as an Em like 0.1em, or absolute as a Pt like 1pt, and renders consistently across all backends. The em and pt unit constants are imported with using SummaryTables: em, pt.
using SummaryTables
using SummaryTables: em, pt
cells = [Cell("$col$row") for row in 1:5, col in 'A':'E']
Table(cells;
header = 1,
outer_rule_width = 2pt,
inner_rule_width = 1pt,
column_padding = 1.5em,
)| A1 | B1 | C1 | D1 | E1 |
| A2 | B2 | C2 | D2 | E2 |
| A3 | B3 | C3 | D3 | E3 |
| A4 | B4 | C4 | D4 | E4 |
| A5 | B5 | C5 | D5 | E5 |
Keyword: footnote_size
Sets the font size of the footnotes and annotations, as an Em or Pt length.
using SummaryTables
using SummaryTables: pt
cells = [Cell("$col$row") for row in 1:5, col in 'A':'E']
Table(cells; footnotes = ["A footnote."], footnote_size = 12pt)| A1 | B1 | C1 | D1 | E1 |
| A2 | B2 | C2 | D2 | E2 |
| A3 | B3 | C3 | D3 | E3 |
| A4 | B4 | C4 | D4 | E4 |
| A5 | B5 | C5 | D5 | E5 |
| A footnote. | ||||
Keyword: footnote_halign
Aligns the footnotes horizontally at the :left (the default), :center or :right.
using SummaryTables
cells = [Cell("$col$row") for row in 1:5, col in 'A':'E']
Table(cells; footnotes = ["A footnote."], footnote_halign = :right)| A1 | B1 | C1 | D1 | E1 |
| A2 | B2 | C2 | D2 | E2 |
| A3 | B3 | C3 | D3 | E3 |
| A4 | B4 | C4 | D4 | E4 |
| A5 | B5 | C5 | D5 | E5 |
| A footnote. | ||||