【问题标题】:error 43 in pandoc: render Rmd with rmarkdown include LaTeX qtreepandoc 中的错误 43:使用 rmarkdown 渲染 Rmd 包括 LaTeX qtree
【发布时间】:2015-11-04 14:56:00
【问题描述】:

我正在尝试在 Rmd 文件中生成一个树形图,我希望它看起来像这样:

使用 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}

【问题讨论】:

  • \tree 命令在带有 knitr 的 Rnw 文件中工作。
  • 这意味着 LaTeX 无法创建 PDF...首先使用 pdflatex 尝试您的内联 TeX...
  • 您可以使用keep_tex: true 作为排除故障的输出选项。似乎有两个问题:1.您的表达式不适用于我的常规 tex 文件。我必须在每个右括号和 2 之后添加新行。 pandoc 将最后两个右括号视为文字字符串并将它们括在 { : {]} {]} 而不是 ] ] 中。
  • @scoa 谢谢。很好的线索...该表达式对我来说在 Rnw 中有效,在我将 .tex 中的 {]} 变成 ] 之后,keep_tex: true nakes 文件运行。如何防止 pandoc 将 ] 解释为 {]}

标签: r r-markdown pandoc


【解决方案1】:

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 

【讨论】:

  • 太棒了。不知道你能做到这一点。谢谢。
猜你喜欢
  • 2018-02-23
  • 1970-01-01
  • 1970-01-01
  • 2016-05-22
  • 2015-12-15
  • 1970-01-01
  • 1970-01-01
  • 2018-04-09
  • 2020-11-30
相关资源
最近更新 更多