是否可以更改Xaringan演示文稿中的项目符号颜色?文本应该有不同的颜色。
我没有在xaringanthemer包中找到任何选项,也没有检查css文件。我在remark.js文档中找不到任何信息。
发布于 2019-05-28 18:17:03
您可以通过向Xaringan演示文稿的YAML标题添加自定义CSS来更改项目符号颜色。
下面是一个完全可重现的最小示例。
标记文件
title: "Example"
author: "Author"
date: "`r Sys.Date()`"
output:
xaringan::moon_reader:
css:
- default
- default-fonts
- custom.css
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
---
```{r setup, include=FALSE}
选项(htmltools.dir.version= FALSE)
## Change bullet point colour
* An item
* Another item
自定义custom.css
我们采用了相关的CSS代码来主题化here中的要点。
ul {
list-style: none; /* Remove default bullets */
}
ul li::before {
content: "\2022"; /* Add content: \2022 is the CSS Code/unicode for a bullet */
color: red; /* Change the color */
font-weight: bold; /* If you want it to be bold */
display: inline-block; /* Needed to add space between the bullet and the text */
width: 1em; /* Also needed for space (tweak if needed) */
margin-left: -1em; /* Also needed for space (tweak if needed) */
}
输出
发布于 2019-05-28 18:21:15
xaringan
的输出是超文本标记语言,所以你可以通过css更改任何部分(例如,使用this guide将项目符号颜色更改为红点)。以此为模板,您可以在Rmd的YAML之后不久添加此块,以将其更改为红色项目符号:
```{css, echo=F}
ul {
list-style:无;/删除默认项目符号/
}
ul li::之前{
content:" \2022 ";/ Add content:\2022是项目符号的CSS代码/unicode/
颜色:红色;/更改颜色/
font-weight:加粗;/如果希望加粗/
display: inline-block;/需要在项目符号和文本之间添加空格/
宽度: 1em;/也需要空间(如果需要可以调整)/
空白处-左:-1em;/也需要空间(如果需要可以调整)/
}
将样式与内容分开
或者更好的(因为它将样式组件从幻灯片内容中分离出来),创建一个css文件,比如style.css
,它包含:
ul {
list-style: none; /* Remove default bullets */
}
ul li::before {
content: "\2022"; /* Add content: \2022 is the CSS Code/unicode for a bullet */
color: red; /* Change the color */
font-weight: bold; /* If you want it to be bold */
display: inline-block; /* Needed to add space between the bullet and the text */
width: 1em; /* Also needed for space (tweak if needed) */
margin-left: -1em; /* Also needed for space (tweak if needed) */
}
然后添加YAML,确保style.css与Rmd在相同的路径中。
css: [xaringan-themer.css, style.css]
调整项目符号形状
您可以使用content
中提供的不同unicode来更改项目符号的形状(例如,将\2023
用于三角形项目符号-请参阅其他常见类型here。
更改项目符号颜色
您只需将red
替换为您选择的颜色。您也可以将其替换为十六进制颜色代码。
https://stackoverflow.com/questions/56338948
复制相似问题