Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to set the background of a section to light gray and leave background of content below and above the section as default?

share|improve this question
Why would right-clicking the cell bracket and looking into the "Background Color" option of the pop-up not work? – J. M. Apr 20 '13 at 5:05
@J.M. I guess OP might want it be gray for not only the background of cells but also spaces between cells. – Silvia Apr 20 '13 at 17:13

Try to group the entire section and set the backround color to gray from the "Writing assistant pallete".

You can also use create your own stylesheet by going to "Format->Edit Stylesheet->Choose a style->Section". Then you change the bckround color to gray using the "Writing assistant pallete". Every time you create a new section, the backround color will be automatically gray

share|improve this answer

If you wish to do this programmatically instead of using the mouse in the front end, you can place the following code after the section you wish to change the color of, then it should select the section and change the background:

SelectionMove[SelectedNotebook[], Previous, CellGroup];
obj = SelectionMove[SelectedNotebook[], Previous, CellGroup]
SetOptions[NotebookSelection[], All, Background -> LightGray]

This could be developed into a button if necessary to be re-used, as it may be a bit clunky to past this in after every section you wish to change the color of.

Note that you can change Previous in the SelectionMove commands to Next if you wish to place this code before the Section to be colored. In addition, this construction can be used to change a variety of other cell styling options.

share|improve this answer
It still has white background in between cells. Is that possible at all to make gray? – qazwsx Apr 30 '13 at 14:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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