Reputation: 56
I am preparing a manuscript for publication and need a way to change (remove actually) the background color of code chunks in my PDF file (generated through Latex).
Reproducible example:
---
title: TestFile
output:
pdf_document: null
---
```{r,echo=TRUE}
test=c(1,2,3) print(test)
```
```{r,echo=TRUE}
test=c(1,2,3)
print(test)
Upvotes: 2
Views: 1769
Reputation: 56
I think I've found a solution. This is a purely latex solution, but it does the trick for what I need (which is outputting to PDF via latex) using the package xcolor. [PDF output] https://i.sstatic.net/yEADg.png
Reproducible Example:
---
title: TestFile
output:
pdf_document: null
header-includes: \usepackage{xcolor}
---
\definecolor{shadecolor}{RGB}{255,255,255}
```{r,echo=TRUE}
test=c(1,2,3)
print(test)
```
Upvotes: 2
Reputation: 135
Another option, is to use Pandoc Syntax Highlighting styles, which is very simple and has very nice options. Compared to the LaTeX option you used, this is perhaps less flexible, but has the advantage of changing not only the background of code chunks, but also the font colour.
To do this, you only have to add the highlight style you want to the YAML. For example, adding the zenburn highlight:
output:
pdf_document:
highlight: zenburn
Will produce this:
Instead of this:
I hope this helps, but let me know if not.
Upvotes: 2