0

How can i change the font size of PDF output in RMarkdown? The font to be changed is not in the chunk. Example:

---
title: "Example"
author: "Tales Martins"
output:
   pdf_document:
    toc: TRUE
    number_sections: TRUE
---
\newpage

```{r, include=FALSE, echo=FALSE}
library(knitr)

```
# Introduction
This is my introduction

How can I change the font size of "This is my introduction"? Default font is little in PDF output.

Thanks in advance

tales_alencar
  • 141
  • 1
  • 10
  • 1
    I've found some posts that may answer your question: [here](https://stackoverflow.com/questions/30446905/rmarkdown-font-size-and-header) and [here](https://stackoverflow.com/questions/32653557/how-do-you-change-the-font-size-in-rmarkdown-for-knitr). [Rmarkdown reference](https://www.rstudio.com/wp-content/uploads/2015/03/rmarkdown-reference.pdf) guide has useful information also. – MrCorote Aug 16 '19 at 20:47
  • Thanks you, man. The solution was really very simple. It was just a bug in my head :) – tales_alencar Aug 16 '19 at 20:59

2 Answers2

1

Did you try this?:

---
title: "Example"
author: "Tales Martins"
output:
   pdf_document:
    toc: true
    number_sections: yes
linestretch: 1.5
---

Add in the YAML linestretch: 1.5, after that change this toc: TRUE to this toc: true and number_sections: TRUE to number_sections: yes

An example here

https://i.stack.imgur.com/VEdLL.png

also you can select linestretch: 2 and others

0

The PDF is formatted through a TeX engine, so you could just start your document (after the {r setup} block) with usual TeX font size commands, i.e.:

\tiny
\scriptsize
\footnotesize
\small
\normalsize
\large
\Large
\LARGE
\huge
\Huge

and switch back and forth to your default document size (e.g. \normalsize) throughout your document.

The answer lies in TeX formatting, not RMarkdown itself. Many problems are solved by passing arguments to the TeX preamble (which Rstudio calls "header"), e.g.:

header-includes:
  \setmonofont{Menlo for Powerline}[Scale=0.65,Color=darkgray]

and many problems are created by using tabs instead of spaces, with the default RMarkdown engine, knitr.

Océane
  • 1
  • 1