Issue
When knitting R code chunks to HTML in R Markdown, it's possible to alter certain visual elements by setting chunk options (figure height, displaying messages/warnings, etc.). I'm curious about whether there's a chunk option to remove the gray border around the box that the code returns into. For example, if I run the following:
```{r}
head(mtcars)
```
The code appears on a light gray background with a gray border, and the return appears on a white background with a gray border. Is there a way to remove the gray border around the code, the return, or both?
Thank you for the help.
Solution
You can add
<style>
pre {
border: 0;
}
</style>
somewhere in your .Rmd
outside of a code chunk. This will give you this.
To elaborate on why this works, both the code block and return are wrapped in a <pre>
tag when knitted, which is for pre-formatted text. You can verify this by simply viewing the page source for a knitted Rmarkdown page. So, using CSS, you can specify no border for these tags.
Answered By - Justin Singh-M.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.