How to place floating figures within paragraphs without breaking them?

I am writing a thesis with long paragraphs (>1 page especially if there is a figure on that page). Sometimes I reference a figure within this paragraph for the first time.
Now I am faced with the decision of where do I define the figure in the flow. If I do this before my paragraph starts, the figure is places to early, if I do this after the paragraph it is to late.

My ideal way would to define the figure just after my reference and typst then places it close to there.
The problem is that defining a figure always breaks my paragraph and I get one paragraph before and one afterwards, which is not what I want.

#set page("a5")
= Placed to early
#figure(square(), caption: [Hi], placement: auto)<fig:ref1>
#lorem(500)
*@fig:ref1*
#lorem(300)
#pagebreak()
= Placed ok but creates unwanted parbreak
#lorem(500)
*@fig:ref2*
#figure(square(), caption: [Hi], placement: auto)<fig:ref2>
#lorem(300)
#pagebreak()
= Placed to late
#lorem(500)
*@fig:ref3*
#lorem(300)
#figure(square(), caption: [Hi], placement: auto)<fig:ref3>

This might be somewhat related to Delay placement of a figure?.
So holding the placing of the figure back or combining the two paragraphs to one paragraph would be what I want, I just don’t get it running.

2 Likes

The problem is that as of now (august 2026, typst 0.15), Typst does not support floating figures in its core, not really (there’s place but it’s not really meant for this). You can use a package like meander to get this functionality (it may slow down your compilation a bit, test if this is acceptable for your use case).

Thanks for the answer, that surprises me. It seems to me like this is a core functionality, essential for scientific writing.
Is this planned any time soon?

I am also sitting with my thesis with the exact same issue. This is indeed essential for scientific writing.

I’m not sure you are referring to the same thing as we are asking about. I do not want to place the figure next to the text. I am looking to do exactly what placement: auto does on the #figure except that I can choose a reference point to inform the placement to be within a long paragraph, without breaking said paragraph. Currently I have to put the definition of the figure either before the paragraph or after it; the former puts it too early and the latter puts it too late. I want the same effect as defining the figure in the middle of a paragraph but without breaking the paragraph.

1 Like

This appears to be an open issue:

1 Like