I use emacs/ESS to write LaTeX documents that embed R code. One of the nice features of emacs is the preview-latex package (part of AucTeX), which typesets LaTeX math directly in the emacs frame. However, preview-latex chokes when it encounters R code chunks, meaning I cannot preview LaTeX math in Rnw files.
My goal is to define a LaTeX environment, Rcode, with the following properties: