Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to colorize comments/code in Sweave?

Tags:

r

sweave

I found that I can keep comments in the Sweave code chunks by specifying keep.source in the \SweaveOpts, but is there a way to make the code listing look nice like with grayed out comments?

like image 341
Andrew Redd Avatar asked Sep 02 '11 01:09

Andrew Redd


2 Answers

There are several options illustrated at Vanderbilt University's Department of Biostatistics sweave templates site: http://biostat.mc.vanderbilt.edu/wiki/Main/SweaveTemplate

I found the Sweavel style to be the most flexible.

The highlight package is another option.

like image 133
kmm Avatar answered Oct 17 '22 17:10

kmm


the pgfSweave package can produce syntax-highlighted code.

like image 44
Ben Bolker Avatar answered Oct 17 '22 17:10

Ben Bolker