In `rmarkdown`, how to add icon in sentence?

Viewed 650

In rmarkdown, how to add icon in sentence? For instance as below, how to add markdown icon between word 'Markdown' and 'is'

enter image description here

3 Answers

There's a nice R package that makes it easy to download and add icons to RMarkdown documents, icons. First, just install and download the necessary icons.

remotes::install_github("mitchelloharawild/icons")
icons::download_fontawesome()

Then we can easily use the icon in RMarkdown.

---
title: "Example"
output: html_document
---

Markdown `r icons::fontawesome("markdown")` is a simple formatting syntax
for authoring HTML, PDF, and MS Word documents.

enter image description here

You can play around with the styling using the style argument to fontawesome() or with more complex styles with font_styles().

You can use

```{r include=FALSE}
library(fontawesome)``` 

(The fontawesome package is available from CRAN.)

And then to insert an icon:

r fa(name = "markdown", fill = "green", height = "1em")

Example:

Markdown `r fa(name = "markdown", fill = "green", height = "1em")`  is 
a simple formatting syntax for authoring HTML, PDF, 
and MS Word documents.

enter image description here

You can find the available icons at:

Fontawesome.

Another solution is to use shiny function icon:

---
title: "Example"
output: html_document
---

Markdown `r shiny::icon("markdown")` is a simple formatting syntax for authoring HTML, PDF, and MS Word documents.

example

Related