如何在R Markdown幻灯片中更改字体颜色

4

我正在使用 R Markdown 创建幻灯片,并希望更改其中一张幻灯片的字体颜色。我想知道是否有可能?它只适用于单个幻灯片,因此无法在 PowerPoint 模板中更改。到目前为止,我找到的所有解决方案似乎都是针对 HTMLPDF 文档。

  • HTML文档使用CSS
---
title: "Example"
author: ""
date: "09/07/2020"
output:
  powerpoint_presentation
---


## R Markdown

<span style="color: red;">
This is an R Markdown presentation. 
I would like this text in red.
</span>


  • 将LaTeX转换为PDF格式
---
title: "Example"
author: ""
date: "09/07/2020"
output:
  powerpoint_presentation
---


## R Markdown

\textcolor{red}{
This is an R Markdown presentation. 
I would like this text in red.}
1个回答

1
您可以使用 {officedown} 和 {officer} 包,如 Rmarkdown Cook book 的第8.3章中所建议的那样来完成它。
1- 使用 officedown::rpptx_document 文档输出
2- 加载 officedownofficer
3- 使用 fp_text() 为块中的每个元素创建要应用的样式
4- 使用内联代码应用样式
---
title: Style text with officedown
output:
  officedown::rpptx_document: default
---

`` `{r setup, include=FALSE}

knitr::opts_chunk$set(echo = FALSE)

library(officedown)
library(officer)

ft <- fp_text(color = 'red', bold = TRUE)
`` `

## R Markdown

This is an R Markdown presentation. 
`r ftext("I would like this text in red", ft)`.


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接