2016-12-09 35 views
0

当试图使用从包艺品模板编织一个PDF(输出:艺品:: acm_article)我得到以下错误:Rstudio PDF针织失败,“环境配以未定义”错误

! LaTeX Error: Environment Shaded undefined. 

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

l.76 \begin{Shaded} 

[R版本3.3 0.1(2016年6月21日)

平台:x86_64的-PC-Linux的GNU(64位), 运行Ubuntu 16:10

我确信我有的texlive胶乳基, texlive-latex-recommended和texlive-latex-extra软件包已安装,但仍然没有运气

我也尝试从中间.tex文件生成pdf,建议here,但我得到了同样的错误。

更新1:

我认为this approach,但它没有工作,我仍然有一个错误(也许我需要调整我的情况下工作,但不知道如何)

更新2 :

我找到了解决办法。如果我用块选项echo = FALSE隐藏代码,则不会产生PDF。

可重复实施例1:

title: Short Paper 
author: 
    - name: I Am Me 
    email: [email protected] 
    affiliation: Fictional University 
abstract: | 
    This is the abstract. 

    It consists of two paragraphs. 
bibliography: sigproc.bib 
output: 
    rticles::acm_article: 
    keep_tex: true 
--- 


## Simple test 

Code chuck follows: 

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

针织到PDF失败! LaTeX Error: Environment Shaded undefined.

实施例2:

--- 
title: Short Paper 
author: 
    - name: I Am Me 
    email: [email protected] 
    affiliation: Fictional University 
abstract: | 
    This is the abstract. 

    It consists of two paragraphs. 
bibliography: sigproc.bib 
output: 
    rticles::acm_article: 
    keep_tex: true 
--- 


## Simple test 

Code chuck follows: 

```{r echo=FALSE} 
plot(rnorm(10)) 
``` 

针织到PDF作品!

这两个示例唯一的区别是将echo=FALSE添加到代码块头。你不会在输出中获得代码,但是对于学术论文来说,你可能不需要它,如果你能以不同的方式展示它。

+0

你有没有试过这种方法? http://stackoverflow.com/questions/34180355/pandoc-syntax-highlighting-in-pdf-not-working。 –

+0

如果它仍然不起作用,请提供一个最简单的示例。 – Christoph

+0

我无法尝试这种方法,因为ir需要有一个.md文件来提供pandoc命令。在我的情况下,编织过程在输出.md文件之前失败。 – HAVB

回答

1

因此,这里的问题是rticles模板有时省略了pandoc注入代码高亮环境的方法,例如, Shaded。为了解决这个问题,你需要插入template.tex前导码:

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

我找到了解决办法。如果我用块选项echo = FALSE隐藏代码,则不会产生PDF。

可重复实施例1:

title: Short Paper 
author: 
    - name: I Am Me 
    email: [email protected] 
    affiliation: Fictional University 
abstract: | 
    This is the abstract. 

    It consists of two paragraphs. 
bibliography: sigproc.bib 
output: 
    rticles::acm_article: 
    keep_tex: true 
--- 


## Simple test 

Code chuck follows: 

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

针织到PDF失败! LaTeX Error: Environment Shaded undefined.

实施例2:

--- 
title: Short Paper 
author: 
    - name: I Am Me 
    email: [email protected] 
    affiliation: Fictional University 
abstract: | 
    This is the abstract. 

    It consists of two paragraphs. 
bibliography: sigproc.bib 
output: 
    rticles::acm_article: 
    keep_tex: true 
--- 


## Simple test 

Code chuck follows: 

```{r echo=FALSE} 
plot(rnorm(10)) 
``` 

针织到PDF作品!

这两个示例唯一的区别是将echo=FALSE添加到代码块头。你不会在输出中获得代码,但是对于学术论文来说,你可能不需要它,如果你能以不同的方式展示它。

相关问题