首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Xaringan演示文稿中的项目符号颜色

Xaringan演示文稿中的项目符号颜色
EN

Stack Overflow用户
提问于 2019-05-28 17:24:01
回答 2查看 1.4K关注 0票数 0

是否可以更改Xaringan演示文稿中的项目符号颜色?文本应该有不同的颜色。

我没有在xaringanthemer包中找到任何选项,也没有检查css文件。我在remark.js文档中找不到任何信息。

EN

回答 2

Stack Overflow用户

发布于 2019-05-28 18:17:03

您可以通过向Xaringan演示文稿的YAML标题添加自定义CSS来更改项目符号颜色。

下面是一个完全可重现的最小示例。

标记文件

代码语言:javascript
运行
复制
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)

代码语言:javascript
运行
复制
## Change bullet point colour

* An item
* Another item

自定义custom.css

我们采用了相关的CSS代码来主题化here中的要点。

代码语言:javascript
运行
复制
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) */
}

输出

票数 3
EN

Stack Overflow用户

发布于 2019-05-28 18:21:15

xaringan的输出是超文本标记语言,所以你可以通过css更改任何部分(例如,使用this guide将项目符号颜色更改为红点)。以此为模板,您可以在Rmd的YAML之后不久添加此块,以将其更改为红色项目符号:

代码语言:javascript
运行
复制
```{css, echo=F}

ul {

list-style:无;/删除默认项目符号/

}

ul li::之前{

content:" \2022 ";/ Add content:\2022是项目符号的CSS代码/unicode/

颜色:红色;/更改颜色/

font-weight:加粗;/如果希望加粗/

display: inline-block;/需要在项目符号和文本之间添加空格/

宽度: 1em;/也需要空间(如果需要可以调整)/

空白处-左:-1em;/也需要空间(如果需要可以调整)/

}

代码语言:javascript
运行
复制

将样式与内容分开

或者更好的(因为它将样式组件从幻灯片内容中分离出来),创建一个css文件,比如style.css,它包含:

代码语言:javascript
运行
复制
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在相同的路径中。

代码语言:javascript
运行
复制
css: [xaringan-themer.css, style.css]

调整项目符号形状

您可以使用content中提供的不同unicode来更改项目符号的形状(例如,将\2023用于三角形项目符号-请参阅其他常见类型here

更改项目符号颜色

您只需将red替换为您选择的颜色。您也可以将其替换为十六进制颜色代码。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56338948

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档