Reputation: 6310
An Rmd file with the YAML headers:
---
title: "Untitled"
author: "Me"
date: "September 14, 2015"
output:
pdfdocument:
latexengine: xelatex
fontsize: 12pt
---
Correctly renders in 12 computer modern roman when converted to PDF in RStudio. If I add mainfont
:
---
title: "Untitled"
author: "Me"
date: "September 14, 2015"
output:
pdfdocument:
latexengine: xelatex
fontsize: 12pt
mainfont: Helvetica
---
The PDF is rendered in Helvetica, but at 10 point. I can't get PDF output of 12pt non-CMR. Is there any way to do this?
I've also tried setting the YAML to 12pt
and putting \usepackage{helvet}
in an external .tex
file that gets included in_header
, but I get 12pt CMR.
Upvotes: 3
Views: 1173
Reputation: 2150
I often encounter problems when trying to use Rmarkdown YAML commands to change font specs. For example, for me neither mainfont nor sansfont command worked to render in Helvetica, or maybe I just fail at figuring out the correct indentation in the YAML header. Besides, I guess you would need to give more information about which OS and R(markdown) Version you're using for someone to help you.
A solution that worked for me (64-bit Linux, R 3.1.2, Rmarkdown 0.7) using CTAN helvet package is this one (let me know it it works for you):
---
title: "Untitled"
author: "Me"
date: "September 14, 2015"
header-includes:
- \usepackage{helvet}
- \usepackage[T1]{fontenc}
- \renewcommand\familydefault{\sfdefault}
output:
pdf_document
fontsize: 12pt
---
I derived the solution from this post.
Upvotes: 1