|
2 | 2 | title: Tables |
3 | 3 | --- |
4 | 4 |
|
5 | | -## GFM Table |
| 5 | +A table is an arrangement of data with rows and columns. Each row consists of cells containing arbitrary text in which inlines are parsed, separated by pipes `|`. The rows of a table consist of: |
6 | 6 |
|
7 | | -You can use the GFM (GitHub Flavored Markdown) table syntax to create a table. |
| 7 | +* a single header row |
| 8 | +* a delimiter row separating the header from the data |
| 9 | +* zero or more data rows |
8 | 10 |
|
9 | | -| Country | Capital | |
10 | | -| ------- | --------------- | |
11 | | -| USA | Washington D.C. | |
12 | | -| Canada | Ottawa | |
| 11 | +## Notes |
13 | 12 |
|
14 | | -## `{table}` Directive |
| 13 | +* A leading and trailing pipe is recommended for clarity of reading |
| 14 | +* Spaces between pipes and cell content are trimmed |
| 15 | +* Block-level elements cannot be inserted in a table |
15 | 16 |
|
16 | | -You can use the `table` directive which gives you configuration captions such as caption and alignment. |
| 17 | +## GitHub Flavored Markdown (GFM) Table |
17 | 18 |
|
18 | | -```{table} Countries and their capitals |
19 | | -:widths: auto |
20 | | -:align: center |
| 19 | +You can use the GFM table syntax to create a table: |
21 | 20 |
|
| 21 | +``` |
22 | 22 | | Country | Capital | |
23 | 23 | | ------- | --------------- | |
24 | 24 | | USA | Washington D.C. | |
25 | 25 | | Canada | Ottawa | |
26 | 26 | ``` |
27 | 27 |
|
28 | | -## `{list-table}` Directive |
29 | | - |
30 | | -You can also use the `list-table` directive to create a table from data. |
31 | | - |
32 | | -```{list-table} Frozen Delights! |
33 | | -:widths: 15 10 30 |
34 | | -:header-rows: 1 |
35 | | -
|
36 | | -* - Treat |
37 | | - - Quantity |
38 | | - - Description |
39 | | -* - Albatross |
40 | | - - 2.99 |
41 | | - - On a stick! |
42 | | -* - Crunchy Frog |
43 | | - - 1.49 |
44 | | - - If we took the bones out, it wouldn't be |
45 | | - crunchy, now would it? |
46 | | -* - Gannet Ripple |
47 | | - - 1.99 |
48 | | - - On a stick! |
49 | | -``` |
| 28 | +| Country | Capital | |
| 29 | +| ------- | --------------- | |
| 30 | +| USA | Washington D.C. | |
| 31 | +| Canada | Ottawa | |
| 32 | + |
| 33 | +% Neither of these work |
| 34 | +% ## `{table}` Directive |
| 35 | +% |
| 36 | +% You can use the `table` directive which gives you configuration captions such as caption and alignment. |
| 37 | +% |
| 38 | +% ```{table} Countries and their capitals |
| 39 | +% :widths: auto |
| 40 | +% :align: right |
| 41 | +% |
| 42 | +% | Country | Capital | |
| 43 | +% | ------- | --------------- | |
| 44 | +% | USA | Washington D.C. | |
| 45 | +% | Canada | Ottawa | |
| 46 | +% ``` --> |
| 47 | +% |
| 48 | +% <!-- ## `{list-table}` Directive |
| 49 | +% |
| 50 | +% You can also use the `list-table` directive to create a table from data. |
| 51 | +% |
| 52 | +% ```{list-table} Frozen Delights! |
| 53 | +% :widths: 15 10 30 |
| 54 | +% :header-rows: 1 |
| 55 | +% |
| 56 | +% * - Treat |
| 57 | +% - Quantity |
| 58 | +% - Description |
| 59 | +% * - Albatross |
| 60 | +% - 2.99 |
| 61 | +% - On a stick! |
| 62 | +% * - Crunchy Frog |
| 63 | +% - 1.49 |
| 64 | +% - If we took the bones out, it wouldn't be |
| 65 | +% crunchy, now would it? |
| 66 | +% * - Gannet Ripple |
| 67 | +% - 1.99 |
| 68 | +% - On a stick! |
| 69 | +% ``` |
0 commit comments