By default output cells are grouped with the input cell from which they are generated (note the nested cell brackets on the right):
Sometimes it is desirable to group manually input cell with previous "Text"
cell containing some comments/description. We can do it manually by selecting both cells and then applying the "Group Cells" item from the right-click menu:
Now both cells are placed in one group:
And this is what happens when we evaluate the grouped input cell:
Now output cells aren't automatically grouped with the input cell anymore!
First question: Is it possible to keep automatic grouping for generated cells if the input cell was manually grouped with some previous cell?
But it is not the end of the story. Being in despair due to this behavior, I manually delete the output cells as well as the text cell, and then try to evaluate my input cell again. Here is what I get:
Surprisingly, output cells aren't grouped with the input cell again! Obviously, the FrontEnd somehow has "marked" this input cell to behave differently. Let us check its internal expression (I selected the cell and pressed Clrl+Shift+E):
Second question: What makes this cell "special" and how to make it an "ordinary" cell again?
Now I copy this cell and try to evaluate it in another place of the Notebook:
The copy obviously is also "special": the automatic grouping doesn't work for it as well! So with the cell some "flag" marking it as "special" was copied. What can it be and how can I remove such a "flag"?
If I copy not the cell, but only the code from it, and then paste as a new cell, normal grouping behavior is restored:
To summarize, my questions are:
Is it possible to keep automatic grouping for generated cells if the input cell was manually grouped with some previous cell?
How FrontEnd "marks" the cell as a "special" and how is it possible to remove such a "mark"?
"GroupTogetherGrouping"
that's doing it. I mean at the stylesheet level you could cook this into allText
andInput
andOutput
cells, but it might be bad for performance to write a style that picks up the prior cell'sCellGroupingRules
and adapts to those. $\endgroup$"Text"
cell in order to have it automatically grouped with next"Input"
cell? $\endgroup$"InputGrouping"
for that $\endgroup$CellGroupingRules->"InputGrouping"
into the code of the"Text"
cell, but it hasn't changed the grouping: the next"Input"
cell is still not grouped with it. $\endgroup$