[ESS] Sweave helper function
Andrew Robinson
A.Robinson at ms.unimelb.edu.au
Thu Nov 1 16:47:54 CET 2007
On Thu, Nov 01, 2007 at 08:52:28AM -0500, Kevin Wright wrote:
> I don't think it is overkill; I have my own simple version:
> ...
Thanks very much, Kevin. I've adapted your code a little to unify the
plot labels. I don't mind typing that in as an argument instead of
reading it from a region, so this solves my problem equally well!
(defun ess-insert-Sweave-figure-labelled ()
"Insert labelled Sweave figure into the buffer at next line."
(interactive)
(setq seed (read-string "Seed name: "))
;; insert initial code swatch
(insert "\n<<label=fig-" seed ", include=FALSE>>=\n\n@\n\n")
;; insert figure environment
(insert "\\begin{figure}[!h]\n\\centering")
;; insert Sweave figure header
(insert "<<fig=TRUE, echo=FALSE, width=6, height=6, label=" seed ">>=\n")
;; call code swatch
(insert "<<fig-" seed ">>\n@\n")
;; finish figure
(insert "\\caption[]{}\n\\label{fig:" seed "}\n\\end{figure}")
)
(define-key noweb-minor-mode-map "\M-nf" 'ess-insert-Sweave-figure-labelled)
Best wishes,
Andrew
--
Andrew Robinson
Department of Mathematics and Statistics Tel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/
More information about the ESS-help
mailing list