pandoc 中的错误 43:使用 rmarkdown 渲染 Rmd 包括 LaTeX qtree
error 43 in pandoc: render Rmd with rmarkdown include LaTeX qtree
我正在尝试在 Rmd 文件中生成树状图,我希望它看起来像这样:
使用 rmarkdown 的 render
函数。
但是得到一个error 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}
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
我正在尝试在 Rmd 文件中生成树状图,我希望它看起来像这样:
使用 rmarkdown 的 render
函数。
但是得到一个error 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}
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