我需要知道如何使用 RMarkdown 中的 block 获取要应用于我的 .Rmd 报告的 CSS 文件?可能吗?
其实我想把.css
文件做成一个参数。
如下所示:
---
title: "Untitled"
output:
html_document
---
```{css, echo=FALSE}
source('style.css')
```
最佳答案
您可以尝试使用 htmltools::includeCSS()
:
my_css.css
的内容:
p {
color: red;
}
Rmd 的内容:
---
title: "Untitled"
output: html_document
params:
my_css: my_css.css
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{r}
htmltools::includeCSS(params$my_css)
```
Hello World!
生成红色文本:
https://stackoverflow.com/questions/71758190/
相关文章:
javascript - 为什么 react 会抛出 "Too many re-renders.",
ruby-on-rails-7 - 如何在Rails7中使用importmap固定npm、yarn包
json - 在 Rust 中使用可选的 JSON 字段,避免在 JSON 中使用 None/nul
arrays - Matrix 有一列全部为 'true' 。如何在不到 O(mn) 的时间内找到它
html - 如何识别dex :get as being JSON or HTML in Commo
html - Font-Awesome 版本 6 图标未显示