How to prevent figure appearing outside of its section?

Hello
I have figures that are appearing ahead of the section that they were placed in. How do I prevent figures from moving ahead of their sections?
I am using the following to prevent them from appearing in later section:

#place.flush()

Thanks

Hi @Ryan, if you are placing figures as floating, then you cannot prevent them from being placed at the top of the page, sometimes ahead of the section heading.

Without knowing more about your exact layout (it would help if you could share a reproducing example), I would say that you can try either:

  • not have floating figures in the first place
  • place them at the bottom with a place.flush() before the next section

See place(float):

Floating elements are positioned at the top or bottom of the parent container, displacing in-flow content. They are always placed in the in-flow order relative to each other, as well as before any content following a later place.flush element.

1 Like

Thanks for the help. I am still trying to figure out typst…
How do I make it default that figures do not float? I would like them to stay where I put them.

Hello @Ryan, have you tried setting the figure.placement parameter to none?

See Figure Function – Typst Documentation

Figure behaviour

By default, figures are placed within the flow of content. To make them float to the top or bottom of the page, you can use the placement argument.

#figure(
  placement: none,
  …
)

No, I did not know about this. I read the documentation but I am getting started so much of the docs are a bit unclear to me.
I guess I can use #set to make the default placement always none.

Placing this in the preamble did the trick:

#set figure(placement: none)
3 Likes

I’m glad you found a solution @Ryan! By default the figure’s placement should be none. You might have something changing it somewhere!

1 Like