pdfr-markdownchunksitalic

Remove italics (# comments) in Rmarkdown code chunks in pdf


I am looking to find a way to remove the italicized comments in Rmarkdown code chunks

---
output:
  pdf_document:
    keep_tex: true
    number_section: no
---

```{r}
# This is a test.
```

And the results.

enter image description here

Is there a way to make it not italicized?

Thank you,


Solution

  • Several code highlight styles do not italicize the comments, including haddock, kate, and zenburn. See here for a preview of available styles.

    ---
    output:
      pdf_document:
        keep_tex: true
        number_section: no
        highlight: kate
    ---
    

    If you need to create a custom syntax highlighting theme, instructions in the pandoc manual are here.