# Close subgroup of cells and keep them closed

Styles can be used to give your calculation a book-like structure; with chapters, sections and paragraphs. Closing those subgroups of cells you don't want to see is then very powerful to create visual order. I use this to keep oversight of my calculation. The cells containing the actual calculations I close, and only the titles and heads are visible.

This works well until I evaluate cells. Whenever a result or message is printed, the cells open automatically, and the notebook becomes a mess again. My question is: how can I prevent these cells from opening ?

I have some ideas, but I would like to hear if you have any (better) alternatives. This I what can think of:

• Add a semicolon after each line.
• Use Block[{Print}, Expression} to suppress Print statements

The side effect of these methods is that no results or messages are printed at all. I would like them to be printed though. At the same time I want to decide my self when to open a cell or not.

-
This question might help –  Heike Mar 20 '12 at 8:40
In this question I use the word close, but maybe I should use the word folded instead. Is it the same? –  sjdh Mar 20 '12 at 9:05

autoFoldOutput[] := (If[$FrontEnd =!=$Failed,
SelectionMove[EvaluationNotebook[], All, EvaluationCell];
FrontEndTokenExecute["SelectionCloseUnselectedCells"]])


And then in a new cell:

2 + 2
autoFoldOutput[]

-