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.
Creating shades of black color with primary colors Red, blue and yellow are the three primary colors for what colors make black paint when mixed together. Simply mix equal amounts of red, blue, and yellow together and you will get a nice black.
In science, black is the absence of light. And colour is a phenomenon of light. But a black object or black images printed on white paper are made from pigment, not light. So artists must use their darkest colour of paint to approximate black.
Darker shades of blue such as navy, indigo, and cobalt are surprisingly chic paired with black, adding subtle depth and nuance.
Mix Brown with Blue = Black Ensure that close to half of the mixture is blue. Add a dab of burnt umber near your blue dab, and then swirl the two colors gently to yield black. You can adjust the amount of either color to create your desired shade of black.
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With