You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many word processors have options for paragraphs like "keep with the next" or "keep lines together". The first, for example, ensures that no page break happens between the two paragraphs. Most often it's used with headings to prevent the pagebreak between a header and a text. Compare these two examples of google docs with the option disabled and enabled:
It would be cool to have these options as a part of par element, or maybe find a way to make them implementable in a general way.
Use Case
The "keep-with-the-next" options is often used with headings if tldr. But Matthew Butterick described the benefits of these options better than me:
Reacted by avrong, Edgar Onghena, gsurrel, Matthew Brown, Ghost4Man, Lucas Parzianello, Daniel Houck, Mikhail Akimov, Andrew Voynov, sciwhiz12 and 36 more
I've been thinking about this too. I would love to see some sort of "same paragraph" detection to glue things like equations to text. For example of I don't have a blank like between my text and the $, I would like them to be rendered together.
When you put content into a block after some heading, it also breaks directly after the heading. I would really like to have some option to prevent breaking at specific locations. I mean, it can break inside the box, if needed.
Example:
#lorem(630) // Change value to break after header
= Header
#block()[
Some content inside block. #lorem(100)
]
I was shocked when I was looking for this and found an open issue instead of documentation. Typst bills itself as a powerful page-oriented markup language, with comparison to Microsoft Word and Latex on the front page; controlling page breaks is essential for such a language.
Reacted by Matt Joiner, Neruthes 0x5200DF38, Eduardo Villegas, Ash-L2L, Suyash Mahar, Federico Guglielmi, NilsNachname, Mashir0, Jochern, Léana and 2 more
Reacted by Jonathan, Marco Thomas, johannesrave, mumblingdrunkard, Henry Wilkinson, Mikhail Kravets, Florian Neumann, Eîar Abramski-Kronenberg, David Armstrong, gnovikov and 8 more
I was shocked when I was looking for this and found an open issue instead of documentation. Typst bills itself as a powerful page-oriented markup language, with comparison to Microsoft Word and Latex on the front page; controlling page breaks is essential for such a language.
Typst is still in beta, and revamp of layout is on the roadmap. I'm not sure why you're surprised that there are still certain aspects that aren't as mature as programs that have been around for 40 years.
Reacted by Pol Dellaiera, Laurenz Stampfl, Andrew Voynov, T. Emil Rivera-Thorsen, Matt Joiner, Spencer Elkington, Rolf Bremer, Marco Thomas, Henry Wilkinson, Bastien Voirin and 13 more
Yeah, that’s fair. I consider this, along with widow/orphan control, a more basic feature than some stuff that already exists, but that doesn’t mean it should have been implemented first.
Absolutely 100% behind having this as a feature, it would solve so many problems. However, I will note that I had the exact same issue when working in LaTeX pretty often, and the solution was either really arcane or non-existent in some circumstances, so I don't think this is an area where Typst particularly falls behind in that respect.
Reacted by Nazar Serhiichuk, avrong, Ming-Long Huang, Bastien Voirin and Runge
For people looking for a workaround, I've cooked something which might be helpful.
Basically consists of keeping the first element - and the spacing between both elements - unbreakable across pages, but not the second. Thus, it should work for the use case of (unbreakable) heading + (breakable) paragraph.
I'm also using blocks after headings and don't want them to break apart. This appears to be intended behaviour, but would be nice if it was configurable.
I'm also using blocks after headings and don't want them to break apart. This appears to be intended behaviour, but would be nice if it was configurable.
If you're referring to having an isolated heading at the bottom of a page, that's a bug, as mentioned above.
Ran across this issue today. Wanted to highlight my use case of Markdown → Typst conversion & styling.
Also probably worth pointing out that this is fairly easy to solve on an individual document basis with manual page breaks, but would definitely be a welcome addition for improving automated workflows! :)
My autobreak function fails when there are too many occurrences.. I would be grateful for ideas or suggestions in #4530 (adjusting #993 (comment) takes me further, but the underlying issue is still here)
// Add enough padding to force the next heading & paragraph to start at the// bottom of the page.#lorem(650)
// No issue here: the heading & paragraph stay together and move to the next// page, since there is not enough space on this page for both of them.= Test
This is the second paragraph.
#pagebreak()
// Add enough padding to force the next heading and paragraph to start at the// bottom of the page.#lorem(650)
// Problem: even though there is not enough space for both the heading and the// paragraph, instead of being moved to the next page, they get split and the// header stays on this page.#block[
= Test
This is the second paragraph.
]
Compiled with:
$ typst --versiontypst 0.12.0 (7add9b45)
$ typst c main.typ
Can confirm. My initial thought (which can be true) was that this is because by default block(breakable: true), but the heading should stick to the text below regardless. Maybe the breakable overrides the heading stickiness. Or maybe it's simply a new/untested edge case.
Activity
SUPERCILEX commentedon Apr 26, 2023
I've been thinking about this too. I would love to see some sort of "same paragraph" detection to glue things like equations to text. For example of I don't have a blank like between my text and the $, I would like them to be rendered together.
LaurenzV commentedon Apr 26, 2023
You might already be aware of this, but as a workaround, you can do it manually by writing something like this:
But obviously it's not ideal if you have to do this manually for every heading.
laurmaedje commentedon May 8, 2023
This specific case with the heading is a bug and should work (#1044), but a general option might be nice.
Beiri22 commentedon Jul 13, 2023
When you put content into a block after some heading, it also breaks directly after the heading. I would really like to have some option to prevent breaking at specific locations. I mean, it can break inside the box, if needed.
Example:
dhouck commentedon Nov 23, 2023
I was shocked when I was looking for this and found an open issue instead of documentation. Typst bills itself as a powerful page-oriented markup language, with comparison to Microsoft Word and Latex on the front page; controlling page breaks is essential for such a language.
Enivex commentedon Nov 23, 2023
Typst is still in beta, and revamp of layout is on the roadmap. I'm not sure why you're surprised that there are still certain aspects that aren't as mature as programs that have been around for 40 years.
Beiri22 commentedon Nov 23, 2023
Just in case, but maybe typst gives a very mature impression with its online appearance?
dhouck commentedon Nov 23, 2023
Yeah, that’s fair. I consider this, along with widow/orphan control, a more basic feature than some stuff that already exists, but that doesn’t mean it should have been implemented first.
jtchen2k commentedon Dec 1, 2023
+1 for this. I think this is one of the most fundamental features for a typesetting system.
betoma commentedon Dec 7, 2023
Absolutely 100% behind having this as a feature, it would solve so many problems. However, I will note that I had the exact same issue when working in LaTeX pretty often, and the solution was either really arcane or non-existent in some circumstances, so I don't think this is an area where Typst particularly falls behind in that respect.
PgBiel commentedon Feb 12, 2024
For people looking for a workaround, I've cooked something which might be helpful.
Basically consists of keeping the first element - and the spacing between both elements - unbreakable across pages, but not the second. Thus, it should work for the use case of (unbreakable) heading + (breakable) paragraph.
https://gist.github.com/PgBiel/2976c9d0ed5638ef57633ce7233928ea
johannesrave commentedon May 7, 2024
I'm also using blocks after headings and don't want them to break apart. This appears to be intended behaviour, but would be nice if it was configurable.
Enivex commentedon May 7, 2024
If you're referring to having an isolated heading at the bottom of a page, that's a bug, as mentioned above.
#1044
Shrinks99 commentedon Jun 27, 2024
Ran across this issue today. Wanted to highlight my use case of Markdown → Typst conversion & styling.
Also probably worth pointing out that this is fairly easy to solve on an individual document basis with manual page breaks, but would definitely be a welcome addition for improving automated workflows! :)
dhouck commentedon Jul 2, 2024
Manual page breaks work great, until you edit the text or styling or paper options in any way.
oliverpool commentedon Jul 8, 2024
I am creating a package for a songbook (similar to patacrep, which is based on LaTeX + Songs) and needed something similar.
Here is my current stance: https://codeberg.org/pfad.fr/typst-songbook/src/branch/main/autobreak.typ
When using
#autobreak[some content], it checks the length of the given content:It works best for short content (i.e. less than 1-2 pages), but it may help for something like:
oliverpool commentedon Jul 10, 2024
My
autobreakfunction fails when there are too many occurrences.. I would be grateful for ideas or suggestions in #4530 (adjusting #993 (comment) takes me further, but the underlying issue is still here)Andrew15-5 commentedon Sep 27, 2024
This issue was mentioned in https://forum.typst.app/t/how-to-make-sure-heading-and-the-first-following-content-stay-on-the-same-page/725/5.
kokkonisd commentedon Dec 6, 2024
Hi!
It seems that this is still broken inside
blocks:Compiled with:
(See attached PDF: main.pdf)
Andrew15-5 commentedon Dec 6, 2024
Can confirm. My initial thought (which can be true) was that this is because by default
block(breakable: true), but the heading should stick to the text below regardless. Maybe the breakable overrides the heading stickiness. Or maybe it's simply a new/untested edge case.laurmaedje commentedon Dec 6, 2024
Tracked by #5296
Timmmm commentedon Sep 18, 2025
It would be cool if when closing issues you could explain what the fix is. For anyone wondering, you can do this:
Maybe not the nicest syntax given how common this pattern is. It's regular at least.