figure
ElementElement functions can be customized with set
and show
rules.
set
and show
rules.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>

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],
)

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.
],
)

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).
ParametersParameters are the inputs to a function. They are specified in parentheses after the function name.
body
The content of the figure. Often, an image.
caption
The figure's caption.
Default: none
kind
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 wish to create a custom figure type that is not an image, a table or code,
- you want to force the figure to use a specific counter regardless of its content.
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],
)

supplement
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",
)

numbering
How to number the figure. Accepts a numbering pattern or function.
Default: "1"
gap
SettableSettable parameters can be customized for all following uses of the function with a set
rule.
set
rule.The vertical gap between the body and caption.
Default: 0.65em
outlined
SettableSettable parameters can be customized for all following uses of the function with a set
rule.
set
rule.Whether the figure should appear in an outline
of figures.
Default: true