Skip to main content

How to implement specific cell grouping behavior?


Here's the situation in my Mathematica Notebook:


enter image description here


I'd like the bottom cell to be grouped with the cells above it. Here are those same cells toggled into code:


 Cell["How to get new text cells to group right?", "ItemNumbered",

WholeCellGroupOpener->True,
CellGroupingRules->{GroupTogetherGrouping, 10000.}]

Cell["This is text...", "Text",
CellGroupingRules->{GroupTogetherGrouping, 10000.}]

Cell["This is code...", "Program",
CellGroupingRules->{GroupTogetherGrouping, 10000.}]

Cell[BoxData[

RowBox[{"why", " ", "am", " ", "I", " ", "not", " ", "in", " ", "the", " ",
RowBox[{"group", " ", ":", "("}]}]], "Input",
CellGroupingRules->{GroupTogetherGrouping, 1001.}]

I have cell grouping set to Manual Grouping in the Cell ► Grouping menu.




Update


Let me clarify what I'm trying to achieve:


Following the solution of @PatrickStevens changes nothing unless I switch to Automatic change grouping to grouping in the Cell dropdown menu. However, doing this breaks other cell groups that I created manually:


enter image description here



So how can I set a notebook to automatically obey these grouping rules:




  1. If the cell type is in {"Text", "Item", "Code", "Input", "Output", and "Program"} then group it together under a header cell.




  2. The header cell (the top cell in a cell group) is the first cell found above of this type, checked in this order: "SubitemNumbered", "ItemNumbered", "Subsection", "Section", "Subtitle", "Title".






Comments