Search code examples
r-markdownline-breakspage-break

Inserting custom-spaced page breaks in Rmarkdown HTML output


I have a rmarkdown script that generates html of some maps and tables. Sometimes, one of the tables is shorter than usual and the next header shifts upward into the space of the previous section. Here is an example of what is happening:

Missing Page-Break Example

I am trying to get the header of the next section to be below both the "LOB" and "Location" tables. Is there a simple way (using css, html, rmarkdown, etc) to get around this without having to create a custom page breaker that measures the number of rows of the previous table?


Solution

  • In Rmarkdown, i usually use <br> </br> syntax for small breaks in HTML code, according to the R Markdown Cookbook for breaks you use \newpage, but that only worked for me for PDF output

    ---
    title: Breaking pages
    output: pdf_document
    ---
    
    # The first section
    
    \newpage
    
    # The second section
    

    enter image description here