How to achieve black and white syntax highlighting in PDF files created using knitr

I am writing a document with knitr (Rnw for processing in PDF) that will be printed in black. I would still like the code snippets to have syntax highlighting.

Is it possible, and how to change the default syntax fonts to use grayscale, etc.?

PS. I do not want to switch to the LaTeX ad package.

+7
r knitr latex
source share
1 answer

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

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

 opts_knit$set( out.format="latex" ) knit_theme$set("print") 
+4
source share

All Articles