Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bookdown: Set Page Breaks

Tags:

r

bookdown

I cannot find out how to make a page break in R bookdown. With page break I mean that the content within one page is displayed as one website.

By default there is always a page break in front of every new section (like # Chapter 1). So, if I run render_book each section becomes one html file. But, if I have a lot of subsections then these sites get very long.

I would like to have page breaks before every subsection (like ## Chapter 1.1).

So far I tried adding \newpage, \pagebreak, --------------- to the .Rmd or to just provide the .Rmd files in the same structure as I would like to have them as .html files. Either way, the .html files are always created according to the sections.

like image 891
mRcSchwering Avatar asked Oct 10 '16 21:10

mRcSchwering


People also ask

How do you do a page break in HTML?

It's done via CSS (inline or in a stylesheet) by adding 'page-break-after: always' to a paragraph at the bottom of your page (above where you intend to break). Optionally, you may need to also add 'page-break-before:always' to the paragraph or heading (or other block level element) at the top of the next page.

How do I add page numbers in markdown?

Page numbering is straightforward. You can use \pagenumbering{gobble} for pages without numbering, \pagenumbering{roman} for roman page numbering and \pagenumbering{arabic} for normal page numbering. Just include the argument wherever you want the have the page numbering changed.


1 Answers

I think this is specified by the split_by argument of gitbook as documented here.

Sounds like you are using chapter but you want to be using section

The split_by argument specifies how you want to split the HTML output into multiple pages, and its possible values are:

  • rmd: use the base filenames of the input Rmd files to create the HTML filenames, e.g., generate chapter3.html for chapter3.Rmd;
  • none: do not split the HTML file (the book will be a single HTML file);
  • chapter: split the file by the first-level headers;
  • section: split the file by the second-level headers;
  • chapter+number and section+number: similar to chapter and section, but the files will be numbered;
like image 188
Gregor Thomas Avatar answered Oct 19 '22 07:10

Gregor Thomas