I would like to have a certain code chunk highlighted in a different color (e.g. red) to indicate that it is bad practice. If I was using .Rnw, I could add the
I found the following way to color (code) chunks in Rmarkdown documents that I knit to PDF:
Use a pandoc highlighting scheme as a basis
pandoc --print-highlight-style pygments > my.theme
Then edit my.theme by using a regex to set all
"text-color": null
Then, you can change this property to any color you like (this one here is lightgrey)
"background-color": "#f8f8f8"
In the YAML of your .Rmd document under "pdf_document", put the following
pandoc_args: --highlight-style=my.theme
For my use case this is all I need.