Figures
Quarto provides comprehensive support for figures including sizing, layout, subfigures, and accessibility features.
Basic Figure Syntax
Markdown Images

With Attributes
{width=50%}
Cross-Referenceable Figure
{#fig-example}
See @fig-example.
Figure Attributes
Common attributes for images:
| Attribute | Description | Example |
|---|---|---|
width |
Image width | width=50%, width=4in |
height |
Image height | height=3in |
fig-align |
Alignment | fig-align="center" |
fig-alt |
Alt text | fig-alt="Description" |
Sizing
Multiple units supported:
{width=50%}
{width=400px}
{width=4in}
{width=10cm}
Alignment
{fig-align="left"}
{fig-align="center"}
{fig-align="right"}
Alt Text for Accessibility
{fig-alt="Detailed description for screen readers"}
Alt text differs from caption - it describes the image content for accessibility.
Computational Figures
Figures generated from code use hashpipe options:
```{r}
#| label: fig-scatter
#| fig-cap: "Scatter plot showing the relationship."
#| fig-alt: "Scatter plot with positive trend."
#| fig-width: 8
#| fig-height: 6
#| fig-align: center
plot(x, y)
```
Python Example
```{python}
#| label: fig-histogram
#| fig-cap: "Distribution of values."
#| fig-width: 10
#| fig-height: 6
import matplotlib.pyplot as plt
plt.hist(data, bins=30)
plt.show()
```
Figure Options
| Option | Description | Example |
|---|---|---|
fig-cap |
Caption | "Figure caption." |
fig-subcap |
Subcaptions | ["A", "B"] |
fig-alt |
Alt text | "Description." |
fig-width |
Width in inches | 8 |
fig-height |
Height in inches | 6 |
fig-align |
Alignment | "center" |
fig-cap-location |
Caption position | "bottom", "top", "margin" |
fig-format |
Output format | "png", "svg", "pdf" |
fig-dpi |
Resolution | 300 |
Subfigures
Group multiple images with a shared caption:
::: {#fig-comparison layout-ncol=2}
{#fig-first}
{#fig-second}
Comparison of two approaches.
:::
See @fig-comparison, particularly @fig-first.
From Code
```{r}
#| label: fig-panels
#| fig-cap: "Panel figure."
#| fig-subcap:
#| - "Distribution of X"
#| - "Distribution of Y"
#| layout-ncol: 2
hist(x)
hist(y)
```
Figure Layouts
For arranging multiple figures, use layout divs. See layout.md for full layout options.
Basic Layout
::: {layout-ncol=2}


:::
Layout Attributes
| Attribute | Description | Example |
|---|---|---|
layout-ncol |
Number of columns | layout-ncol=2 |
layout-nrow |
Number of rows | layout-nrow=2 |
layout |
Custom layout array | layout="[[1,1]]" |
layout-valign |
Vertical alignment | layout-valign=top |
Figure Panels
For images without individual captions:
::: {#fig-panel layout-ncol=2}


Multiple plots in a panel.
:::
Caption Location
Document Level
fig-cap-location: top
Per Figure
```{r}
#| label: fig-example
#| fig-cap: "Caption on top."
#| fig-cap-location: top
plot(1:10)
```
Options: top, bottom, margin.
Lightbox
Enable click-to-zoom for images (HTML only):
{.lightbox}
Or for a group:
::: {.lightbox}


:::
Lightbox Options
{.lightbox group="gallery" description="Detailed view"}
Enable Globally
lightbox: true
Or with options:
lightbox:
match: auto
effect: zoom
loop: true
Linked Images
Make images clickable:
[](fullsize.png)
Or link to URL:
[](https://example.com)
Figure Divs
For complex figure content:
::: {#fig-custom}
<iframe src="interactive.html"></iframe>
Custom interactive figure.
:::
Document Defaults
Set figure defaults in YAML:
format:
html:
fig-width: 8
fig-height: 6
fig-format: svg
fig-dpi: 300
fig-align: center