Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R markdown - how to switch font to Times New Roman?

Tags:

markdown

fonts

I gave up. I can't find any working solution to change font type in my R Markdown document. I tried a lot of stuff, for example:

---
output: word_document    
sansfont: Calibri Light
---

But RStudio just ignores it. Can you help me? I need Times New Roman font in my pdf/word document.

Regards

like image 378
Tomasz Wojtas Avatar asked Apr 30 '16 21:04

Tomasz Wojtas


2 Answers

Another option: for a pdf document, I used:

output: pdf_document
fontfamily: arev

In my YAML header.

like image 117
Nova Avatar answered Oct 14 '22 01:10

Nova


This worked for me. Try using mainfont instead of sansfont, and set latex_engine to either xelatex or lualatex.

---
output: 
  pdf_document:
    latex_engine: xelatex
mainfont: Times New Roman
---
like image 45
Nishant Panicker Avatar answered Oct 14 '22 00:10

Nishant Panicker