24
$\begingroup$

How does one change the default notebook background color?

$\endgroup$
1
  • 1
    $\begingroup$ It should also be noted that for Wolfram Mathematica 11.0, if you go to Format, then StyleSheet, there is the option ReverseColor in case you want a "dark theme". $\endgroup$
    – user73236
    May 27, 2020 at 0:30

5 Answers 5

24
$\begingroup$

You can SetOptions for the current notebook as:

SetOptions[EvaluationNotebook[], Background -> LightGreen]

to change the background to whatever colour you like. You can also supply an RGB colour as:

SetOptions[EvaluationNotebook[], Background -> RGBColor[0.9, 0.7, 0.7]]

Other possibilities for the first argument of SetOptions are

  • $FrontEnd which will change the background for all notebooks and last across restarting Mathematica.

  • $FrontEndSession which will change the background for all notebooks but won't be saved if you restart Mathematica.

$\endgroup$
12
  • $\begingroup$ @Brett Thanks for the edits. I've been trying to look at making changes to the stylesheet, but couldn't figure out which style to change. I thought Cell[StyleData["Notebook"], Background -> LightBlue] should work, but it doesn't. Any clue? $\endgroup$
    – rm -rf
    Feb 6, 2012 at 3:35
  • $\begingroup$ If you select the All item from the popup list of styles in the stylesheet editor, that should work. $\endgroup$ Feb 6, 2012 at 3:39
  • 3
    $\begingroup$ @R.M you cannot use named colours in style sheets you have to use e.g. Cell[StyleData["Notebook"], Background -> RGBColor[0.87, 0.94, 1]] $\endgroup$ Feb 6, 2012 at 3:46
  • $\begingroup$ I like this answer because it will allow me to make changes programmatically, thanks $\endgroup$
    – Tim
    Feb 6, 2012 at 3:48
  • 3
    $\begingroup$ @GustavoBandeira If by "text", you mean input text (or code), then see this answer of mine that describes the various tokens that control the different colours. If you mean normal text, then the idea is the same — you modify the stylesheet, except that now you choose Text from the dropdown menu instead of StandardForm or anything else. $\endgroup$
    – rm -rf
    Nov 30, 2012 at 18:10
18
$\begingroup$

You could create a custom stylesheet that has a different background color and define it to be the default one. To do that, go to Format | Edit Stylesheet, select All in the "Choose a style" combo box. Select the appearing entry in the list below and set your appropriate style definitions for it, in your case that would be another background color using Format | Background Color. The new window should look somewhat like this:

enter image description here

You can now select File | Save as, and save the stylesheet window notebook somewhere. To make it available in the stylesheet choosing menu (Format | Stylesheet), save it in $UserBaseDirectory/SystemFiles/FrontEnd/StyleSheets, where $UserBaseDirectory is your user directory. If you don't know where that is, simply execute $UserBaseDirectory in Mathematica and it will print its location. Once your newly created stylesheet is saved in that folder, you'll be able to select it over the menus; if it doesn't appear right away, restart the frontend.

If you want to use this as your default stylesheet, i.e. the one that is used when the program starts, go to the options inspector (Format | Options Inspector), select Global preferences at the top (see picture below), and change the value of DefaultStyleDefinitions to the path you put your stylesheet in.

enter image description here

$\endgroup$
1
  • $\begingroup$ The style sheet only changes the background color of all cells and not the notebook. How can I create a stylesheet where it changes only the the notebook background color? $\endgroup$
    – Qbyte
    Mar 26, 2020 at 22:35
10
$\begingroup$

Another option is to pull up the Format --> Option Inspector selection in the menu system, select the notebook that you're using in the upper-left, and then navigate to Notebook Options --> Display Options --> Background. The palette would let you pick the exact shade that you wish to work with. You can also see a bunch of the great options that R.M. identified in the answer above through the Option Inspector.

It's a little clunky and the SetOptions command is quicker, but it is an alternative for tinkering and playing around with to get the Notebook set up to your satisfaction.

enter image description here

$\endgroup$
6
$\begingroup$

This is just another way of getting at the notebook options, which I note as an alternative syntax to R.M.'s answer:

CurrentValue[EvaluationNotebook[], Background] = Red; 

The CurrentValue command can also be used to access a range of other (often system-specific) options like "PanelFontSize".

$\endgroup$
0
2
$\begingroup$

If you go to Format->Edit stylesheet, then you have to add the word "Notebook" where it says "Enter a style name". The you can change its background color in Format->background color by selecting it. Hope I could help!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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