Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rmarkdown - how to remove grey background on output

Tags:

r-markdown

I am experiencing a slightly irritating problem, which is that I am not able to remove the grey text from output (please see picture below).

I've searched for a solution, but is restricted by my lack of knowledge about the proper terms, and therefore I am not able to find any solutions.

I know this can be somehow bypassed by using only one "`", yet I need the triple "```" in order to run my code interpreting rows.

The grey background on output

---
title: "Untitled"
output: word_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r, echo=FALSE}
hej <- ("test")
print(hej)
```
like image 585
Nikolaj Avatar asked Sep 10 '25 14:09

Nikolaj


1 Answers

You might simply want to override the grey highlighting in the YAML header as follows:

---
title: "Untitled"
output: 
   word_document:
      highlight: NULL
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

Now if you want to get rid of the "##" and the line-numbers, tell knitr to handle texts as-is, and use cat():

```{r textfoo, echo = FALSE, results = 'asis'}
hej <- ("test")
cat(hej)
```

Et voilà:

enter image description here

like image 161
jay.sf Avatar answered Sep 13 '25 11:09

jay.sf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!