Chris437
Chris437

Reputation: 69

`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:

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

Upvotes: 1

Views: 1039

Answers (1)

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

Upvotes: 4

Related Questions