diff --git a/Template-Example-guide.pdf b/Template-Example-guide.pdf index bc94784..cb1b28c 100644 Binary files a/Template-Example-guide.pdf and b/Template-Example-guide.pdf differ diff --git a/chapters/01-Introduction.typ b/chapters/01-Introduction.typ index c683e62..1ea01d1 100644 --- a/chapters/01-Introduction.typ +++ b/chapters/01-Introduction.typ @@ -26,6 +26,13 @@ you can supply it if it is not "Introduction" using the `first_chapter_title` pa caption: [Code example explaining how to configure language and a different first chapter] ) +// By default, the template will *not* apply a pagebreak +// on non-top-level headings to avoid headings without content +// on the same page but can be enabled. +// The threshold percentage on the page can be configured +// by providing the `heading_pagebreak_percentage` propery like `0.7` or `none`. +// Top-level headings will always have a (weak) pagebreak. + == Bibliography As for bibliography / reference listing, diff --git a/template.typ b/template.typ index 5c2063c..5b8ac1d 100755 --- a/template.typ +++ b/template.typ @@ -140,6 +140,12 @@ // This is required to generate the content section correctly first_chapter_title: "Introduction", + // Factor of page location when to pagebreak headings + // to avoid a heading without content on the same page. + // Can be disabled by setting it to none + // WARNING: can result in "layout did not converge within 5 attempts" issue + heading_pagebreak_percentage: none, + // set automatically by using the template via `#show: thesis.with(...) body, ) = [ @@ -207,6 +213,21 @@ // (weak = no pagebreak on already blank pages) if it.level == 1 { pagebreak(weak: true) + } else if heading_pagebreak_percentage != none { + // If a heading would start at the very end of a page, + // it would not look right => pagebreak + context { + let here_abs = here().position().y + let here_rel = here_abs.abs / page.height + + if here_rel > heading_pagebreak_percentage { + // Write but hide to assess location correctly + // Hidden will not have any influence + // on the output besides correct calculation + hide[#here_abs.abs #page.height rel: #here_rel%] + pagebreak(weak: true) + } + } } [ diff --git a/thesis.typ b/thesis.typ index d34acf7..77cdf0d 100755 --- a/thesis.typ +++ b/thesis.typ @@ -36,4 +36,4 @@ but I am too lazy to explain. = Summary and Conclusion -#lorem(100) +#lorem(250)