我正在try 在Rmarkdown 文档中添加字体很棒的图标,并将其呈现到HTML文件中.我在页脚中包含了字体Awesome CDN CSS链接,并使用includes
参数将其包含在文档中.当self_contained
YAML参数设置为false
时,图标可能会显示.
但是,当self_contained
设置为true
时,图标不会显示.
Rendered HTML document with self_contained: false
Rendered HTML document with self_contained: true
示例文档
Rmarkdown
---
title: "Test for fontawesome icon"
output:
html_document:
self_contained: true
includes:
after_body: samplefooter.html
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
```
Testing whether fontawesome icons could be shown
<!-- solid style -->
<i class="fas fa-user"></i>
<!-- regular style -->
<i class="far fa-user"></i>
<!--brand icon-->
<i class="fab fa-github-square"></i>
HTML页脚(samplefooter.html
)
<footer>
<br>
<!-- Add fa icon library -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" /> -->
<hr />
<p style="text-align: center;">
<a href="" title="icon 1" class="fas fa-globe-asia"></a>
<a href="" title="icon 2" class="fab fa-github"></a>
<a href="" title="icon 3" class="fas fa-envelope"></a>
</p>
<br>
</footer>
Xfun::会话信息
R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 12.3.1, RStudio 2022.2.3.492
Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8
Package version:
askpass_1.1 base64enc_0.1.3 bslib_0.2.5.1 cachem_1.0.5 callr_3.7.0 cli_3.1.0 colorspace_2.0-2
commonmark_1.7 compiler_4.1.0 cpp11_0.4.2 crayon_1.4.2 curl_4.3.2 digest_0.6.29 ellipsis_0.3.2
evaluate_0.14 fansi_0.5.0 farver_2.1.0 fastmap_1.1.0 fs_1.5.0 fst_0.9.4 glue_1.5.1
graphics_4.1.0 grDevices_4.1.0 highr_0.9 htmltools_0.5.2 httpuv_1.6.1 httr_1.4.2 jquerylib_0.1.4
jsonlite_1.7.2 kableExtra_1.3.4 knitr_1.36 labeling_0.4.2 later_1.2.0 lifecycle_1.0.1 magrittr_2.0.1
methods_4.1.0 mime_0.12 munsell_0.5.0 openssl_1.4.5 packrat_0.7.0 parallel_4.1.0 pillar_1.6.4
pkgconfig_2.0.3 processx_3.5.2 promises_1.2.0.1 ps_1.6.0 R6_2.5.1 rappdirs_0.3.3 RColorBrewer_1.1.2
Rcpp_1.0.7 rlang_0.4.12 Rmarkdown _2.14 rsconnect_0.8.25 rstudioapi_0.13 rvest_1.0.0 sass_0.4.0
scales_1.1.1 selectr_0.4.2 shiny_1.6.0 sourcetools_0.1.7 stats_4.1.0 stringi_1.7.5 stringr_1.4.0
svglite_2.0.0 sys_3.4 systemfonts_1.0.2 tibble_3.1.6 tinytex_0.32 tools_4.1.0 utf8_1.2.2
utils_4.1.0 vctrs_0.3.8 viridisLite_0.4.0 webshot_0.5.2 withr_2.4.3 xfun_0.31 xml2_1.3.2
xtable_1.8-4 yaml_2.2.1