我正在R中使用神话般的knitr()
包,以通过LaTeX将rmarkdown渲染为PDF。由于默认语法突出显示不是我想要的,并且LaTeX环境listings
在突出显示R代码方面有严格的限制,因此我想使用LaTeX minted
包,只需将编织代码嵌入到铸造的环境中
有人让knitr使用LaTeX软件包minted
吗?
我已经无法通过一个奇怪的错误加载铸造的包了:D
---
title: "Test"
author: "me"
date: "10. March 2019"
output:
pdf_document
header-includes:
- \usepackage{minted}
---
```{r}
library(knitr)
minted_hook = function(x, options) { paste0("\\begin{minted}{R}", x, "\\end{minted}\n") }
knit_hooks$set(
source = minted_hook,
warning = minted_hook,
message = minted_hook,
error = minted_hook
)
```
# Test
```{r}
# this is a comment
a <- 1:10
a
```
一旦我加载了薄荷糖,我就会收到错误消息
"C:/PROGRA~1/PANDOC~1.1/pandoc" +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.tex --template "[path not shown]\R\WIN-LI~1\3.5\RMARKD~1\rmd\latex\DEFAUL~3.TEX" --highlight-style tango --pdf-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" --variable "compact-title:yes"
tlmgr search --file --global "/(.sty"
Fehler in grep(paste0("/", x[j], "$"), l)
> invalid regular expression '/(.sty$', Reason 'Missing ')
我确实按照here的说明安装了pygminted。