::: {#tbl-letters}| Col1 | Col2 | Col3 ||------|------|------|| A | B | C || E | F | G || A | G | G |My Caption:::
Subtables
To combine sub-tables into one composition, use a div with a main identifier.
Assign sub-identifiers and optional captions to each table inside the div.
::: {#tbl-panel layout-ncol=2}| Col1 | Col2 | Col3 ||------|------|------|| A | B | C || E | F | G || A | G | G |: First Table {#tbl-first}| Col1 | Col2 | Col3 ||------|------|------|| A | B | C || E | F | G || A | G | G |: Second Table {#tbl-second}Main Caption:::See @tbl-panel for details, especially @tbl-second.
Output:
Note
Note that the “Main Caption” for the table is provided as the last block within the containing div.
Caption Location
Default location is above the table.
Use tbl-cap-location to change the location to top, bottom, or margin. For example:
---tbl-cap-location: top---
Computations
Using Python. Display markdown table using the Python tabulate package along with the Markdown() function from the IPython display module:
Note that we use the display() function imported from IPython so that we can render multiple outputs from a single cell (by default cells only output their last expression).
Grid tables are a more advanced type of markdown tables that allow arbitrary block elements (multiple paragraphs, code blocks, lists, etc.). For example:
+-----------+-----------+--------------------+| Col1 | Col2 | Col3 |+===========+===========+====================+| A | B | - C1 || | | - C2 |+-----------+-----------+--------------------+| E | F | - G1 || | | - G2 |+-----------+-----------+--------------------+: Example of grid table.
Which looks like this when rendered to HTML:
Example of grid table.
Col1
Col2
Col3
A
B
C1
C2
E
F
G1
G2
The row of = separates the header from the table body, and can be omitted for a headerless table. Cells that span multiple columns or rows are not supported.
Alignments can be specified as with classical tables, by putting colons at the boundaries of the separator line after the header:
===: for right-aligned (R)
:=== for left-aligned (L)
:===: for centered (C)
+---------+--------+------------------+| R | L | C |+========:+:=======+:================:+| A | B | C |+---------+--------+------------------+
Which looks like this when rendered to HTML:
R
L
C
A
B
C
For headerless tables, the colons go on the top line instead:
+----------:+:----------+:--------:+| A | B | C |+-----------+-----------+----------+
Which looks like this when rendered to HTML:
A
B
C
Note that grid tables are quite awkward to write with a plain text editor (because unlike pipe tables, the column indicators must align). Here are some tools that can assist with creating grid tables: