2015-11-04 59 views
2

我想產生一個RMD文件樹形圖我希望是這樣的:錯誤43 pandoc:渲染RMD與rmarkdown包括乳膠配額樹

使用rmarkdownrender功能。

但是得到一個錯誤43我不知道如何解釋。我怎樣才能讓pdf呈現?什麼導致了錯誤?

RMD文件

--- 
title: "testtree" 
header-includes: 
    - \usepackage{qtree} 
output: 
    pdf_document 
--- 

\Tree [.S [.NP LaTeX ] [.VP [.V is ] [.NP fun ] ] ] 

Success 

錯誤消息

> rmarkdown::render("testtree.Rmd", "all") 


processing file: testtree.Rmd 
    |.................................................................| 100% 
    ordinary text without R code 


output file: testtree.knit.md 

"C:/Users/trinker/AppData/Local/Pandoc/pandoc" +RTS -K512m -RTS testtree.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output testtree.pdf --template "C:\R\R-3.2.2\library\rmarkdown\rmd\latex\default-1.14.tex" --highlight-style tango --latex-engine pdflatex --variable "geometry:margin=1in" 
! Paragraph ended before \doanode was complete. 
<to be read again> 
        \par 
l.90 

pandoc.exe: Error producing PDF from TeX source 
Error: pandoc document conversion failed with error 43 
In addition: Warning message: 
running command '"C:/Users/trinker/AppData/Local/Pandoc/pandoc" +RTS -K512m -RTS testtree.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output testtree.pdf --template "C:\R\R-3.2.2\library\rmarkdown\rmd\latex\default-1.14.tex" --highlight-style tango --latex-engine pdflatex --variable "geometry:margin=1in"' had status 43 
> 

以下.Rnw文件編譯成功:

\documentclass{article} 
\usepackage[T1]{fontenc} 
\usepackage{qtree} 

\begin{document} 

Here is a code chunk. 

\Tree [.S a [.NP {\bf b} c ] d ] 

You can also write inline expressions, e.g. $\pi=\Sexpr{pi}$, and \Sexpr{1.598673e8} is a big number. 

\end{document} 
+0

的'\ tree'命令可knitr文件。 –

+0

這意味着LaTeX無法創建PDF ...先用'pdflatex'試試你的內聯TeX ... – mb21

+1

你可以使用'keep_tex:true'作爲輸出選項來排除故障。看起來有兩個問題:1.你的表達式在我的常規tex文件中不起作用。我必須在每個右括號後添加新行,並且2. pandoc將最後兩個右括號視爲文字字符串,並將它們封裝在{:{{}} {]}'中,而不是']]'中。 – scoa

回答

3

Pandoc變成最後兩個右括號] ]作爲{]} {]},行爲你可以看看你是否使用輸出選項keep_tex: true。我不確定這是否是一個錯誤,你應該在pandoc郵件列表或file a report上提問。

一個快速的解決辦法是使用pandoc's ability to ignore the code inside an environment和環繞你的命令與虛擬的環境中,一個RNW

--- 
title: "testtree" 
header-includes: 
    - \usepackage{qtree} 
    - \newenvironment{dummy}{}{} 
output: 
    pdf_document: 
     keep_tex: true 
--- 

\begin{dummy} 
\Tree [.S [.NP LaTeX ] [.VP [.V is ] [.NP fun ] ] ] 
\end{dummy} 

Success 
+0

太棒了。不知道你能做到這一點。謝謝。 –