更新时间:2022-05-23 09:15:42
您必须包含软件包color
,然后它才能工作.我不知道为什么它只在其中带有R块的情况下起作用.但是此解决方案将解决此问题:
You have to include the package color
, then it works. I don't know why this works just with an R chunk in it. But this solution will solve this problem:
---
title: "test"
output: pdf_document
header-includes: \usepackage{color}
---
Roses are \textcolor{red}{red}, violets are \textcolor{blue}{blue}.
如果要将颜色编织为HTML,则必须使用以下代码:
If you want to knit colors to HTML, you have to use this code:
---
title: "test"
output: html_document
---
Roses are <span style="color:red">red</span>,
violets are <span style="color:blue">blue</span>.