Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page Numbering in R Bookdown

Tags:

r

latex

bookdown

How do you achieve roman numerals for things like preface, acknowledgement etc and restart Arabic numbering at 1 for first page of chapter one in R Bookdown.

I am wanting to render to pdf in bookdown, but have not found any good information on how to change page numbering like this

thanks

like image 295
Lyndon Sundmark Avatar asked Apr 30 '17 20:04

Lyndon Sundmark


1 Answers

I think it might be easier to just follow the example @yihui used in his own bookdown krantz example:

Add the following files, perhaps in a /latex subfolder:

  • preamble.tex with the latex \frontmatter command at the end,
  • after_body.tex with the latex \backmatter command,

Then, before your first actual main body, just add the \mainmatter command (just in latex) to, say, your index.Rmd (whichever of your *.Rmds is first, conventionally index.Rmd).

Then, to amend your _output.yml like so:

bookdown::pdf_book:
  includes:
    in_header: latex/preamble.tex
    after_body: latex/after_body.tex 

This intersperses the correct \frontmatter, \mainmatter and \backmatter commands into your pandoc-ed latex book. It will be respected by most style files to make sure that arabic numbering only begins inside the main matter.

This is also documented in the publishing chapter of the bookdown book.

like image 191
maxheld Avatar answered Sep 18 '22 18:09

maxheld