The low level cell expression is Cell
. All those Text/ExpressionCells
typset to Cell
at the end, but only in some circumstances. That is if you mix it with low level Cell
/ Notebook
it won't work. So the point is, either all Cells
or higher level functions like CreateDocument/ExpressionCell
etc.
Maybe you can mix it, but I failed and my rule of thumb is to use low level functions like mentioned above and BoxData
ToBoxes
etc.
For example I'd expect this to work:
CellPrint[
CellGroup[{
TextCell["Title", "Subsection"],
ExpressionCell[b, "Output"],
ExpressionCell[c, "Output"]
}, 1]
]
but it seems that CellPrint
don't cope to well with high level CellGroup
and the group is opened.
So the low level approach is:
NotebookWrite[
EvaluationNotebook[]
, CellGroupData[{
Cell["Title", "Subsection"]
, Cell[BoxData @ ToBoxes @ b, "Output"]
, Cell[BoxData @ ToBoxes @ c, "Output"]
}
, Closed
]
]
remember that if you write somewhere where subsequent cells would be automatically grouped by your Subsection
then the group will be opened to merge them.
You can use CellGrouping -> Manual
for your notebook but it depends of the context.
Good luck, be aware of:
Cell @ CellGroupData[... in Cells family