【问题标题】:Adding icons to text unstable向不稳定的文本添加图标
【发布时间】:2021-02-24 17:11:41
【问题描述】:

我想在其中一张幻灯片的文本中添加一个图标。 我尝试了一些东西,但最终结果不稳定。该图标正在打印在 html 文件中,但如果我添加幻灯片或一些文本,图标就会消失。即使我将使用 Ctrl+Z 完成的操作恢复为以前的工作代码,图标也不会被打印出来......

我可能遗漏了一些东西,但 bookdown 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",style = "color: rgb(0,166,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,166,90)"></i> 似乎也不起作用。

【问题讨论】:

    标签: r r-markdown ioslides


    【解决方案1】:

    一种选择是使用包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", style = "solid"), scale = 2, 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$setlibrary(icon)。为了实现您选择的 RGB 颜色,需要 HEX 代码 (#00A65A)。

    【讨论】:

      猜你喜欢
      • 2012-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多