Question

I am writing a document with knitr (Rnw to be processed to PDF) that will be printed in black&white. I still would like the code chunks to have syntax highlighting.

Is it possible, and how, to modify default syntax highlighting colors to use some shades of gray etc.?

PS. I do not want to switch to LaTeX 'listings' package.

Was it helpful?

Solution

As suggested by @Roland, knitr themes (?knit_theme) do the job. In particular, the print theme seems to suite black-and-white printing best. A gallery of all built-in knitr themes can be found here http://animation.r-forge.r-project.org/knitr/

In particular, to set print theme in my Rnw document put this in the initial R code chunk:

opts_knit$set( out.format="latex" )
knit_theme$set("print")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top