[R] Colors in Sweave

Stephen Tucker brown_emu at yahoo.com
Sun Jul 27 21:10:21 CEST 2008

Hi list,

I was using Sweave and was wondering if anyone has had any luck changing the font colors of the code chunks. For instance, in my .Rnw preample I tried including:


which works in the sense that colors do show up in the processed pdf document, but extra spaces in between the input and output code chunks appear (which is not the case when colors are not specified), resulting in a long document with many blank lines.

Alternatively, in the resulting tex document I replaced all instances of \begin{Sinput}... \end{Sinput} with {\color{midnightblue}\begin{Sinput} ... \end{Sinput}} and darkred for Soutput and so on. When I do this, I get the following error message:

=== LaTeX excerpt ===
> ISOdatetime(1970, 1, 1, 0, 0, 0, "") - ISOdatetime(1970, 1, 1, 
+     0, 0, 0, "GMT")
Time difference of 8 hours

=== error message ===
! FancyVerb Error:
  Extraneous input `}\end{}' between \end{Sinput} and line end
\FV at Error ... {FancyVerb Error:
\space \space #1
l.13 \end{Sinput}}

I guess I don't know enough of the Schunk/Sinput/Soutput definitions to toy with it and was wondering if anyone had tried something similar. 



More information about the R-help mailing list