2
$\begingroup$

I want to do a for loop to compute some values, create a new (sub-)section and print those values there within each iteration. How would it be possible?

$\endgroup$
  • 2
    $\begingroup$ CellPrint is probably the core function you'd use in this case. You can find other helpful functions here. $\endgroup$ – user6014 Sep 9 '18 at 1:39
3
$\begingroup$
Do[CellPrint[
  CellGroup[{TextCell["i = " <> ToString@i, "Subsection"], 
    ExpressionCell[Plot[Sin[i x], {x, -Pi, Pi}, ImageSize -> 150], "Output"]}]],
 {i, 1, 3}]

enter image description here

$\endgroup$
4
$\begingroup$

You gave very little details as to exactly what you're after, but something like the following should be a good start:

Do[CellPrint[Cell[ToString@RandomReal[], "Subsection"]], {i, 1, 10}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.