问题描述
我想使用 CSS 为 xaringan 幻灯片中的不同单词着色。
.red {
color: red;
}
我的 rmarkdown 文件有这个:
---
title: "test"
output:
xaringan::moon_reader:
css: ["stuff.css"]
lib_dir: libs
---
blah .red[<command]
blah .red[command>]
blah .red[<command>]
前两行按我的预期显示([
]
内的文本为红色),但第三行只显示废话。为什么会这样?如何让第三行在尖括号中显示 blah 后跟 word 命令?
解决方法
编辑
这应该可以解决问题。将这些添加到您的 function DirectedGraph() {
this.edges = {};
}
DirectedGraph.prototype.addVertex = function(vertex) {
this.edges[vertex] = {};
}
DirectedGraph.prototype.addEdge = function(origVertex,destVertex,weight=0) {
this.edges[origVertex][destVertex] = weight;
}
文件中:
css
然后,只需调用 .red {
color: red;
}
.red:before {
content: '\003C';
}
.red:after {
content: '\003E';
}
。特殊字符 .red[command]
和 <
将分别添加在 >
之前和之后,red:before
。
您可以在 Rmarkdown 中以多种方式使用 CSS 来控制输出中的彩色单词。整体主体颜色为 red
,而我可以使用内嵌 CSS 代码覆盖颜色。
---
title: "test"
output:
xaringan::moon_reader:
lib_dir: libs
---
```{css,echo = FALSE}
body{
color: red;
}
```
red
<span style="color:black">black</span>
<span style="color:green">green</span>