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.

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
1  
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 mathematica.stackexchange.com/questions/14466/… for another approach. –  cormullion Feb 15 '13 at 12:24
add comment

1 Answer

up vote 18 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]}},
 MenuSortingValue->10000]

"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
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.