TypstDocumentation

figureElement
Question mark

A figure with an optional caption.

Automatically detects its contents to select the correct counting track. For example, figures containing images will be numbered separately from figures containing tables.

Examples

The example below shows a basic figure with an image:

@glacier shows a glacier. Glaciers
are complex systems.

#figure(
  image("glacier.jpg", width: 80%),
  caption: [A curious figure.],
) <glacier>
Preview

You can also insert tables into figures to give them a caption. The figure will detect this and automatically use a separate counter.

#figure(
  table(
    columns: 4,
    [t], [1], [2], [3],
    [y], [0.3s], [0.4s], [0.8s],
  ),
  caption: [Timing results],
)
Preview

This behaviour can be overridden by explicitly specifying the figure's kind. All figures of the same kind share a common counter.

Modifying the appearance

You can completely customize the look of your figures with a show rule. In the example below, we show the figure's caption above its body and display its supplement and counter after the caption.

#show figure: it => align(center)[
  #it.caption |
  #emph[
    #it.supplement
    #it.counter.display(it.numbering)
  ]
  #v(10pt, weak: true)
  #it.body
]

#figure(
  image("molecular.jpg", width: 80%),
  caption: [
    The molecular testing pipeline.
  ],
)
Preview

If your figure is too large and its contents are breakable across pages (e.g. if it contains a large table), then you can make the figure breakable across pages as well by using #show figure: set block(breakable: true) (see the block documentation for more information).

Parameters
Question mark

body
content
RequiredPositional
Question mark

The content of the figure. Often, an image.

caption
none or content
Settable
Question mark

The figure's caption.

Default: none

kind
auto or string or function
Settable
Question mark

The kind of the figure this is.

If set to auto, the figure will try to automatically determine its kind. All figures of the same kind share a common counter.

Setting this to something other than auto will override the automatic detection. This can be useful if

You can set the kind to be an element function or a string. If you set it to an element function that is not supported by the figure, you will need to manually specify the figure's supplement.

Default: auto

#figure(
  circle(radius: 10pt),
  caption: [A curious atom.],
  kind: "atom",
  supplement: [Atom],
)
Preview

supplement
auto or content or function
Settable
Question mark

The figure's supplement.

If set to auto, the figure will try to automatically determine the correct supplement based on the kind and the active text language. If you are using a custom figure type, you will need to manually specify the supplement.

This can also be set to a function that receives the figure's body to select the supplement based on the figure's contents.

Default: auto

#figure(
  [The contents of my figure!],
  caption: [My custom figure],
  supplement: [Bar],
  kind: "foo",
)
Preview

numbering
none or string or function
Settable
Question mark

How to number the figure. Accepts a numbering pattern or function.

Default: "1"

gap
length
Settable
Question mark

The vertical gap between the body and caption.

Default: 0.65em

outlined
boolean
Settable
Question mark

Whether the figure should appear in an outline of figures.

Default: true