How do I prevent a graphic from leaving a big white space when it moves to the next page/column?

Here is a project where there are charts, tables, and boxes mixed. On the first section (“Valuations”), everything works fine, but when I get to “Performance Indices” section, the chart, which is too big, leaves a big white space, marked below with a circle.

Is it possible for the chart object in this case to move down to after the table that follows, automatically? But it shouldn’t break the table in half it should follow the end of the table, like this:

My code is linked here but I’m really looking for generic advice on this type of problem where a big “blocky” element must not leave whitespace but instead flow to the next column or page, and something which can be split across multiple columns or pages, can sort of take priority in those cases and be moved up.

I don’t think what you want is possible precisely with Typst’s built-in layout tools*. You can put your graph in a floating figure, but that will not place it before/after the next block (such as the table you have. If you put the table in a floating figure, it won’t be able to break across pages at all; if you let the graph float to the bottom, the “Notes” box may also precede it (partly).

I would probably go for a floating figure and accept that the table only continues after the graph. At least in scientific papers, that format would be acceptable. If you absolutely need the uninterrupted table, I think you’ll have to place these manually.

*In theory, we could try to come up with some layout() + measure() construct. The tricky part is this: the total space taken will differ between the two options (graph first, table first) due to the different amounts of whitespace. That means that one ordering decision can influence the next, and after a few figures you will probably get “Layout did not converge within 5 attempts”.

1 Like

Yes the floating figure is perfectly good enough (though it’s true it would be nice to have a little bit more control as described, but it’s not a dealbreaker, and especially if it’s well established in academia).