简体   繁体   中英

`fontawesome` icons ignored when knitting Rmarkdown to PDF

Unfortunately, I fail to knit an *.Rmd file in RStudio to PDF that includes fontawesome -icons. However, when knitting to output: html_document in renders perfectly.

Info:

  • I am using R version 4.0.3 with RStudio 1.3.1056
  • I have installed the latest TeX Live distribution

The following example contains elements taken from RStudio's Github :

Icon renders in HTML:

---
title: "FontAwesome in R Markdown"
output: html_document
---

```{r load_packages, message=FALSE, warning=FALSE, include=FALSE} 
library(fontawesome)
```

This is an R icon: `r fa("r-project", fill = "steelblue")`.

Icon is ignored for PDF output:

---
title: "FontAwesome in R Markdown"
output: pdf_document
---

```{r load_packages, message=FALSE, warning=FALSE, include=FALSE} 
library(fontawesome)
```

This is an R icon: `r fa("r-project", fill = "steelblue")`.

Neither R nor Rmarkdown shows any errors when rendering to PDF. Does anyone have an idea why it does not work?

Thank you very much.

Cheers, Christian

You can workaround the problem by using the fontawesome5 latex package:

---
title: "FontAwesome in R Markdown"
output: 
  pdf_document:
    keep_tex: true
header-includes:
  - \usepackage{fontawesome5}
---

This is an R icon: \faRProject

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM