如何在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
相关产品推荐
相关产品推荐

