typst/typst · error · SourceDiagnostic
too many cells or lines were given
Error message
too many cells or lines were given
What it means
Raised during grid layout resolution: the total number of resolved cells plus explicitly positioned lines exceeds the grid capacity implied by the specified column-count and any fixed positions, so the grid cannot accommodate everything given.
Source
Thrown at crates/typst-library/src/layout/grid/resolve.rs:1073
// those (when the table child being processed is a single cell),
// 'local_auto_index' will simply be an alias for 'auto_index', which
// will be updated after that cell is placed, if it is an
// automatically-positioned cell.
let mut auto_index: usize = 0;
// We have to rebuild the grid to account for fixed cell positions.
//
// Create at least 'children.len()' positions, since there could be at
// least 'children.len()' cells (if no explicit lines were specified),
// even though some of them might be placed in fixed positions and thus
// cause the grid to expand.
//
// Additionally, make sure we allocate up to the next multiple of
// 'columns', since each row will have 'columns' cells, even if the
// last few cells weren't explicitly specified by the user.
let children = children.into_iter();
let Some(child_count) = children.len().checked_next_multiple_of(columns) else {
bail!(self.span, "too many cells or lines were given")
};
// Rows in this bitset are occupied by an existing header.
// This allows for efficiently checking whether a cell would collide
// with a header at a certain row. (For footers, it's easy as there is
// only one.)
//
// TODO(subfooters): how to add a footer here while avoiding
// unnecessary allocations?
let mut header_rows = SmallBitSet::new();
let mut resolved_cells: Vec<Option<Entry>> = Vec::with_capacity(child_count);
for child in children {
self.resolve_grid_child(
columns,
&mut pending_hlines,
&mut pending_vlines,
&mut header_rows,
&mut headers,View on GitHub (pinned to 35417aa769)
Solutions
- Increase the number of `columns` in the grid
- Remove some cells or explicit hlines/vlines
- Check that fixed cell positions (x/y) do not overflow the grid dimensions
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/typst-library/src/layout/grid/resolve.rs:1073 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of typst/typst@35417aa769 (2026-08-17).
Data as JSON: /api/errors/0f94f5254df76320.
Report an issue: GitHub.