Emacs: AucTeX + Rubber + Sweave
ESS
Emacs
LaTeX
R
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
;;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
).