The tall box gets pushed to a third page. I guess on the first iteration the float is not found so the tall box is sized too high, then the float is placed and the tall box is pushed to the next page. How can I avoid that?
Weirdly it seems to work if I put the #floating line last:
When compiling it with 2024-09-09 version, it gives a warning about not being able to converge in 5 tries.
I think it is because floating figures will be inserted last, after everything else is typeset, and it is clear where it is better to put it. But tall-box depends on the floating position, and it should be placed first. So there is some time-related conflict.
I don’t really know how adding float last fixes this, but it somehow does. Either there is some hidden behavior that I don’t know, or it’s some sort of bug.
The solution is very clever, and I personally don’t know how to change it.
I assume that this is because it places some other stuff at the top too?
Thanks, I just tried with the current main and don’t see any convergence issue so something must have changed recently.
Regarding what you say about floats being inserted last: at first I thought that cannot be it because here with place(top, float: true, ...) the float position is already given. But maybe the implementation is shared with other types of floats that don’t have fix position, so indeed that could explain it.
That can happen, though the typical use for this floating function would be a show rule for some headings, and the red and green boxes correspond to content that the user adds later in the document.
Edit: thinking more about it, another reason why the float insertion could be delayed is because typst might decide to insert first another float (this one without fixed alignment.
Haha I reported that linked issue :) Indeed now that this awesome PR fixed it I can use block(height: 1fr, ...) which covers the main use case.
It’s not a complete fix since I also have the red box on the left, so I must get the user to put red and green together in a block(height: 1fr). It’s also a bit less flexible than what I had in mind: I thought tall-box could have a parameter to make the height only 90% or 50% or whatever, but height: 1fr will always take the full height.
Yeah exactly… Also I’d like to be able to reserve some space on the page for other things above or below, e.g. having a tall-box height of 100% - 2cm. I can convert that to the correct height if I know the height of the floating element (though it doesn’t work as discussed above because the floating element is found too late). With a ...fr height I cannot reserve space.
Yes that works! I got to the same solution :) The downside is that I must ask the user to add this block(height: 1fr, it) wrapper themselves. I was hoping I could get floating and tall-box to just work. For now I’ll add the block wrapper method to the documentation.