更改默认的RMarkdown字体

时间:2017-01-05 18:18:51

标签: r pdf latex yaml r-markdown

我正在努力改变我的pdf文件的字体。我的计算机上没有Helvetica所以我无法编译.pdf(html完美无缺)。我相信我的Rmarkdown编码不起作用,但它与建议的here相同。 LaTeX安装正常,我可以使用Lyx的XeLaTeX进行编译。

---
title: "5_jan"
author: "Matias Andina"
date: "January 5, 2017"
output: 
  pdf_document:
    latex_engine: xelatex
sansfont: Calibri Light
---

据我了解,Calibri字体已加载

fonts()[grepl('Calibri',fonts())]
[1] "Calibri"       "Calibri Light"

我一直在调整cannot load afm file 'Helvetica.afm'错误。这是我的会议

sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] extrafont_0.17 knitr_1.13     dplyr_0.4.3   

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.7     digest_0.6.9    assertthat_0.1  R6_2.1.2       
 [5] Rttf2pt1_1.3.4  DBI_0.4-1       magrittr_1.5    highr_0.6      
 [9] lazyeval_0.2.0  extrafontdb_1.0 rmarkdown_0.9.6 tools_3.3.0    
[13] yaml_2.1.13     parallel_3.3.0  htmltools_0.3.5

更新

错误在于R代码块。如果我编织除了R块之外的所有东西都可以工作

---
title: "5_jan_hplc"
author: "Matias Andina"
date: "January 5, 2017"
output: 
  pdf_document:
    latex_engine: xelatex
mainfont: Calibri Light 
---

this is my test  

I can write anything here and it will render **perfectly**  

```{r}
plot(mtcars)
```

processing file: test.Rmd
Quitting from lines 16-17 (test.Rmd) 
Error in grDevices::pdf(NULL, width, height, ...) : 
  failed to initialise default PDF font
Calls: <Anonymous> ... chunk_device -> dev_new -> do.call -> <Anonymous> -> <Anonymous>
In addition: Warning messages:
1: In grDevices::pdf(NULL, width, height, ...) :
  afm file 'C:\PROGRA~1\R\R-33~1.0/library/grDevices/afm/Helvetica.afm' could not be opened
2: In grDevices::pdf(NULL, width, height, ...) :
  cannot load afm file 'Helvetica.afm'
Execution halted

0 个答案:

没有答案