I have a function with the following (simplified) structure:
myfunc[someInput_] :=
Module[{var1, var2, var3},
var1 = someInput*3;
Print["text1: ", var1];
var2 = someInput^5;
Print["text2: ", var2];
var3 = var1*var2;
Print["text3: ", var3];
Return[var3]
];
What I would like to do is the following: For each of the prints, I would like to print first the text (e.g. 'text1') in a single cell, and then the variable (e.g. 'var1') into another cell right underneath and then group just these two cells, such that I could collapse them later on and the only visible thing is the text ('text1').
The problem is that I am trying to find a way that does not involve the usage of Section, Subsection etc. since that would interfere with my Notebook layout... I would just like to have standard output cells which I group according to my liking (but 'automatically' within the function).
Based on this post I tried:
CellPrint@ExpressionCell[Print["text1: "]; Print[var3];, "Output"];
but this did not group the two cells and it also prints an additional, empty cell underneath. So far, I cannot come up with / find anything else and would thus appreciate any input!