I want to have my entire notebook be a conditional while statement. However, I don't want to merge all of my cells together, as it is a long and detailed process. Is there a way to create another cell that encompasses all of the smaller cells in my notebook?
-
$\begingroup$ What do you mean by "I want to have my entire notebook be a conditional while statement?" Have you looked at Cell Groups? $\endgroup$– Mr.WizardJun 11, 2014 at 13:45
-
$\begingroup$ Just guesswork, but this could be useful: Creating Mathematica packages. Otherwise, your question is unclear. $\endgroup$– Yves KlettJun 11, 2014 at 13:50
-
$\begingroup$ I want to be able to combine all of my original cells into a larger cell without losing the smaller subcells. I don't know how topics in Cell groups would help if I am trying to span across multiple cells to create another cell. @Mr.Wizard $\endgroup$– KaiseyJun 11, 2014 at 14:08
-
$\begingroup$ Is is possible to simple rerun the notebook if, at the end, a certain condition is not met? $\endgroup$– KaiseyJun 11, 2014 at 14:23
2 Answers
I guess you are looking for something like this:
If[condition, NotebookEvaluate[EvaluationNotebook[]]]
I'd suggest its somewhat cleaner to create a second 'control' notebook with some code similar to this:
While[condition , NotebookEvaluate[First@Notebooks["Untitled-4"]]
-
$\begingroup$ your code seems to work, but I cannot figure out how to get the output of my cells to show. $\endgroup$– KaiseyJun 11, 2014 at 18:54
-
$\begingroup$ I don't follow that - the output appears in the notebook same as if you did select-all;shift-enter. $\endgroup$ Jun 12, 2014 at 15:26
Grouping power is controlled by the Option CellGroupingRules
, frequently defined in the style sheet system. The outermost Cell style by default is Title
and has CellGroupingRules->{"TitleGrouping", 0}
. Smaller values group larger values, and 0
is the smallest that is normally present. If you create a new Cell with negative value in this place it will group all below it.
For example if I create a new Cell (as entered in the Show Expression view):
Cell["Entire Notebook", "Title", CellGroupingRules->{"TitleGrouping", -10}]
It will group everything under it, e.g.: