[Tex/LaTex] how to colorize syntax using R + Sweave

beamerlistingssweave

I'm writing a LaTeX document using Sweave (a Beamer presentation, really), which weaves R code and LaTeX. Is there a way to make my chunks of code and its output highlighted? I could use listings package but that would mean I would have to rummage through the .tex file and wrap all Schunks so I'm looking for perhaps more elegant solutions if currently available.

Best Answer

The SweaveListingUtils package contains additions to Sweave that enables pretty-printing input and output using the LaTeX listings package. Example usage can be found in the vignette.

Another alternative is to override the Schunk, Sinput and Soutput environments using \renewenvironment so that they do whatever you want them to.