inbo / INBOmd

An R package with a collection of RMarkdown styles and templates. Elaborate examples are available at https://github.com/inbo/INBOmd_examples
https://inbo.github.io/INBOmd
GNU General Public License v3.0
11 stars 2 forks source link

prevent subsection title + lone sentence at end of page (pdf output inbo_rapport) #44

Closed hansvancalster closed 5 years ago

hansvancalster commented 5 years ago
---
title: "Titel van het rapport"
site: bookdown::bookdown_site
output:
  bookdown::pdf_book:
    base_format: INBOmd::inbo_rapport
---

# Section

```{r results="asis", echo=FALSE}
cat(rep("a sentence", 27), sep = "\n", fill = 10)

Subsection

Here are some points to consider:

hansvancalster commented 5 years ago

Here is another example where the subsection title alone is at the bottom of the page:

---
title: "Titel van het rapport"
site: bookdown::bookdown_site
output:
  bookdown::pdf_book:
    base_format: INBOmd::inbo_rapport
---

# Section

```{r results="asis", echo=FALSE}
cat(rep("a sentence", 26), sep = "\n", fill = 10)

Subsection

Subsubsection

cat(rep("a sentence", 26), sep = "\n")
ThierryO commented 5 years ago

This is hard to solve because you want to keep three items together. In your first example you want the section and the list to keep together. In the second example the section and the last paragraph should be together.

A workaround is to add a \needspace{measurement}, e.g. \needspace{30mm}. This will calculate the remaning space on the page. If there is not enough vertical space, it will insert a pagebreak.

hansvancalster commented 5 years ago

That's a nice solution. @florisvdh pinging to you to make sure you read this. Closing the issue.