During rather long computation I have intermediate steps Print
ed with useful information which should be collected for possible use in future inside of the evaluation Notebook
. When the computation is finished the final results are printed. But there are hundreds of intermediate Print
s which fill the screen and contain supporting information which is interesting to see during computation but impede reading the final results. I wish to have an ability to collapse the intermediate prints in a CellGroup
.
Here is an example from the Documentation page for EvaluationMonitor
:
FindRoot[x^2 - 2, {x, 1},
EvaluationMonitor :> Print["x = ", x " x^2 - 2 =", x^2 - 2]]
After evaluation of the above we get intermediate results in one collapsable CellGroup
(note the collapsed cell group selected on the right):
My problem is that my computation involves several cycles with intermediate evaluations and I am forced to Print
the final results after a cycle is finished. So all the prints by default belong to one cell group. It can be simulated as follows:
Do[Print@FindRoot[x^a - 2, {x, 1},
EvaluationMonitor :> Print["x = ", x , ", x^", a, " - 2 = ", x^a - 2]], {a, 1, 3}]
How is it possible to have intermediate prints grouped together and collapsible?
Lookup[Developer`CellInformation[#], "FirstCellInGroup"]
can be useful for automatic collapsing the cell groups. $\endgroup$