# [ESS] Problems compiling latex during Sweave process

Joan-Josep Vallbé vallbe at ub.edu
Fri Jan 7 22:10:54 CET 2011

Dear all,

I'm runing R 2.12.1 and Emacs 23.2 under Mac OS X 10.6.5 and I'm trying to use Sweave in order to draft some reports. While I'm able to Sweave my .Snw file using the command M-n s, an error message arises when I further try M-n l and M-n- P in order to compile latex on the results and have a pdf from it, delivering first the following message: "ess-swv-latex: Searching for program: no such file or directory, latex".

If I instead open the .tex file created by Sweaving and compile it (C-c C-c), then it works, but I cannot carry out the intended whole process M-n s, M-n l, and M-n P under ESS. The test file is the following:

####################################################
\documentclass[a4paper]{article}
\title{Tests with Sweave}
\author{}
\begin{document}
\maketitle
This is a test.
<<>>=

data(airquality)
@
We include a plot of the data.
\begin{center}

<<fig =TRUE , echo =FALSE >>=
plot(airquality$Ozone,airquality$Solar,pch=20,log="xy")
@
\end{center}
\end{document}
#####################################################

I haven't been able to find this same problem already solved, so I guess the problem is too obvious and might have to do with the ess-swv.el file. However, I'm not familiar with lisp and don't know what to change. Following some advice found googling around, I added the following code to my .emacs file; I've tried to remove it (except (require 'ess-site)) and try again, without any success:

(require 'ess-site)

(setq TeX-file-extensions
'("Snw" "Rnw" "nw" "tex" "sty" "cls" "ltx" "texi" "texinfo"))
(lambda ()
(add-to-list 'TeX-expand-list '("%rnw" file "Rnw" t) t)
'("Stangle" "R CMD Stangle %rnw"
TeX-run-command nil (latex-mode) :help "Run Stangle") t)
'("Sweave" "R CMD Sweave %rnw"
TeX-run-command nil (latex-mode) :help "Run Sweave") t)