RStudio R Markdown Notebook: Change colour of chunk background highlight option in Source panel (not Knitted document)
If I've understood you correctly...
It's possible. I did it with the Viridis theme on Github. On Github, where this theme is found, the authors wrote that you need to have certain things, save the theme in a specific place, all that jazz. I didn't do any of that; I haven't had any problems.
Should you choose to do so, copy the raw script from Viridis.rstheme and use a script editor like Atom or Rstudio. Save the file where you want it and name it exactly as the authors did (it has to match the script's content).
Line 199 is where you go to change the background chunk color for RMarkdown documents. I threw in one of the Viridis purple colors so that the contrast would be vibrant. (I used #481567FF.)
It's bright compared to the original contrast.
change R chunk background color in bookdown gitbook
Thanks to @cderv for pointing me to the right direction. just needed to add !important
to the css styles i want to prioritize:
.Rchunk {
background-color: #f2dede !important;
font-weight: bolder;
color: red !important;
}
.Rout {
background-color: #d9edf7 !important;
font-weight: bolder;
color: blue !important;
}
How do I change the entire background color in an RMarkdown HTML Document?
Just add custom CSS to your document. You can place this line at the top (after the yaml part):
1. Inline Style
<body style="background-color:grey;">
2. Embedded Style Sheet
<style>
body { background-color: grey; }
pre, pre:not([class]) { background-color: red; }
</style>
xaringan: Changing code background for specific chunks
This was actually something I was trying to work out a few days ago.
Here's one workaround.
First in your css file or either place the following in xaringan
Rmarkdown file:
```{css, echo=F}
.code-bg-red .remark-code, .code-bg-red .remark-code * {
background-color:red!important;
}
```
and then wrap the code chunk like
.code-bg-red[
```{r}
lm(speed ~ dist, cars)
```
]
then your output will be:
You can, of course, change the red to other colors to suit your needs.
How to keep default R markdown colors when knitting to html?
Use highlight: textmate
in the YAML header.
For instance,
---
title: "Test"
output:
html_document:
highlight: textmate
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Test
```{r}
library("tidyverse")
```
knits to
Further reading
R Markdown: The Definitive Guide
Related Topics
Order of Prioritization When Using Multiple Contradictory CSS Files
Bootstrap Change Order of Columns
CSS Get Height of Screen Resolution
CSS Equivalent of the "If" Statement
Styling Mat-Select in Angular Material
IE7, IE8 Support for CSS3 Media Query
Using Primefaces with Bootstrap Causes Changes in Padding/Sizing/Borders
How to Control Number of Items Per Row Using Media Queries in Flexbox
How to Use a CSS Wildcard in the Middle of an Attribute Selector
How to Reset a CSS Variable (Aka Custom Properties) and Use the Fallback One
Google Warning: Resource Interpreted as Font But Transferred with Mime Type Application/Octet-Stream
Css3 ::Selection Behaves Differently in Ff & Chrome
Background-Size with Svg Squished in IE9-10