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

I'm working on a large notebook and I want to exclude some sections and subsections from being evaluated when I evaluate the whole notebook.

Is there a way to exclude specific sections or subsections from the notebook evaluation while maintaining their original format? Or even better, format them e.g. by adding a gray background?

share|improve this question
Rather than specify which sections to not evaluate, you can specify which you do want to evaluate, by setting them to be initialization cells, and evaluating only initialization cells. – jVincent Feb 15 '13 at 11:51
Or, you can select those cells that you don't need to evaluate and comment them (Edit menu -> Un/Comment Selection). – VLC Feb 15 '13 at 12:08
See… for another approach. – cormullion Feb 15 '13 at 12:24
up vote 19 down vote accepted

This solution only works in version 9. Create a private stylesheet, and add style cells for any Section, etc., styles that you want to create using the following pattern:

Cell[StyleData["NonEvaluatingSection", StyleDefinitions -> StyleData["Section"]],
 PrivateCellOptions->{"CellGroupBaseStyle"->{Evaluatable -> False,
   Background->RGBColor[0.8, 0.8, 0.8]}},

"CellGroupBaseStyle" is new to version 9, and it allows you to layer in options to all cells which are grouped by the given style. So, in this case, we have a style "NonEvaluatingSection", which has all of the properties of the style "Section", except that it adds a background and Evaluatable->False to itself and all of the cells grouped by it. The option is not documented, but that's just an oversight. It will be in a future release.

If, for example, you've added the above to the notebook's private stylesheet, then you can simply set the style of the head cell of any sections you don't want to evaluate to "NonEvaluatingSection" style (which you'll now see in the Format->Style menu).

share|improve this answer

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.