Labels : automatically numbered identifiers like " Figure 1 ", " Figure 2 ", etc. Captions : descriptive text rendered below the figure. Multi-panel layouts : arrange subfigures in grids with a concise layout mini-language. Overlays : transparent SVG annotation layers for arrows, callouts, bounding boxes, and labels.
Syntax
figure
::: figure <label> #<id> [<layout>] {pad="<padding>"}

The figure caption.
:::
Labels
figure
IDs and cross-referencing
idfig-fig-1fig-1a#
See [Figure 1](#fig-1) for an overview.
Subfigure [Figure 4a](#fig-4a) shows the red panel, while [Figure 4c](#fig-4c) shows the blue panel.fig-1#<id>
::: figure #specimen-1

Photograph of the first specimen.
:::
#specimen-1
Captions
::: figure
A paragraph containing only an image (or audio, or video) becomes content . Any other paragraph becomes caption .
::: figure
A blue placeholder image.

:::

Figure 1:
::: figure

This is the first paragraph of the caption.
This is a second paragraph providing additional detail about the figure.
:::

Figure 2:
Executable figures
::: figure
```plotly exec
{
"data": [
{
"type": "bar",
"x": ["A", "B", "C", "D", "E"],
"y": [4, 7, 2, 9, 5]
}
],
"layout": {
"xaxis": {"title": {"text": "Category"}},
"yaxis": {"title": {"text": "Value"}}
}
}
```
A plot of value by category.
:::
Figure 3:
Subfigures
::: figure
::: figure

A purple panel.
:::
::: figure

A blue panel.
:::
A figure with two subfigures stacked vertically.
:::


Figure 4:
Grid layouts
figure
::: figure [<layout>]
:::
[row] | ||
[2] | ||
[3] | ||
[30 70] | ||
[40 g20 40] | ||
[a b | a c] | a | |
[30 70 : a b | a c] | ||
[a . | b c] | . |
Single row
row
::: figure [row]
::: figure

Purple.
:::
::: figure

Teal.
:::
::: figure

Blue.
:::
Three panels in a single row.
:::



Figure 5:
Column count
::: figure [2]
::: figure

Purple.
:::
::: figure

Teal.
:::
::: figure

Blue.
:::
::: figure

Orange.
:::
Four panels in a two-column grid.
:::




Figure 6:
Column widths
30 70
::: figure [30 70]
::: figure

Narrow left panel.
:::
::: figure

Wide right panel.
:::
Unequal two-column layout with a 30:70 width ratio.
:::


Figure 7:
Column gaps
gN40 g20 40
::: figure [40 g20 40]
::: figure

Left.
:::
::: figure

Right.
:::
Two columns with an explicit gap.
:::


Figure 8:
Layout maps
ab|
a b | |
a b | a c | abc |
a a | b c | abc |
a . | b c |
Spanning rows
::: figure [a b | a c]
::: figure

Spans both rows.
:::
::: figure

Top right.
:::
::: figure

Bottom right.
:::
One tall panel on the left with two stacked panels on the right.
:::



Figure 9:
Spanning columns
::: figure [a a | b c]
::: figure

Spans both columns.
:::
::: figure

Bottom left.
:::
::: figure

Bottom right.
:::
A wide panel on top with two panels below.
:::



Figure 10:
Empty cells
.
::: figure [a . | b c]
::: figure

Top left.
:::
::: figure

Bottom left.
:::
::: figure

Bottom right.
:::
Top-right cell left intentionally empty.
:::



Figure 11:
Combining column widths with layout maps
:
::: figure [30 70 : a b | a c]
::: figure

Narrow left, spans both rows.
:::
::: figure

Wide right, top.
:::
::: figure

Wide right, bottom.
:::
A 30:70 split with the left panel spanning both rows.
:::



Figure 12:
Mixed image sizes
::: figure [2]
::: figure

Wide (2 : 1).
:::
::: figure

Tall (5 : 4).
:::
::: figure

Medium (8 : 5).
:::
::: figure

Wide (2 : 1).
:::
Subfigures with different aspect ratios — each image keeps its proportions and centers vertically.
:::




Figure 13:
Overlays
viewBox
::: figuresvg overlay<svg>viewBoxviewBox0 0 1000 1000
--figure-overlay-*
<s:callout><s:arrow><s:scale-bar><s:roi-rect>
Simple figure overlay
viewBox="0 0 600 300"viewBox
::: figure

```svg overlay
<svg viewBox="0 0 600 300" xmlns:s="https://stencila.io/svg">
<s:halo cx="300" cy="150" r="20" width="10"/>
<s:callout x="370" y="145" label="Center" to-x="300" to-y="150"/>
<s:roi-rect x="30" y="30" width="160" height="80" label="Region A" label-position="below" stroke-style="dashed"/>
<s:arrow x="450" y="50" to-x="550" to-y="250" label="Trend"/>
</svg>
```
A figure with several overlay annotations: a [`<s:halo>`](figure-overlay-components#halo) and [`<s:callout>`](figure-overlay-components#callout) highlighting the center, a dashed [`<s:roi-rect>`](figure-overlay-components#roi-rectangle) bounding box, and an [`<s:arrow>`](figure-overlay-components#straight-arrows) trend line.
:::

Figure 14: <s:halo><s:callout><s:roi-rect><s:arrow>
Executable figure overlays
viewBox
<s:callout>fill
::: figure
```r exec
hist(rnorm(1000), breaks=30, xlim=c(-4, 4), col='#b0d0e8', border='#7aaccc', xlab='Random normal variate', ylab='Frequency', main='')
```
```svg overlay
<svg viewBox="0 0 600 400" xmlns:s="https://stencila.io/svg">
<s:callout x="460" y="45" label="Peak near μ=0" to-x="335" to-y="100" curve="quad" fill="crimson"/>
<s:callout x="105" y="130" label="Thin left tail" to-x="185" to-y="240" curve="quad" fill="darkorange"/>
<s:callout x="410" y="190" label="Thin right tail" to-x="445" to-y="270" curve="quad" fill="seagreen"/>
</svg>
```
An R histogram annotated with overlay callouts — the kind of annotation that is easy with components but would require manual arrowhead definitions and path geometry in raw SVG.
:::
Figure 15:
widthheightviewBox
::: figure
```plotly exec
{
"data": [
{
"type": "scatter",
"mode": "lines",
"x": ["Jan", "Feb", "Mar", "Apr", "May"],
"y": [0, 1.5, 5.2, 8, 6]
}
],
"layout": {
"width": 600,
"height": 400,
"xaxis": {"title": {"text": "Month"}},
"yaxis": {"title": {"text": "Value"}}
}
}
```
```svg overlay
<svg viewBox="0 0 600 400" xmlns:s="https://stencila.io/svg">
<s:halo cx="422" cy="25" r="16"/>
<s:callout x="460" y="25" label="Peak"/>
<s:arrow x="170" y="240" to-x="238" to-y="165" stroke="green" stroke-width="3" label="Rising trend" label-position="below" fill="green"/>
</svg>
```
A Plotly chart with an overlay highlighting the peak with a [`<s:halo>`](figure-overlay-components#halo) and [`<s:callout>`](figure-overlay-components#callout), and an [`<s:arrow>`](figure-overlay-components#straight-arrows) indicating the rising trend.
:::
Figure 16: <s:halo><s:callout><s:arrow>
Note
Subfigures with individual overlays
<s:roi-rect><s:roi-ellipse>
::: figure [2]
::: figure

```svg overlay
<svg viewBox="0 0 400 250" xmlns:s="https://stencila.io/svg">
<s:roi-rect x="50" y="40" width="140" height="90" label="Feature α" label-position="below"/>
</svg>
```
Purple panel.
:::
::: figure

```svg overlay
<svg viewBox="0 0 400 250" xmlns:s="https://stencila.io/svg">
<s:roi-ellipse cx="280" cy="130" rx="80" ry="50" label="Feature β" label-position="below"/>
</svg>
```
Teal panel.
:::
Two subfigures, each with its own overlay annotation.
:::


Figure 17:
Parent overlay connecting subfigures
<s:arrow><s:halo><s:callout><s:roi-rect>viewBox
::: figure [2]
::: figure

```svg overlay
<svg viewBox="0 0 400 250" xmlns:s="https://stencila.io/svg">
<s:halo cx="200" cy="125" r="40"/>
<s:callout x="180" y="210" label="Source"/>
</svg>
```
Left panel with source.
:::
::: figure

```svg overlay
<svg viewBox="0 0 400 250" xmlns:s="https://stencila.io/svg">
<s:roi-rect x="120" y="70" width="100" height="100" label="Target" label-position="below"/>
</svg>
```
Right panel with target.
:::
```svg overlay
<svg viewBox="0 0 800 250" xmlns:s="https://stencila.io/svg">
<s:arrow x="350" y="150" to-x="500" to-y="150" label="Leads to" label-position="above"/>
</svg>
```
Subfigures with individual annotations plus a parent overlay arrow connecting them.
:::


Figure 18:
Padding
pad
::: figure {pad=50}
::: figure {pad="30 60"}
::: figure [2] {pad="10 20 30 40"}
50means 50px on all sides. 30 60means 30px top and bottom, 60px left and right. 10 20 30 40means top, right, bottom, left.
How padding affects overlay coordinates
pad="T R B L"viewBox"0 0 (W+L+R) (H+T+B)"
{pad="0 0 56 0"}viewBox="0 0 600 356"{pad="50 20 56 20"}viewBox="0 0 640 406"x="100" y="80"x="120" y="130"
Padding for a single figure overlay
<s:scale-bar>
::: figure {pad="0 0 56 0"}

```svg overlay
<svg viewBox="0 0 600 356" xmlns:s="https://stencila.io/svg">
<s:scale-bar x="40" y="326" length="130" label="20 μm"/>
</svg>
```
A figure with bottom padding that leaves room for a scale bar beneath the image.
:::

Figure 19:
Padding on a parent figure
<s:callout>
::: figure [2] {pad="0 0 56 0"}
::: figure

Purple panel.
:::
::: figure

Blue panel.
:::
```svg overlay
<svg viewBox="0 0 824 306" xmlns:s="https://stencila.io/svg">
<s:callout x="370" y="290" label="Points of interest" to-x="220" to-y="210"/>
<s:callout x="370" y="290" label="" to-x="610" to-y="90"/>
</svg>
```
A two-panel figure with parent padding that leaves room for a note below the grid.
:::


Figure 20: