Tables¶
To produce tables in MyST, write one line per row, with columns separated by |.
The first row contains the column headings.
The second row defines horizontal alignment of each column and consists of either :- (left-align), :-: (centre-align),
or -: (right-align). If there’s no colon, the text is left-aligned. For example:
Left | Centre | Right
:- | :-: | -:
0.19 | 0.19 | 0.19
90.10 | 90.10 | 90.10
produces
Left |
Centre |
Right |
|---|---|---|
0.19 |
0.19 |
0.19 |
90.10 |
90.10 |
90.10 |
Writing tables by hand in Markdown is very time consuming and the use of a generator tool such as the Markdown Tables Generator is recommended.
Ensure you put a blank line before and after the table.
To number and caption tables, use the table block:
:::{table} Markdown cheatsheet
:name: md
:width: 50%
Write... | to get...
-|-
`*text*` | *text*
`**text**`| **text**
`---` | horizontal line
:::
This produces
Write… |
to get… |
|---|---|
|
text |
|
text |
|
horizontal line |
The width option can be set to an absolute number or a percentage of the webpage width.
The name option defines a mnemonic label (md for the table above) for linking to the table. Note that
the link doesn’t indicate the file containing the table.
All labels must therefore be unique within the website.
If you have data in CSV format, don’t rewrite it into the MyST table format.
Instead, load and display the CSV file with the
csv-table directive.