Tables

Details

rst2typst supports all types of tabple syntax, but it only accepts some attributes.

Examples

Grid table

+------------------------+------------+----------+----------+
| Header row, column 1   | Header 2   | Header 3 | Header 4 |
| (header rows optional) |            |          |          |
+========================+============+==========+==========+
| body row 1, column 1   | column 2   | column 3 | column 4 |
+------------------------+------------+----------+----------+
| body row 2             | Cells may span columns.          |
+------------------------+------------+---------------------+
| body row 3             | Cells may  | - Table cells       |
+------------------------+ span rows. | - contain           |
| body row 4             |            | - body elements.    |
+------------------------+------------+---------------------+
#table(
  columns: 4,
  table.header(
    [Header row, column 1
    (header rows optional)],
    [Header 2],
    [Header 3],
    [Header 4],
  ),
  [body row 1, column 1],
  [column 2],
  [column 3],
  [column 4],
  [body row 2],
  table.cell(colspan: 3,)[Cells may span columns.],
  [body row 3],
  table.cell(rowspan: 2,)[Cells may
  span rows.],
  table.cell(rowspan: 2,colspan: 2,)[  - Table cells
  - contain
  - body elements.
],
  [body row 4],
)

Simple table

=====  =====  =======
  A      B    A and B
=====  =====  =======
False  False  False
True   False  False
False  True   False
True   True   True
=====  =====  =======
#table(
  columns: 3,
  table.header(
    [A],
    [B],
    [A and B],
  ),
  [False],
  [False],
  [False],
  [True],
  [False],
  [False],
  [False],
  [True],
  [False],
  [True],
  [True],
  [True],
)

CSV table

.. csv-table:: Frozen Delights!
   :header: "Treat", "Quantity", "Description"
   :widths: 15, 10, 30

   "Albatross", 2.99, "On a stick!"
   "Crunchy Frog", 1.49, "If we took the bones out,
   it wouldn't be crunchy, now would it?"
   "Gannet Ripple", 1.99, "On a stick!"
#figure([
  #table(
    columns: (15fr, 10fr, 30fr),
    table.header(
      [Treat],
      [Quantity],
      [Description],
    ),
    [Albatross],
    [2.99],
    [On a stick!],
    [Crunchy Frog],
    [1.49],
    [If we took the bones out,
    it wouldn't be crunchy, now would it?],
    [Gannet Ripple],
    [1.99],
    [On a stick!],
  )],
  caption: [Frozen Delights!],
)

List table

.. list-table:: Frozen Delights!
   :widths: 15 10 30
   :header-rows: 1

   * - Treat
     - Quantity
     - Description
   * - Albatross
     - 2.99
     - On a stick!
   * - Crunchy Frog
     - 1.49
     - If we took the bones out, it wouldn't be
       crunchy, now would it?
   * - Gannet Ripple
     - 1.99
     - On a stick!
#figure([
  #table(
    columns: (15fr, 10fr, 30fr),
    table.header(
      [Treat],
      [Quantity],
      [Description],
    ),
    [Albatross],
    [2.99],
    [On a stick!],
    [Crunchy Frog],
    [1.49],
    [If we took the bones out, it wouldn't be
    crunchy, now would it?],
    [Gannet Ripple],
    [1.99],
    [On a stick!],
  )],
  caption: [Frozen Delights!],
)

List table with autolayout

.. list-table:: Frozen Delights!
   :header-rows: 1

   * - Treat
     - Quantity
     - Description
   * - Albatross
     - 2.99
     - On a stick!
   * - Crunchy Frog
     - 1.49
     - If we took the bones out, it wouldn't be
       crunchy, now would it?
   * - Gannet Ripple
     - 1.99
     - On a stick!
#figure([
  #table(
    columns: 3,
    table.header(
      [Treat],
      [Quantity],
      [Description],
    ),
    [Albatross],
    [2.99],
    [On a stick!],
    [Crunchy Frog],
    [1.49],
    [If we took the bones out, it wouldn't be
    crunchy, now would it?],
    [Gannet Ripple],
    [1.99],
    [On a stick!],
  )],
  caption: [Frozen Delights!],
)

CSV table with autolayout

.. csv-table:: Frozen Delights!
   :header: "Treat", "Quantity", "Description"

   "Albatross", 2.99, "On a stick!"
   "Crunchy Frog", 1.49, "If we took the bones out,
   it wouldn't be crunchy, now would it?"
   "Gannet Ripple", 1.99, "On a stick!"
#figure([
  #table(
    columns: 3,
    table.header(
      [Treat],
      [Quantity],
      [Description],
    ),
    [Albatross],
    [2.99],
    [On a stick!],
    [Crunchy Frog],
    [1.49],
    [If we took the bones out,
    it wouldn't be crunchy, now would it?],
    [Gannet Ripple],
    [1.99],
    [On a stick!],
  )],
  caption: [Frozen Delights!],
)

CSV table with “auto” keyword

.. csv-table:: Frozen Delights!
   :header: "Treat", "Quantity", "Description"
   :widths: auto

   "Albatross", 2.99, "On a stick!"
   "Crunchy Frog", 1.49, "If we took the bones out,
   it wouldn't be crunchy, now would it?"
   "Gannet Ripple", 1.99, "On a stick!"
#figure([
  #table(
    columns: 3,
    table.header(
      [Treat],
      [Quantity],
      [Description],
    ),
    [Albatross],
    [2.99],
    [On a stick!],
    [Crunchy Frog],
    [1.49],
    [If we took the bones out,
    it wouldn't be crunchy, now would it?],
    [Gannet Ripple],
    [1.99],
    [On a stick!],
  )],
  caption: [Frozen Delights!],
)

List table with “auto” keyword

.. list-table:: Frozen Delights!
   :widths: auto
   :header-rows: 1

   * - Treat
     - Quantity
     - Description
   * - Albatross
     - 2.99
     - On a stick!
   * - Crunchy Frog
     - 1.49
     - If we took the bones out, it wouldn't be
       crunchy, now would it?
   * - Gannet Ripple
     - 1.99
     - On a stick!
#figure([
  #table(
    columns: 3,
    table.header(
      [Treat],
      [Quantity],
      [Description],
    ),
    [Albatross],
    [2.99],
    [On a stick!],
    [Crunchy Frog],
    [1.49],
    [If we took the bones out, it wouldn't be
    crunchy, now would it?],
    [Gannet Ripple],
    [1.99],
    [On a stick!],
  )],
  caption: [Frozen Delights!],
)

Simple table with explicit widths

.. table:: Truth table with explicit widths
   :widths: 10 10 15

   =====  =====  =======
     A      B    A and B
   =====  =====  =======
   False  False  False
   True   False  False
   False  True   False
   True   True   True
   =====  =====  =======
#figure([
  #table(
    columns: (10fr, 10fr, 15fr),
    table.header(
      [A],
      [B],
      [A and B],
    ),
    [False],
    [False],
    [False],
    [True],
    [False],
    [False],
    [False],
    [True],
    [False],
    [True],
    [True],
    [True],
  )],
  caption: [Truth table with explicit widths],
)

Grid table with “grid” widths keyword

.. table:: Truth table with grid-derived widths
   :widths: grid

   +-------+-------+-----------+
   |   A   |   B   |  A and B  |
   +=======+=======+===========+
   | False | False | False     |
   +-------+-------+-----------+
   | True  | False | False     |
   +-------+-------+-----------+
   | False | True  | False     |
   +-------+-------+-----------+
   | True  | True  | True      |
   +-------+-------+-----------+
#figure([
  #table(
    columns: (7fr, 7fr, 11fr),
    table.header(
      [A],
      [B],
      [A and B],
    ),
    [False],
    [False],
    [False],
    [True],
    [False],
    [False],
    [False],
    [True],
    [False],
    [True],
    [True],
    [True],
  )],
  caption: [Truth table with grid-derived widths],
)

References

Docutils:

Typst: