0
votes

I'm hoping someone can point me to the internal setting that can fix my issue with compiling tex docs from R.

My issues is that texi2pdf and knit2pdf throw warnings and do not generate a pdf.

I can get Rnw files to compile using the "Compile pdf" button in RStudio, I can knit rnw files into text files, and I can get my tex files to compile into pdf using TeXnicCenter, but I can't get the texi2pdf or knit2pdf functions to work in R.

In Windows 7 on one machine with TexLive installed and on another machine with MikTex 2.9 installed, when I run the following:

library(knitr)
f = system.file("examples", "knitr-minimal.Rnw", package = "knitr")
knit(f)  # compile to tex
texi2pdf(gsub('Rnw', 'tex', f))

the first part works (rnw->tex), but the texi2pdf (tex->pdf) results in:

Warning message:
running command '"C:\PROGRA~2\MIKTEX~1.9\miktex\bin\texify.exe" --quiet --pdf 
"C:/Program Files/R/R-3.3.3/library/knitr/examples/knitr-minimal.tex" --max-
iterations=20 -I "C:/PROGRA~1/R/R-33~1.3/share/texmf/tex/latex" -I 
"C:/PROGRA~1/R/R-33~1.3/share/texmf/bibtex/bst"' had status 1 

The same is true if I run knit2pdf(f), I get the same warning message + a pop up "pdflatex.EXE has stopped working".

One other thing I don't understand is that I have MikTex 2.9 in my path, but the warning message references MikTex 1.9, which is not installed on my machine and is not in the path.

2
That's a bug imho. I also get the output of Sys.which("texify") to be the exact same path, and there's no distribution to be found there.Joris Meys
Do you think that's what's causing the compilation problems? I don't understand the interworkings of these pieces, is that a bug with r? knitr? tools?fishgal64
It's not a bug, and it's not looking for MikTex 1.9. I was horribly wrong about that. r.789695.n4.nabble.com/…Joris Meys
The Same error is happening to me. How did you fix it?Tiago Bruno

2 Answers

0
votes

This isn't so much a fix as a work around...

library(knitr)
setwd(system.file("examples", package = "knitr"))
knit("knitr-minimal.Rnw")  # compile to tex
system('pdflatex knitr-minimal.tex')
0
votes

This happened to me today, and it seems it was because MikTex 2.9 was installed under my User account. R is also installed under my User account. Here is what worked for me:

  1. Uninstall MikTex and reinstall it under Program files. Update MikTex from its console.
  2. Add "C:\Program Files\MiKTeX 2.9\miktex\bin\x64" to Windows PATH (delete the old MikTex path).
  3. Restart you computer
  4. Uninstall and reinstall the knitr package (that might not be necessary).