pandoc 中的错误 43:使用 rmarkdown 渲染 Rmd 包括 LaTeX qtree [英] error 43 in pandoc: render Rmd with rmarkdown include LaTeX qtree

查看:45
本文介绍了pandoc 中的错误 43:使用 rmarkdown 渲染 Rmd 包括 LaTeX qtree的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to produce a tree diagram in a Rmd file I expect to look like this:

使用 rmarkdownrender 函数.

但是得到一个错误 43 我不知道如何解释.我怎样才能让pdf呈现?导致错误的原因是什么?

But get an error 43 I do not know how to interpret. How can I get the pdf to render? What's causing the error?

---
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文件编译成功:

The following .Rnw document compiles successfully:

\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}

推荐答案

Pandoc 把最后两个右括号 ] ] 变成 {]} {]},一个行为您可以查看是否使用输出选项 keep_tex: true.我不确定这是否是一个错误,您应该在 pandoc 邮件列表或 提交报告.

Pandoc turns the last two closing brackets ] ] as {]} {]}, a behavior you can see if you use output option keep_tex: true. I am not sure whether this is a bug, you should ask this on the pandoc mailing-list or file a report.

快速解决方法是使用 pandoc 忽略环境中代码的能力和用虚拟环境包围您的命令:

A quick fix is to use pandoc's ability to ignore the code inside an environment and surround your command with a dummy 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 

这篇关于pandoc 中的错误 43:使用 rmarkdown 渲染 Rmd 包括 LaTeX qtree的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆