Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
2  
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
1  
@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
add comment

2 Answers 2

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
add comment

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? –  Problemaniac Apr 30 '13 at 14:12
add comment

Your Answer

 
discard

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.