TypstDocumentation

matElement
Question mark

A matrix.

The elements of a row should be separated by commas, while the rows themselves should be separated by semicolons. The semicolon syntax merges preceding arguments separated by commas into an array. You can also use this special syntax of math function calls to define custom functions that take 2D data.

Content in cells that are in the same row can be aligned with the & symbol.

Example

$ mat(
  1, 2, ..., 10;
  2, 2, ..., 10;
  dots.v, dots.v, dots.down, dots.v;
  10, 10, ..., 10;
) $
Preview

Parameters
Question mark

delim
none or str
Settable
Question mark

The delimiter to use.

VariantDetails
"("

Delimit with parentheses.

"["

Delimit with brackets.

"{"

Delimit with curly braces.

"|"

Delimit with vertical bars.

"||"

Delimit with double vertical bars.

Default: "("

View example
#set math.mat(delim: "[")
$ mat(1, 2; 3, 4) $
Preview

augment
none or int or dictionary
Settable
Question mark

Draws augmentation lines in a matrix.

Default: none

View example
$ mat(1, 0, 1; 0, 1, 2; augment: #2) $
// Equivalent to:
$ mat(1, 0, 1; 0, 1, 2; augment: #(-1)) $
Preview
$ mat(0, 0, 0; 1, 1, 1; augment: #(hline: 1, stroke: 2pt + green)) $
Preview

gap
relative
Settable
Question mark

The gap between rows and columns.

Default: 0pt

View example
#set math.mat(gap: 1em)
$ mat(1, 2; 3, 4) $
Preview

row-gap
relative
Settable
Question mark

The gap between rows. Takes precedence over gap.

Default: 0.5em

View example
#set math.mat(row-gap: 1em)
$ mat(1, 2; 3, 4) $
Preview

column-gap
relative
Settable
Question mark

The gap between columns. Takes precedence over gap.

Default: 0.5em

View example
#set math.mat(column-gap: 1em)
$ mat(1, 2; 3, 4) $
Preview

rows
array
RequiredPositional
Question mark
Variadic
Question mark

An array of arrays with the rows of the matrix.

View example
#let data = ((1, 2, 3), (4, 5, 6))
#let matrix = math.mat(..data)
$ v := matrix $
Preview