New versions of typst do not allow page breaks in a show heading rule anymore. This is why we are using colbreaks. However, we noticed that colbreak seems to get applied after the outline is generated, leading to wrong page numbers in the outline.
The headings are on different pages, but the outline shows page 2 for both headings. Even weirder, the outline shows an increment of 1 page for all following headings.
#outline()
#pagebreak()
#show heading: it => {
colbreak(weak: true)
it
}
= Heading 1
= Heading 2
= Heading 3
What could be the reason for this, and how could I achieve displaying headings on new pages with a correct outline?
Hello, page breaks should be working in heading show rules in all recent versions, you probably have additional things that cause the problem.
The problem with colbreak was introduced with Typst v0.12 see #5471 for the relevant GitHub issue.
Please post more information or a minimal example that shows your issue with page break.
#let typst-preview(output, typst-code) = table(
columns: 2,
fill: (_, row) => if row == 0 { blue } else { white },
align: (_, row) => if row == 0 { center } else { horizon + left },
text(fill: white, weight: "bold", "Typst Code"),
text(fill: white, weight: "bold", "Output"),
align(horizon, box(width: 100%, typst-code)),
box(width: 100%)[
#set heading(numbering: "i.", outlined: false)
#output
],
)
``
This function led to an error if the code passed to the function contained a level 1 heading.
I fixed the error by adding `offset: 1` to the set heading rule to ensure no level 1 headings can be passed to it.