In a previous question knitr2pdf eclipse : how to configure?, I tried to set up eclipse to work with knitr2pdf, Yihui Xie was kind enough to give me a very prompt answer . Now I'm stuck one step further.
here is my file
---
title: "knit2pdf test"
author: "cedric"
date: "27/10/2017"
output: pdf_document
---
```{r}
plot(rnorm(1:10))
```
When running this file, I get the following answer
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
I've tried to find questions reporting a similar problem, Using knit2pdf with Rmd files the answer was to try to use render instead of knit2pdf which is not what I want. This is not a problem with eclipse, but me failing to run the knit2pdf properly. Manually running the command knit2pdf("test_knit2pdf.Rmd") gets the same error. Again, maybe someone will have run into a similar problem and will be able to help me, is my file badly formed, have I missed something ?
To process a Rmd document using rmarkdown::render() the following steps are necessary
Install pandoc Edit windows path, system environment variables, copy path to pandoc which is located there C:\Users\me\AppData\Local\Pandoc
Go to eclipse, Run > External Tools > External Tools Configurations Click on wikitext + R document processing In the dropdown menu, topright, named load Preset example, click the PDF using Rmarkdown, single steps. In 2/ produce output everything is configured to produce pdf as output.
I followed this excellent post https://www.r-bloggers.com/processing-rmarkdown-documents-with-eclipse-and-statet/ which helped me a lot.
Now I can run by clicking on the render_markdown button in eclipse and get
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