Is there a YAML option that I can set to cause every figure to appear in the margin of a Quarto document?
I know I can put individual figures in the margin by using a fenced div like:
::: {.column-margin}
![Plots of Ansocombe's quartet](images/c01/fig-01-01.jpg){#fig-01-01}
:::
but I don't want to do this for dozens of images throughout a book if I can avoid it.
As far as I can tell, there is no documentation suggesting that there is a YAML option for what you are trying to do. However, I have come up with a solution that appears to be working to accomplish your goal. I haven't tested this outside of HTML yet, so your mileage may vary.
First, you'll need the following YAML frontmatter in your QMD file:
---
format: html
filters:
- at: pre-quarto
path: image_filter.lua
---
Then in image_filter.lua:
function Plain(el)
if el.content[1].t == "Image" then
path = el.content[1].src
image = pandoc.Image("", path, "", pandoc.Attr("", { "column-margin" }))
plain = pandoc.Plain(image)
return pandoc.Div(plain, pandoc.Attr("", { "column-margin" }))
else
return el
end
end
Then we can test with a full QMD file:
---
format: html
filters:
- at: pre-quarto
path: image_filter.lua
---
This is some text to test placement
![Quarto logo](./quarto_logo.jpg){#fig-quarto}
Going to test cross-reference too
@fig-quarto
Gives us: