I have a similar question as this one, but I'm getting a different error. I want to set the mainfont
in yaml to roboto, but I get the error "fontspec error: "font-not-found"" when I knit it to PDF.
---
title: "My Title"
header-includes:
- \usepackage[sfdefault]{roboto}
- \usepackage[T1]{fontenc}
output:
pdf_document:
latex_engine: xelatex
mainfont: roboto
---
Running MacTex 2016
sessionInfo()
#R version 3.3.2 (2016-10-31)
#Platform: x86_64-apple-darwin13.4.0 (64-bit)
#Running under: macOS Sierra 10.12.4
Update 1
It does work to define the font in header-includes
, but it seems like the mainfont
specification should also work:
---
title: "My Title"
header-includes:
- \usepackage[sfdefault]{roboto}
- \renewcommand{\familydefault}{\sfdefault}
output:
pdf_document:
latex_engine: xelatex
---
Update 2
monofont
also failed for me, but header-includes
worked:
---
title: "My Title"
header-includes:
- \usepackage{fontspec}
- \setmonofont[Mapping=tex-text]{inconsolata}
- \usepackage[sfdefault]{roboto}
- \renewcommand{\familydefault}{\sfdefault}
output:
pdf_document:
latex_engine: xelatex
---
What am I doing wrong with mainfont
and monofont
in the yaml?