You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在xaringan幻灯片中修改特定文字的字体样式、大小与颜色

在Xaringan幻灯片中修改特定文本样式的简便方法

可以直接通过内嵌HTML+CSS实现,无需额外配置,以下是针对你需求的修改方案:

修改后的完整代码

---
title: "Econ"
subtitle: "Week 1"
author: "Instructor"
date: "`r Sys.Date()`"
output: 
  xaringan::moon_reader:
    css: [default, metropolis, metropolis-fonts]
    lib_dir: libs
    nature:
      highlightStyle: arta
      highlightLines: true
      countIncrementalSlides: false
    
---

# Is economics a science?

--
Probably not, maybe <span style="color: red; font-size: 1.2em; font-weight: bold; font-style: italic;">pseudo-science</span>.

样式说明

  • color: red;:设置文本为红色
  • font-size: 1.2em;:将字号调大20%(em是相对单位,适配当前主题字号;也可使用18px这类固定值)
  • font-weight: bold;:实现粗体
  • font-style: italic;:实现斜体

另一种写法(嵌套语义化标签)

如果习惯用语义化标签,也可以嵌套<strong>(粗体)和<em>(斜体):

Probably not, maybe <strong><em style="color: red; font-size: 1.2em;">pseudo-science</em></strong>.

这两种方式都能直接在Xaringan幻灯片中生效,因为Xaringan支持Markdown内嵌HTML语法。

内容的提问来源于stack exchange,提问作者jck21

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 07:15:38