is an option for cells that specifies the rules used for grouping cells together.
CellGroupingRules
is an option for cells that specifies the rules used for grouping cells together.
Details
- A cell may form a cell group with cells below it automatically by following the rules specified by the CellGroupingRules option.
- With the default setting CellGroupingRules->"NormalGrouping", cells do not form cell groups, but may be included in groups formed by various other group types.
- Cell grouping rules may be specified as "type" or {"type",prec}. "type" is the type of grouping performed, and prec is an integer specifying the precedence of grouping relative to other cells of the same type.
- A cell group always has at least two cells. To form a cell group, the first cell of the group must have a CellGroupingRules setting that allows the formation of a group, and subsequent cells must have CellGroupingRules settings that allows participation in that group
-
Group type Allowed to group Grouped by "NormalGrouping" nothing "TitleGrouping", "SectionGrouping" "TitleGrouping" anything "TitleGrouping", "SectionGrouping", "ItemGrouping" "SectionGrouping" anything "TitleGrouping", "SectionGrouping", "ItemGrouping" "ItemGrouping" anything "TitleGrouping", "SectionGrouping", "ItemGrouping" "InputGrouping" "OutputGrouping", "GraphicsGrouping" "TitleGrouping", "SectionGrouping", "ItemGrouping" "OutputGrouping" nothing anything except "OutputGrouping", "GraphicsGrouping" "GraphicsGrouping" "GraphicsGrouping" anything except "OutputGrouping" - The types "TitleGrouping", "SectionGrouping" and "ItemGrouping" should be specified as {"type",prec}. Groups that are allowed to form by the type rules will only form if the lead cell has a lower prec than the prec of the cells that follow.
- The types "NormalGrouping", "InputGrouping", "OutputGrouping" and "GraphicsGrouping" are always considered to have a higher precedence than the other types, and so may be specified as simply CellGroupingRules"type".
- "TitleGrouping" cells automatically group other "TitleGrouping" cells of equal precedence.
- StyleData cells group do not group following the rules of CellGroupingRules. Instead, cells specifying settings for the same style are grouped together.
Examples
Basic Examples (2)
By default, Section cells always group Input cells:
CreateDocument[{TextCell["section", "Section"], ExpressionCell["input", "Input"]}]Use CellGroupingRules to change the grouping so the Input cell is no longer grouped:
CreateDocument[{TextCell["section", "Section"], ExpressionCell["input", "Input", CellGroupingRules -> {"SectionGrouping", 0}]}]Query the CellGroupingRules attribute for the Section style:
CurrentValue[{StyleDefinitions, "Section", CellGroupingRules}]Section cells group Input cells because "SectionGrouping" always groups "InputGrouping":
CurrentValue[{StyleDefinitions, "Input", CellGroupingRules}]Related Guides
History
Introduced in 1999 (4.0)
Text
Wolfram Research (1999), CellGroupingRules, Wolfram Language function, https://reference.wolfram.com/language/ref/CellGroupingRules.html.
CMS
Wolfram Language. 1999. "CellGroupingRules." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CellGroupingRules.html.
APA
Wolfram Language. (1999). CellGroupingRules. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CellGroupingRules.html
BibTeX
@misc{reference.wolfram_2026_cellgroupingrules, author="Wolfram Research", title="{CellGroupingRules}", year="1999", howpublished="\url{https://reference.wolfram.com/language/ref/CellGroupingRules.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_cellgroupingrules, organization={Wolfram Research}, title={CellGroupingRules}, year={1999}, url={https://reference.wolfram.com/language/ref/CellGroupingRules.html}, note=[Accessed: 13-June-2026]}