2015-11-04 96 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

太棒了。不知道你能做到这一点。谢谢。 –