问题描述
我想在其中一张幻灯片的文本中添加一个图标。 我尝试了一些东西,但最终结果不稳定。图标正在 html 文件中打印,但是如果我添加幻灯片或一些文本,图标就会消失。即使我将使用 Ctrl+Z 完成的操作恢复为以前的工作代码,图标也不会打印...
我可能遗漏了一些东西,但书单 documentation 没有关于这个主题的任何内容......
---
title: 'Title'
author: "Author"
date: '`r format(Sys.time(),"%d %B,%Y")`'
output:
ioslides_presentation:
self_contained: true
incremental: false
---
```{r knitr_init,echo=FALSE,message=FALSE,warning=FALSE,cache=FALSE}
## Global options
library(knitr)
library(shiny)
opts_chunk$set(
cache = FALSE,prompt = FALSE,tidy = FALSE,comment = NA,message = FALSE,warning = FALSE
)
library(tidyverse)
library(plotly)
```
## S1
`r shiny::tags$i(class = "fa fa-arrow-down",style = "color: rgb(0,166,90)")`
item 3
`r shiny::tags$i(class = "fa fa-arrow-down",90)")`
item 2
## S2
```{r,echo=F}
data.frame(a=1:10,b=1:10) %>%
plot_ly(x=~a,y=~b)
```
将图标写成 <i class="fa fa-arrow-down" style="color: rgb(0,90)"></i>
似乎也不起作用。
解决方法
一种选择是使用包 icon
(更多信息 here)。
---
title: 'Title'
author: "Author"
date: '`r format(Sys.time(),"%d %B,%Y")`'
output:
ioslides_presentation:
self_contained: true
incremental: false
---
```{r knitr_init,echo=FALSE,message=FALSE,warning=FALSE,cache=FALSE}
## Global options
library(knitr)
library(shiny)
opts_chunk$set(
cache = FALSE,prompt = FALSE,tidy = FALSE,comment = NA,message = FALSE,warning = FALSE,echo=FALSE
)
library(tidyverse)
library(plotly)
library(icon)
```
## S1
```{r icon-style1}
icon_style(fontawesome("arrow-down",style = "solid"),scale = 2,fill = "#00A65A")
```
item 3
```{r icon-style2}
icon_style(fontawesome("arrow-down",fill = "#00A65A")
```
item 2
## S2
```{r,echo=F}
data.frame(a=1:10,b=1:10) %>%
plot_ly(x=~a,y=~b)
```
-输出
我刚刚添加了两个代码块,每个图标一个。此外,在您的第一个 r
块中,我将 echo=FALSE
添加到 opts_chunk$set
和 library(icon)
。为了实现您选择的 RGB 颜色,需要 HEX 代码 (#00A65A)。