【发布时间】:2015-11-04 14:56:00
【问题描述】:
我正在尝试在 Rmd 文件中生成一个树形图,我希望它看起来像这样:
使用 rmarkdown 的 render 函数。
但是得到一个错误 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}
【问题讨论】:
-
\tree命令在带有 knitr 的 Rnw 文件中工作。 -
这意味着 LaTeX 无法创建 PDF...首先使用
pdflatex尝试您的内联 TeX... -
您可以使用
keep_tex: true作为排除故障的输出选项。似乎有两个问题:1.您的表达式不适用于我的常规 tex 文件。我必须在每个右括号和 2 之后添加新行。 pandoc 将最后两个右括号视为文字字符串并将它们括在 { :{]} {]}而不是] ]中。 -
@scoa 谢谢。很好的线索...该表达式对我来说在 Rnw 中有效,在我将 .tex 中的
{]}变成]之后,keep_tex: truenakes 文件运行。如何防止 pandoc 将]解释为{]}?
标签: r r-markdown pandoc