I have been using knitr for a while to generate some quite complex PDFs. On one of my machines knit2pdf started to cause me issues, and I cannot figure out why. knit2pdf continues to work on my other machines.
My typical setup is:
test.Rnw
\documentclass{article}
\begin{document}
This is a test
\end{document}
R Command
knit2pdf(input = "latex/test.Rnw", output = 'latex/knit2pdf', clean = TRUE)
however, I receive the following error message:
knit2pdf(input = "latex/test2.Rnw", output = 'latex/knit2pdf', clean = TRUE)
processing file: latex/test2.Rnw
|.................................................................| 100% ordinary text without R codeoutput file: latex/knit2pdf
[1] "latex/knit2pdf.pdf" Warning message: running command '"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\texify.exe" --quiet --pdf "knit2pdf" --max-iterations=20 -I "C:/PROGRA~1/R/R-33~1.2/share/texmf/tex/latex" -I "C:/PROGRA~1/R/R-33~1.2/share/texmf/bibtex/bst"' had status 1
and the contents of knit2pdf.pdf is:
article[]graphicx[]color fgcolorrgb0.345, 0.345, 0.345 [1][rgb]0.686,0.059,0.5691[1][rgb]0.192,0.494,0.81[1][rgb]0.678,0.584,0.6861[1][rgb]0,0,01[1][rgb]0.345,0.345,0.3451[1][rgb]0.1framed kframetotalleftmargin@ setminipage @end@of@kframe shadecolorrgb.97, .97, .97 messagecolorrgb0, 0, 0 warningcolorrgb1, 0, 1 errorcolorrgb1, 0, 0 knitrout alltt upquote.styupquote document This is a test
I have managed to get the output I require (using the example from How to create multiple PDFs with different content from a single data frame?), but with significantly more work than just calling knit2pdf.
filename <- "texi2pdf"
f_tex <- paste0("latex/", filename, ".tex")
f_pdf <- paste0("latex/", filename, ".pdf")
knit("latex/test.Rnw", output = f_tex)
tools::texi2pdf(file = f_tex, clean = TRUE, quiet = FALSE)
file.rename(from = paste0(filename, ".pdf"), to = f_pdf)
And in this case the PDF output (texi2pdf.pdf) is simply, and correctly,
This is a test
I am running R 3.3.2 and all packages are up to date.