3
$\begingroup$

I would like to change the background color of the code cell style in my private stylesheet.

I can change the background of the text cell style for example but not the code cell style in my private stylesheet.

I can change the background color of a single code cell in a notebook but I want all code cells to have the same background automatically.

I have been trying to do this via a front-end cell execution as a fix but using the different questions here I did not find a way that works for the code cell style.

$\endgroup$

1 Answer 1

6
$\begingroup$

The simplest, easiest way is to set the background color against the InitializationCell style.

Cell[StyleData["InitializationCell"],Background->RGBColor[0.87, 0.94, 1]]

$\endgroup$
3
  • $\begingroup$ Thank you very much for your response. I have seen this usage of cell often when trying to find an answer but It is unclear to me what it does or how to use it. If I just evaluate that command seemingly nothing happens. $\endgroup$ Jun 22 at 21:24
  • $\begingroup$ @userrandrand, that is a style data cell. File > New and then Format> Edit stylesheet, paste the above into it, select Yes when the Interpret dialog comes up, and then close the stylesheet notebook. Inserting a new Code cell in that notebook will now have a blue'ish background. $\endgroup$
    – ihojnicki
    Jun 22 at 21:49
  • $\begingroup$ Thank you very much. So the background color of the code cell style is tied to that of InitializationCell style. In any case that worked. Thank you again. $\endgroup$ Jun 22 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.