2016-12-09 28 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添加到代碼塊頭。你不會在輸出中獲得代碼,但是對於學術論文來說,你可能不需要它,如果你能以不同的方式展示它。

相關問題