Rstudio pdf knit 失败并出现 "Environment Shaded undefined"错误

标签 r rstudio r-markdown pdflatex

尝试使用包文章中的模板编织 PDF 时 output: rticles::acm_article我收到以下错误:

! LaTeX Error: Environment Shaded undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.76 \begin{Shaded}

这似乎只发生在我在输出文档中包含代码块时。

可重现的示例 :

您需要使用 New Document -> From Template -> Association for Computing Machinery 开始一个新的 R Markdown 文档。 .这是 R Markdown 文件:
---
title: Short Paper
author:
  - name: I Am Me
    email: me@email.com
    affiliation: Fictional University
abstract: |
  This is the abstract.
  It consists of two paragraphs.
output: 
  rticles::acm_article:
    keep_tex: true
---


## Simple test

Code chuck follows:

```{r}
plot(rnorm(10))
```

但是,如果我设置 echo=FALSE,则上面的示例有效在标题中。你不会在输出中得到代码,但是对于一篇学术论文,你可能无论如何都不需要它,如果你需要它,你可以以不同的方式显示它。

笔记:
  • R 版本 3.3.1 (2016-06-21)
  • 平台:x86_64-pc-linux-gnu(64位),
  • 运行 Ubuntu 16:10
  • 我确保我安装了 texlive-latex-base、texlive-latex-recommended 和 texlive-latex-extra 软件包,但仍然没有成功
  • 我还尝试从中间 .tex 文件生成 pdf,如建议 here ,但我得到同样的错误。
  • 我考虑过this approach ,但它不起作用,我仍然遇到错误(也许我需要调整才能在我的上下文中工作,但不确定如何)
  • 最佳答案

    所以,这里的问题是 rticles模板有时会省略 pandoc 注入(inject)代码突出显示环境的方法,例如Shaded .要解决这个问题,您必须插入 template.tex前言:

    $if(highlighting-macros)$
    $highlighting-macros$
    $endif$
    

    关于Rstudio pdf knit 失败并出现 "Environment Shaded undefined"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41052687/

    相关文章:

    r - 拆分单元格中的值并添加到 R 中新创建的行

    r - 如何在 Shiny 的应用程序中用颜色画一条线

    r - R中的highchart内部循环

    r - 将 LaTeX 与 R markdown 和 pandoc 相结合

    r - Shiny 的应用程序在 Rstudio 中运行良好但找不到文件错误 Shiny 服务器

    r - 如何删除 R Markdown 生成的 HTML 文件左侧的 "padding"

    knitr - 将 rmarkdown 文档编织到投影仪演示文稿时如何使用不同目录中的引用书目?

    r - 使用 dplyr 过滤数据框

    r - 字符串不是标准的明确格式

    r - 在 R markdown 中使用 knitr、kableExtra 和 Latex 将 col 名称和标题(上图)设置为奇怪的字符