RMarkdown - 更改内联代码颜色 [英] RMarkdown - Change Inline Code Color

查看:111
本文介绍了RMarkdown - 更改内联代码颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 RMarkdown 中的内联代码,我想要所有的文本内联代码的结果是文档中的不同颜色.在这个例子中,我希望heat.colors在整个文档中都是红色的.有没有办法做到这一点?

I am using inline code in RMarkdown and I would like all the text that is a result of inline code to be a different color in the document. In this example, I would like heat.colors to be red all over the document. Is there a way to do this?

推荐答案

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

Or you can use text_spec in kableExtra. It literarily does the same thing but just a tiny bit more literal. See more 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 - 更改内联代码颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆