Emacs: AucTeX + Rubber + Sweave

I got rubber to work with AucTeX and Sweave (Rnw) files with the help of this.

Basically, combined with my other stuff, I tweaked my .emacs file to look like:

<pre class="src src-sh">;;following is AucTeX with Sweave -- works

;;http://andreas.kiermeier.googlepages.com/essmaterials (setq TeX-file-extensions ‘(“Snw” “Rnw” “nw” “tex” “sty” “cls” “ltx” “texi” “texinfo”)) (add-to-list ‘auto-mode-alist ‘(“\.Rnw\'” . Rnw-mode)) (add-to-list ‘auto-mode-alist ‘(“\.Snw\'” . Snw-mode)) (add-hook ‘Rnw-mode-hook (lambda () (add-to-list ‘TeX-command-list (“Sweave” “R CMD Sweave %s” TeX-run-command nil (latex-mode) :help “Run Sweave”) t) (add-to-list ‘TeX-command-list (“LatexSweave” “%l %(mode) %s” TeX-run-TeX nil (latex-mode) :help “Run Latex after Sweave”) t) ;; following 3 lines for rubber, taken from same site as next paragraph, http://www.nabble.com/sweave-and-auctex-td23492805.html, xpdf to open (add-to-list ‘TeX-command-list (“RubberSweave” “rubber -d %s && open ‘%s.pdf'” TeX-run-command nil t) t) (setq TeX-command-default “Sweave”)))

;; AucTeX with rubber ;;http://www.nabble.com/sweave-and-auctex-td23492805.html (eval-after-load “tex” ‘(add-to-list ‘TeX-command-list ;;‘(“Rubber” “rubber -d %t && xpdf ‘%s.pdf‘” TeX-run-command nil t) t)) ;; change by vinh (“Rubber” “rubber -d %t && open ‘%s.pdf'” TeX-run-command nil t) t))

Now, when an Rnw file is open, I can press C-c C-c, select Sweave. Then repeat, select RubberSweave (or LatexSweave).

rubber – latex’ing multiple times to get the final product

Rubber is a Python script that assists with the compilation of LaTeX documents. It is useful when you use bibtex for bibliographies because multiple latex and bibtex commands are needed to be executed for the document to be generated. With rubber, I can issue a single command and the necessary commands will be executed automatically:

<pre class="src src-sh">rubber -d myfile.tex <span style="color: #ff4500;">## </span><span style="color: #ff4500;">-d or --pdf for pdflatex</span>

If you are making a pdf file, it will convert all eps files into pdf.

The next thing to do is to get rubber working with AucTeX and ESS/Sweave. Check out the later posts on this thread.