4

When I knit the Rmarkdown template directly in the RStudio IDE, it creates the desired PDF exactly. However, when I try to knit the document using rmarkdown::render(), I get an error that I can't figure out. I've installed the latest version of Rmarkdown and of MikTex. Below are the details:

The Rmarkdown template I'm using is below. Thanks for any help you can give.

---
title: "Test"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r cars}
summary(cars)
```

## Including Plots

You can also embed plots, for example:

```{r pressure, echo=FALSE}
plot(pressure)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

When I attempt to knit this using rmarkdown::render(), I get the following output:

> rmarkdown::render("I:/test.Rmd")

processing file: test.Rmd
  |.........                                                        |  14%
  ordinary text without R code

  |...................                                              |  29%
label: setup (with options) 
List of 1
 $ include: logi FALSE

  |............................                                     |  43%
  ordinary text without R code

  |.....................................                            |  57%
label: cars
  |..............................................                   |  71%
  ordinary text without R code

  |........................................................         |  86%
label: pressure (with options) 
List of 1
 $ echo: logi FALSE

  |.................................................................| 100%
  ordinary text without R code

output file: test.knit.md

"C:/PROGRA~2/Pandoc/pandoc" +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test.tex --template "C:\Users\sshewfelt.INGENUITY\Documents\R\win-library\3.4\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --pdf-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" 
Error: Failed to compile test.tex.
In addition: Warning message:
running command '"pdflatex" -halt-on-error -interaction=batchmode "test.tex"' had status 127 

And here is my Session Info:

> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.4.3   backports_1.1.2  magrittr_1.5     rprojroot_1.3-2  htmltools_0.3.6  tools_3.4.3      yaml_2.1.16      tinytex_0.3     
 [9] Rcpp_0.12.15     stringi_1.1.6    rmarkdown_1.8.10 knitr_1.19       stringr_1.2.0    digest_0.6.15    evaluate_0.10.1 
sshew
  • 41
  • 2
  • `"status 127"` on windows often means the executable was not found in the `PATH`. What does`Sys.which("pdflatex")` give you? (If `""`, then the problem is that `MiKTeX` or windows-`TeXLive` is not in the path. RStudio is likely fixing this for itself when it calls `pandoc` and friends.) – r2evans Feb 20 '18 at 19:16
  • rEvans - you're correct that I get Sys.which("pdflatex") returns "". But when I run Sys.getenv("PATH"), I see MikTex in the proper path ("C:\\Users\\sshewfelt.INGENUITY\\AppData\\Local\\Programs\\MiKTeX 2.9\\miktex\\bin\\x64\"). Any suggestions? – sshew Feb 20 '18 at 19:54
  • 2
    If you don't mind, uninstall MiKTeX, and test TinyTeX instead: https://yihui.name/tinytex/ (You will need to restart R/RStudio) – Yihui Xie Feb 21 '18 at 03:28
  • 1
    That worked perfectly. Thank you very much Yihui! – sshew Feb 21 '18 at 04:21
  • 1
    Although I have no idea why MiKTeX didn't work for you, I'm glad that TinyTeX worked anyway. – Yihui Xie Feb 21 '18 at 14:44

0 Answers0