我有一個類似的問題this one,但我收到了一個不同的錯誤。我想將yaml中的mainfont
設置爲roboto,但是當我將它編織爲PDF時,出現「fontspec error:」font-not-found「」錯誤。rmarkdown pdf字體不可用
---
title: "My Title"
header-includes:
- \usepackage[sfdefault]{roboto}
- \usepackage[T1]{fontenc}
output:
pdf_document:
latex_engine: xelatex
mainfont: roboto
---
運行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
更新1
它的工作在header-includes
來定義字體,但它似乎像mainfont
規範也應該工作:
---
title: "My Title"
header-includes:
- \usepackage[sfdefault]{roboto}
- \renewcommand{\familydefault}{\sfdefault}
output:
pdf_document:
latex_engine: xelatex
---
更新2
monofont
也失敗了,對我來說header-includes
工作:
---
title: "My Title"
header-includes:
- \usepackage{fontspec}
- \setmonofont[Mapping=tex-text]{inconsolata}
- \usepackage[sfdefault]{roboto}
- \renewcommand{\familydefault}{\sfdefault}
output:
pdf_document:
latex_engine: xelatex
---
我在做什麼毛病在YAML mainfont
和monofont
?
非常有幫助,@易輝。感謝您花時間澄清。 –