我正在尝试在Rmd文件中生成一个树形图,我期望看起来像这样:
使用 rmarkdown 的render
功能。
但是得到 错误43 我不知道如何解释。我怎样才能获得pdf渲染?导致错误的是什么?
---
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 :(得分:3)
Pandoc将最后两个右括号] ]
变为{]} {]}
,如果使用输出选项keep_tex: true
,则可以看到这种行为。我不确定这是不是一个错误,您应该在pandoc邮件列表或file a report上询问。
快速解决方法是使用pandoc's ability to ignore the code inside an environment并使用虚拟环境包围您的命令:
---
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