2

在上一个问题knitr2pdf eclipse 中:如何配置?,我尝试设置eclipse与knitr2pdf一起工作,Yihui Xie很友好地给了我一个非常迅速的答案。现在我又被困了一步。

这是我的文件

---
title: "knit2pdf test"
author: "cedric"
date: "27/10/2017"
output: pdf_document
---


```{r}
plot(rnorm(1:10))
```

运行此文件时,我得到以下答案

knit2pdf(input= "C:/workspace/p/example_scripts/test_knit2pdf.Rmd")


processing file: C:/workspace/p/example_scripts/test_knit2pdf.Rmd
  |................................                                 |  50%
  ordinary text without R code

  |.................................................................| 100%
label: unnamed-chunk-1

output file: test_knit2pdf.md

Error: running 'texi2dvi' on 'test_knit2pdf.md' failed

LaTeX errors:
! Emergency stop
*** (job aborted, no legal \end found)

!  ==> Fatal error occurred, no output PDF file produced!
!  ==> Fatal error occurred, no output PDF file produced!
In addition: Warning message:
running command '"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\texify.exe" --quiet --pdf "test_knit2pdf.md" --max-iterations=20 -I "C:/Program Files/R/R-3.4.2/share/texmf/tex/latex" -I "C:/Program Files/R/R-3.4.2/share/texmf/bibtex/bst"' had status 1 

我试图找到报告类似问题的问题,将 knit2pdf 与 Rmd 文件一起使用,答案是尝试使用渲染而不是 knit2pdf,这不是我想要的。这不是 Eclipse 的问题,但我无法正确运行 knit2pdf。手动运行命令 knit2pdf("test_knit2pdf.Rmd") 得到相同的错误。同样,也许有人会遇到类似的问题并且能够帮助我,我的文件是否格式错误,我错过了什么?

4

1 回答 1

1

要使用 rmarkdown::render() 处理 Rmd 文档,需要执行以下步骤

安装 pandoc 编辑 windows 路径,系统环境变量,复制路径到 pandoc 位于C:\Users\me\AppData\Local\Pandoc

转到eclipse,运行>外部工具>外部工具配置单击wikitext + R文档处理在下拉菜单中,右上角,命名为加载预设示例,单击使用Rmarkdown的PDF,单步。在 2/ 生成输出中,所有内容都配置为生成 pdf 作为输出。

在此处输入图像描述

我关注了这篇出色的帖子https://www.r-bloggers.com/processing-rmarkdown-documents-with-eclipse-and-statet/这对我帮助很大。

现在我可以通过单击 Eclipse 中的 render_markdown 按钮运行并获取

rmarkdown::render(input= "C:\\workspace\\p\\example_scripts\\testmd.Rmd", output_format= "pdf_document", output_file= "C:\\workspace\\p\\example_scripts\\testmd.pdf", encoding= "UTF-8")


processing file: testmd.Rmd
  |......................                                           |  33%
  ordinary text without R code

  |...........................................                      |  67%
label: unnamed-chunk-1
  |.................................................................| 100%
  ordinary text without R code


output file: testmd.knit.md

"C:/Users/me/AppData/Local/Pandoc/pandoc" +RTS -K512m -RTS testmd.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pandoc2806c2b6c59.pdf --template "C:\PROGRA~1\R\R-34~1.2\library\RMARKD~1\rmd\latex\DEFAUL~3.TEX" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" 

Output created: C:\workspace\p\example_scripts\testmd.pdf
于 2017-10-28T08:51:35.060 回答