4

I am struggling with changing the font of my pdf files. I don't have Helvetica on my computer so I am unable to compile .pdf (html works perfectly). I believe my Rmarkdown coding is not working but it is identical to what is suggested here. LaTeX is installed and properly working, I can compile using XeLaTeX from Lyx.

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

As far as I understand, Calibri font is loaded

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

I keep geting the cannot load afm file 'Helvetica.afm' error. This is my session

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

UPDATE

The error is with R code chunks. If I knit everything but the R chunk it works

---
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
Community
  • 1
  • 1
Matias Andina
  • 4,029
  • 4
  • 26
  • 58

0 Answers0