How to make sure heading and the first following content stay on the same page?

In fact, I search a way for make that heading can’t stay alone in bottom of a page. I already know the way with

box([ = MyTiTle
mytext here
])

but I search an automated way
For example :

The issue with lone heading at the bottom of the page is fixed in the next release (due “soon”). In the meantime one workaround that @PgBiel suggested is something like this:

// Make a heading reserving some space below to avoid
// a page break between heading and content
#let custom-heading(it, reserve: 6em) = {
  block(breakable: false, it + v(reserve))
  v(-1 * reserve)
}

which you could use with #show heading: custom-heading.

(I couldn’t test the above since for some reason I cannot get a small example to reproduce the problem :thinking:)

thanks for your help!
it work well

1 Like

Related issue: Keep with the next paragraph · Issue #993 · typst/typst · GitHub.
Related PR that fixed this issue: New flow layout, with multi-column floats by laurmaedje · Pull Request #5017 · typst/typst · GitHub.
Link to the original solution: Typst - Try to keep two things in the same page · GitHub.