[Tex/LaTex] Sweave: run a bat file in Windows 7

miktexsweavewindows

When I run a RNW file inside RStudio compilation is working. But when I try to run the same RNW file through a BAT file, compilation is not working. I am a Win 7 user, using MixTex…

Actually my aim is to work on a LaTeX editor like TeXMaker and compile a RNW files through a BAT file. After compilation I would like to get a PDF file…

On Rstudio I create a file named "main.Rnw" then I simply press on "Compile PDF" then I get a nice PDF output.

But on texmaker I created the same "main.Rnw" but when I create my a "run.bat" file on the same directory, nothing is working. My "run.bat" contains:

Sweave main.Rnw

I don't find a solution to my issue…


My "main.Rnw" code:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{lipsum} % for lorem ipsum text
\begin{document}
\title{Test sweave}
\maketitle

%fake text
\lipsum[1]

%just a boxplot text
<<fig=TRUE>>=
test <- c(-10,8,6,4,2,0,2,4,6,8,10)
boxplot(test)
@

%fake text
\lipsum[2]

\end{document}

enter image description here

Best Answer

I do not think there is such a thing as Sweave.exe in R under Windows. There is only R CMD Sweave.

The other way is to define a custom command as illustrated here: http://yihui.name/knitr/demo/editors/ (it is using knitr instead of Sweave, but the basic idea is the same)