MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Cell Grouping Question

In article <87lua8$6qf at>,
 "David Park" <djmp at> writes:

> I would very much like to obtain the following cell grouping behavior: If a new cell
> was started, especially a Text or Input Cell, I would like it to be grouped into the
> lowest containing OPEN group. Then I could be working at the Section level say, start
> a Subsection which would contain ancillary material, close up the Subsection, and
> continue with the Section. But with present behavior any new material always goes
> into the Subsection. Also to make the scheme workable, it would be necessary to be
> able to set a new cell selection point either at the end of a subsection or beyond it
> in the larger group.
> Manual grouping is not an adequate solution since all the automatic grouping is given
> up. And once you switch back to automatic grouping, any manual grouping done is lost.
> I have somewhat mimicked this behavior by defining new cell types SubText and
> SubSubText in my style sheet such that SubText is grouped at the same level as
> Subsection.
> Does anyone know an easier method to obtain the behavior described above?

You can change the cell grouping precedences as defined in the notebook's
style sheet.  This will give you the means of directing the front end
to use your preferences as "automatic grouping".

The decision as to whether a collection of cells will be grouped under 
a single bracket is determined by the option setting CellGroupingRules  
that resides within the style definition used by the cell.  Option values 
take the form

        <grouping rule name>

        {<grouping rule name>, <integer between 0 and 100>}

Grouping rule names that use strings only include "InputGrouping",
"OutputGrouping", and "GraphicsGrouping".  Grouping rule names that use
strings with numbers include "TitleGrouping" and "SectionGrouping".  The
numbers indicate a precedence level with 0 being highest and 100 being

In general, if adjacent cells have styles which use the same grouping rule
name, the cells will be grouped only if the preceding cell has a higher
precedence level.  Consider the placement of these two cells together.

        Cell["cell A", CellGroupingRules->{"TitleGrouping", 10}]

        Cell["cell B", CellGroupingRules->{"TitleGrouping", 20}]

These cells will be grouped together because the prior cell will have
higher precedence.  However, the following cells will not group because
the precedence levels are reversed.

        Cell["cell A", CellGroupingRules->{"TitleGrouping", 20}]

        Cell["cell B", CellGroupingRules->{"TitleGrouping", 10}]

Things get a little more complicated when cells of unlike grouping rules
begin to appear next to one another.  The rules here are:

1) "TitleGrouping" groups with any other cell that appears below it.

2) "SectionGrouping" groups with any other cell that appears below it
with the exception of those cells which have "Title" grouping.

3) "InputGrouping", "OutputGrouping", and "GraphicsGrouping" don't grop
with any cells that appear after them.

Finally, if a pair of cells group together, but a third, preceding cell
does not group with the first cell in the pair, then the pair will for its
own cell subgroup.

P.J. Hinton
Mathematica Programming Group           paulh at
Wolfram Research, Inc.
Disclaimer: Opinions expressed herein are those of the author alone.

  • Prev by Date: Mapping of mapping functions in metadefinitons
  • Next by Date: Re: Why doesn't Mathematica know this?
  • Previous by thread: Cell Grouping Question
  • Next by thread: #1 FindRoot and protected variables? #2 Am I using the wrong method?