[Tex/LaTex] Howto: Set up knitr (*.Rnw compilation) from in TexStudio


How do I set up TeXstudio to compile xxx.Rnw files?

I am using the TeX-Editor TeXstudio 2.7, on Windows 7, and R 3.01 64-bit.

I would like to write a xxx.Rnw-file in TeXstudio and then from TeXstudio automatically (a) call R, (b) compile the Rnw to tex using knitr, (c) compile the pdf, (d) view the Pdf.

I found these pieces of information regarding the issue

Using the configuration "Rscript -e "library(knitr); knit2pdf('"test"Rnw')" for the user-defined compilatin command in TeXstudio, I get the error message that the command could not be started if I try to compile a sample file.

I would be glad if somebody made this work and is willing to share the configuration of the TeXstudio commands. Thanks a lot in advance!

Best Answer

I have solved it.

The command I use in the user-defined commands for compiling and displaying a Rnw-file in my own pdf-viewer is :

"C:/whateverYourPathToRonYourMachineIs/R-3.0.1/bin/Rscript.exe" -e "library(knitr); knit2pdf('%.Rnw')" | pdflatex -synctex=1 -interaction=nonstopmode %.tex | "C:/whateverYourPathToYourPDFViewerOnYourMachineIs/Foxit Reader.exe" "?am.pdf"

Screenshot of the TeXstudio configuration