I was wondering if it was possible to delay a command, so it takes effect several pages later in the document. Specifically, I would like to place a figure several pages later than in appears in the source.
For example, in the following I would like the figure occur on the second or third page:
#figure(
placement:bottom,
[#square(fill: blue, size: 4cm)],
caption: [Somewhere in the middle.])
#lorem(3000) // A several page text document.
My goal is to control the position of the figure, without interspersing the document text and typst commands
If by “occur” you mean just visually, then do:
#let some-figure = figure(
placement: bottom,
square(fill: blue, size: 4cm),
caption: [Somewhere in the middle.],
)
#lorem(3000) // A several page text document.
#some-figure
But I think any granularity in “place on page n” is impossible. You can do out of document flow conditional placement with page.background. If it doesn’t naturally place into the exact place, then it’s probably never will, gotta place it manually.
Because of the lack of other good solutions, here is a dubious one. You can ask meander to make a layout like this: one or more full pages, then a page with a placed figure on the bottom. And the text flows through those pages.
#import "@preview/meander:0.4.2"
#meander.reflow({
import meander: *
container()
pagebreak()
placed(bottom, figure(rect(width: 100%, height: 8cm), caption: [Caption]))
container()
content[
#set par(justify: true)
#lorem(1500)
]
})
This text comes after that block.