gpt4 book ai didi

RMarkdown - 更改内联代码颜色

转载 作者:行者123 更新时间:2023-12-02 00:49:55 25 4
gpt4 key购买 nike

我正在使用inline code in RMarkdown我希望内联代码产生的所有文本在文档中具有不同的颜色。在 this example ,我希望 heat.colors 整个文档都是红色的。有办法做到这一点吗?

最佳答案

或者您可以在kableExtra中使用text_spec。从字面上看,它做了同样的事情,但只是更字面一点。查看更多here

---
title: ''
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(kableExtra)
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

This is inline code: `r text_spec(colnames(mtcars)[1], color = "red")`.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r cars}
summary(cars)
```

## Including Plots

You can also embed plots, for example:

### This is more inline code `r text_spec(colnames(mtcars)[2], color = "red")`.

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

关于RMarkdown - 更改内联代码颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50727217/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com