【发布时间】:2012-08-27 18:10:24
【问题描述】:
恐怕回答会是:“Markdown 本来就是简单的,但它并没有做到这一点”,但问它(几乎)永远不会有坏处。
在编写 R Markdown 文档时,我可以在浏览器中查看 HTML 文件,它看起来很棒。当我尝试在纸上或 PDF 上打印它时,会打印图中的颜色,但不会突出显示语法。有没有办法在打印时保持语法高亮?
例子:
Minimal Example
=====
This text looks great in the file and the plot prints in color, but see commented code below.
```{r}
# this commented line will be green in the HTML file, but will be black when I print it
z <- cor(mtcars)
require(lattice) # 'require' will be blue in the HTML file, but will be black when I print it
levelplot(z)
```
我在 RStudio 中按下“Knit HTML”按钮并在 Chrome 或 Safari 中打开 HTML,没有任何问题。如果我从浏览器中的 HTML 打印,所有语法高亮都会丢失。
【问题讨论】:
-
您能否举一个您的工作流程的最小可重现示例?
-
什么样的 R 降价?针织?
-
还有其他方法可以使用 R Markdown 吗?请详细说明。
-
剥猫皮的方法有很多。对于 r 降价,您还可以使用 pander
-
knit2HTML按钮的使用在这里至关重要。问题在于markdown::markdowntoHTML突出显示的方式