Emacs: AucTeX + Rubber + Sweave

May 30, 2009

(This article was first published on Super Nerdy Cool » R, and kindly contributed to R-bloggers)

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:

;;following is AucTeX with Sweave -- works
(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
(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 a *.Rnw file is open, I can do C-c C-c, select Sweave. Then repeat, select RubberSweave (or LatexSweave).

To leave a comment for the author, please follow the link and comment on their blog: Super Nerdy Cool » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , , , , ,

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)