# Formatting questions in R markdown with the bookdown package

Hi everyone,

I'm in the process of writing a book about data analysis. Currently using the R and the Bookdown package. I'm currently using your book "Authoring books and technical with R markdown" as a guide. Love it by the way!

I have some experience with LateX and Overleaf, but I'm starting to like R and the bookdown package more.

However, I encounter some problems related to formatting, especially the pdf document output.

I'm currently using the big example found in " bookdown: Authoring Books and Technical Documents with R Markdown" by Yihui as a default template.

Here are my questions:

1. How do I customize all the headings in the table of contents to the Danish language? Aswell as having the "Chapter 1" to render as "Kapitel 1, Kapitel 2 etc." in the pdf output.

2. How do I adjust pagenumbering. Running the output in pdf format shows that pagenumbering starts on the page with my table of contents. Basically I want to have the first pagenumber to show on the next page, where my abstract starts.

3. How do i configure the margins for the entire document? The function is called "equal margins" in Microsoft Word. It's doable with LateX and Overleaf engine. But for some reason I get an error in the console when I type the code in the Yaml.

4. Is it possible to create a full-sized book coverpage?

If you know the answers, please redirect me to some source code. I can't send you the code unfortunately because I had to reinstall R. Guess I played too much with all the different settings lol. Lets just say I managed to destroy the functionality of R lol.

I hope you can help

Regards,

Kenneth Gottfredsenbout R Markdown here.

Is this not working ? (4.5 Internationalization | bookdown: Authoring Books and Technical Documents with R Markdown)If so, this is an issue we should deal with

probably something that would require some LaTeX command. If you know how to do that with LaTeX, you can then include inside the default template. I do not know how to do that in LaTeX unfortunately

I believe this can be done in LaTeX using some options for the document class right ? Maybe geometry ?
See 3.3 PDF document | R Markdown: The Definitive Guide
See Also Pandoc Manual for layout option Pandoc - Pandoc User’s Guide

This will be passed to the LaTeX template using the geometry CTAN package

Again something to know how to do in LaTeX, then you can probably tweak the template to make that happen.

I've solved the page numbering problem as follows:

I added the following to the end of my preamble.tex file:

\frontmatter

That starts the book with roman numeral numbering, including the TOC. Then, wherever you want your front matter to end, just insert the following line:

\mainmatter

You can either do that in your before_body.tex, or you can do it in the Rmd files wherever you want, if you have additional front matter content, like I do.

If you need to mess with page numbering directly, you can use latex commands like this right in your markdown:

\setcounter{page}{1}\pagenumbering{arabic}

1 Like

I use the following code in my preamble.tex

\usepackage[paperwidth=5.5in, paperheight=8.5in]{geometry}
\geometry{left=.5in}
\geometry{right=.5in}
\geometry{bottom=.75in}
\geometry{top=.75in}

1 Like

I'm not sure exactly what you're looking for here, but I wanted an actual book cover. Here's the code I use:

% Insert book cover first and format title page after that
\usepackage{titling}
\usepackage{pdfpages}
\IfFileExists{./cover.pdf}{
\newcommand{\myCover}{./cover.pdf}}
{\IfFileExists{./cover.jpg}{
\newcommand{\myCover}{./cover.jpg}}
{\IfFileExists{./cover.png}{
\newcommand{\myCover}{./cover.png}}{}
}
}
\makeatletter
\@ifundefined{myCover}
{}
{
\pretitle{\begin{center}\includepdf{\myCover}}
\posttitle{\end{center}\setcounter{page}{0}}
\usepackage{atbegshi}% http://ctan.org/pkg/atbegshi