> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nemu.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Tables

> Render tables with rich inline cell content and precise column sizing

The `table` block renders rows, optional headers, optional column sizing, and an optional
style.

```ts theme={null}
{ type: "table", rows: TableRow[], headers?: TableRow, columns?: number | number[], style?: StyleProperties }
```

## Rows and cells

A row is an array of cells, and a cell is either a string or a `TableCell`.

```ts theme={null}
type TableCell = { text: InlineContent; align?: "left" | "center" | "right" };
type TableRow = Array<string | TableCell>;
```

A cell `text` accepts inline content, so bold, links, and inline formulas all work inside
cells. See [Inline content](/packages/pdf/doc/inline) for the full set of inline nodes.

```ts theme={null}
doc.page().content({
  type: "table",
  headers: ["Metric", "Q3", "Q4"],
  rows: [
    ["Revenue", "1.2M", { text: { type: "strong", text: "1.6M" }, align: "right" }],
    ["Margin", "18%", { text: "24%", align: "right" }],
  ],
});
```

## Column sizing

The `columns` field is optional and controls how column widths are computed.

<ParamField path="columns" type="number | number[]" optional>
  Omit it to size columns equally from the header or first row. Set it to a count for equal
  columns, or to an array of absolute widths in points where `0` means auto.
</ParamField>

<AccordionGroup>
  <Accordion title="Omitted">
    Columns are sized equally, derived from the header row or the first data row.
  </Accordion>

  <Accordion title="A number">
    A count produces that many equal width columns.

    ```ts theme={null}
    { type: "table", columns: 3, headers: ["A", "B", "C"], rows: [["1", "2", "3"]] }
    ```
  </Accordion>

  <Accordion title="An array of point widths">
    Each entry is an absolute width in points. A `0` entry is sized automatically from the
    remaining space.

    ```ts theme={null}
    { type: "table", columns: [180, 0, 100], rows: [["Name", "Description", "Total"]] }
    ```
  </Accordion>
</AccordionGroup>

<Warning>
  Array values are absolute widths in points, not fractional weights. `[2, 1, 1]` means
  2pt, 1pt, 1pt, not a 2:1:1 ratio.
</Warning>
