TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I've tried to configue Sweave on Texmaker following these instructions: http://arts.uwaterloo.ca/~tmparker/722/hw/Setup_Sweave_in_Texmaker.pdf

When I go to run this example:


\title{Sweave Example 1}
\author{Friedrich Leisch}



In this example we embed parts of the examples from the
\texttt{kruskal.test} help page into a \LaTeX{} document:

kruskal.test(Ozone ~ Month, data = airquality)
which shows that the location parameter of the Ozone 
distribution varies significantly from month to month. Finally we
include a boxplot of the data:

boxplot(Ozone ~ Month, data = airquality)


saving it as a .Rnw file and clicking Tools -> R Sweave, the message log at the bottom of Texmaker 'Error: could not start the command'. I've saved it in a directory with no spaces and followed the above link setup exactly.

Let me know if more info is required.

share|improve this question
If you have the message "could not start the command", it means that the syntax of the command is wrong or the executable launched by the command doesn’t exist or the executable is not in the windows path (or you have not the permission to launch it). This message is displayed when the system can't launch the command (and returns an error). – user27168 Oct 7 '13 at 17:46
Is there a way to amend this so it can run? I'm pretty sure the above syntax is correct. – hgeop Oct 7 '13 at 19:59
@hgeop may be R Sweave executable path is not set in Configure TeXmaker-->Commands to let TeXmaker know the executable properly. – texenthusiast Oct 10 '13 at 7:16
up vote 3 down vote accepted

I had the same problem described above and even following the instructions cited, couldn't solve the problem. So I tried to use knitr instead Sweave and everythig is fine now. Here is what I did:

  1. Install the package knitr on R;

  2. On TeXmaker > User > User commands > Edit User commands: choose command 1;

  3. Configure the user command 1 as follow:

    • On menu item type: knitr

    • On command, type (with the quotes):

      Rscript.exe -e "knitr::knit2pdf('%.Rnw')" for Texmaker on Windows

      Rscript -e "knitr::knit2pdf('%.Rnw')" for Texmaker on Ubuntu

    • Click OK

  4. Open the .Rnw file

  5. Choose 1:knitr on compile options, then compile the file

  6. Run PDFLaTeX on the file.

  7. Open the PDF.

share|improve this answer
Thanks for this. I've managed to implement both sweave and knitr now – hgeop Nov 20 '13 at 20:33
How do you embed/mix this code from a rnw file with other code on a tex file? – skan Nov 1 '15 at 1:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.