1

Which tex package does Rmarkdown use by default to implement syntax highlighting and how to change the highlighting colors?

I have written a style file which i use as a template for my beamer presentations written in Rmarkdown.

When I include a code chunk, e.g:


g = ggplot(mtcars, aes(x=wt, y=mpg, color=cyl, size=cyl)) +
      geom_point() +
      theme(legend.position="none") 

This is visible in the knitted pdf as a code chunk as it apparently draws on some RMD defaults not specified in my style file.

By adding the following to the style file, I was able to change the background color of the code chunk and the font size:


\let\oldShaded\Shaded
\let\endoldShaded\endShaded
\renewenvironment{Shaded}{\footnotesize\oldShaded}{\endoldShaded}

\definecolor{shadecolor}{RGB}{      221,    219,    217}

Now I would also like to change the syntax highlighting color to better match the overall style of my template.

3
  • Welcome to TeX.SX! Please also read the welcome guide and provide a MWE. That makes it easier for us to help you.
    – Steradiant
    May 28, 2020 at 13:29
  • Maybe related stackoverflow.com/questions/32857212/… ?
    – Marijn
    May 28, 2020 at 13:41
  • Hi, this question aims at incorporating code chunks from other languages (stan, python, etc.) in Rmd which is unfortunately not what I am looking for (I want to change the color of r syntax highlighting which must be somehow supplied by some default/hidden Rmarkdown/latex style file). A minimal working example is difficult to provide. One could open a default beamer template in rstudio and try to change the color of the code chunks. But to do this, one has to know what is the default latex environment/package given by rmarkdown to highlight syntax - which is precisely what im looking for.
    – persephone
    May 28, 2020 at 16:46

1 Answer 1

1

mwe

---
output:
  beamer_presentation:
    highlight: espresso
---

# foo

```{r,eval=FALSE}
g = ggplot(mtcars, aes(x=wt, y=mpg, 
      color=cyl, size=cyl)) +
      geom_point() +
      theme(legend.position="none")
```

For more styles: `pandoc --list-highlight-styles`

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .