There are several questions in Mma.SE related to programmatically opening and closing cells, but I could not find quite what I'm seeking.
Here's a minimal example:
CellPrint[
{ExpressionCell[x + y,
Background -> LightOrange,
"Equation",
CellGroupingRules -> "OutputGrouping"]}]
When I evaluate this code it produces (almost) what I want: the expression in the Equation
cell, properly grouped with the code that produced it.
However I would like to automatically collapse (Close
) the source code cell, while preserving the existing grouping. I would like to go back, if necessary, to manually open the source cell, but the default should be that upon execution the source cell closes.
My kludge at present is to manually double click on the output cell, thereby collapsing the source code cell, but I'd rather it be automatic.