Sunday, August 9, 2009

Emacs and Sage

I have been unhappy with my current practice of cut and pasting statistical results etc. from MATLAB or Python output into LaTeX for publishing. Changes to code and recalculations lead to an endless possibility for error. So I have been working on using SageTex as an interface LaTeX. As a small step that might be helpful to others by adding the commands at the end of this post to my .emacs file (actually I use Aquamacs) I can type C-c C-c sage to run Sage on the appropriate segments of my LaTeX file (see SageTeX) for more detail. I will post in future about my experience using SageTeX for getting closer to the goal of reproducible research (SageTeX also has a MATLAB interface so I plan to use it for interfacing with MATLAB too).

;; SageTeX setup
;; This adds the command sage when in LaTeX mode (to invoke type C-C C-c sage)
(eval-after-load "tex"
'(setq TeX-command-list
(append TeX-command-list
(list "sage" "sage %s.sage" 'TeX-run-command nil t :help "Run SAGE on the SAGE file corresponding to this LaTeX file (run latex first).")))))

No comments: