I am making a xaringan presentation and I am trying to show my chunk options in R Markdown, and I need that it appears in a gray square.
Like this image:
But I just get my code without that nice gray square:
And of course I don't know how to put the highlights in this kind of code chunks. If somebody knows how to do it, I will really appreciate it.
This is the code I wrote in order to get the chunk without the square:
```{r echo=FALSE, comment = NA}
cat("````
```{r, echo = TRUE, eval=TRUE, out.width = '50%', fig.align = 'center'}`r ''`
url <- 'https://media.springernature.com/full/springer-static/\nimage/art:10.1186/s13059-020-02088-y/MediaObjects/13059_2020_2088_Fig1_HTML.png'
knitr::include_graphics(url)
```\n````")
```
CodePudding user response:
Following the example in the "Ninja" presentation template, you can produce "raw chunks" by using the markdown
formatting with some tricks:
# Test
````markdown
`r ''````{r, echo = TRUE, eval=TRUE, out.width = '50%', fig.align = 'center'}
url <- 'https://media.springernature.com/full/springer-static/\nimage/art:10.1186/s13059-020-02088-y/MediaObjects/13059_2020_2088_Fig1_HTML.png'
knitr::include_graphics(url) #<<
```
````
Output:
```{r, echo = TRUE, eval=TRUE, out.width = '50%', fig.align = 'center'}
url <- 'https://media.springernature.com/full/springer-static/\nimage/art:10.1186/s13059-020-02088-y/MediaObjects/13059_2020_2088_Fig1_HTML.png'
knitr::include_graphics(url) #<<
```
Line highlighting is done with #<<
. For this, you need to enable the highlighting in the yaml header (again, I've taken the default from the Ninja template):
output:
xaringan::moon_reader:
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false