MathGroup Archive 2007

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

Search the Archive

Mathematica 6 Cell Grouping

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79293] Mathematica 6 Cell Grouping
  • From: yatesd at mac.com
  • Date: Tue, 24 Jul 2007 05:56:51 -0400 (EDT)

I have been trying to infer the CellGroupingRules option in order to
accomplish the following:

I like to keep "code" together with my document. By "code", I mean
typical Input and Output cells (not Initialization Cells). So, for
example, I might have a whole lot of code at the begining of a
document, followed by formatted pages which include a mixture of text,
graphics, and complicated cells (mostly GridBox's used to create page
formatting with inline cells of text and/or graphics). On the
formatted pages, I also have some code. Usually just the code which
generated a complicated graphic, but sometimes other code as well.
When I come to print the document, I don't want any of the "code" to
print. All the code has a Style of either "Input" or "Output" and all
the parts that I DO want to print have styles that are never "Input"
or "Output". Originally, I had thought this could easily be
accomplished by having the following in my stylesheet
Cell[StyleData["In","Printout"],CellOpen->False] and
Cell[StyleData["Out","Printout"],CellOpen->False], but unfortunately,
even a closed cell has some height (even if you set
CellElementSpacings->{"ClosedCellHeight"->0} ). This probably does not
make much difference to your formatting if you only have one cell like
that, but makes a big difference if you have a lot of them.

First thought for a workaround was to use a NotebookLocate to select
all the cells I want printed (having setup appropriate CellTags
first). Then call NotebookPrint passing a NotebookSelection of the
previously located cells, which according to the help is supposed to
print only the selected cells. I could not get this to work.
(NotebookPrint printed the whole notebook regardless of what I did or
selected.)

My latest workaround is to use the new Dynamic feature in Version 6.
By creating CellGroupData[{Cell..},Dynamic[cellShow]], it appears I
can make all the cells that are wrapped by that CellGroupData
disappear by setting cellShow->{}. It is quite time consuming to
always manually group cells, and so I wish to better understand the
CellGroupingRules so that I can automatically get all of my "Input"
and "Output" cells into their own cell groups.

Here is what I have managed to infer so far (no guarantees that I got
it right, as these features are unfortunately undocumented).

CellGroupingRules can be one of the following:

"NormalGrouping" -> Appears to be essentially no grouping

{"TitleGrouping", _Integer} -> See "SectionGrouping"

{"SectionGrouping", _Integer} -> For "TitleGrouping" and
"SectionGrouping", it appears grouping is mostly controlled by the
Integer (I read somewhere it needs to be in the range of 0 to 100, but
have not tested this.) Lower integers have higher priority, so a
higher integer group becomes nested within the lower integer group. If
a new lower integer cell is found, it then starts its own group. The
"TitleGrouping" vs "SectionGrouping" part seems to influence the
behaviour only if you have a "SectionGrouping" immediately followed by
a "TitleGrouping" of lower precendence (ie higher integer). In that
case, the "TitleGrouping" is ignored. "TitleGrouping" appears to have
one more (ANNOYING) "feature". If it does not have any cells in its
group, it adds some space to the bottom cell margin. I have not found
an option to control or turn this off.

"InputGrouping"-> Group with cell below if it has style "Ouput",
otherwise no grouping

"OutputGrouping"-> Group with cell above if it has style "Input" or
"Output". (By implication, will group will cell below if cell below
has Style "Output")

"GraphicsGrouping"-> I think this is now legacy as graphics have style
"Output" in version 6. Presumably still used if you turn on legacy
graphics.

"GroupTogetherGrouping"-> This is new to version 6, and I am not sure
how it works yet and whether or not it needs an _Integer like
TitleGrouping and SectionGrouping.

"GroupTogetherNestedGrouping"-> Also new to version 6. Also not sure
how it works.

I would be interested in hearing what others have inferred, or if they
have any other ideas on how to achieve printing "without the code".

Derek



  • Prev by Date: Re: truncated File -> Save As -> HTML conversion problem
  • Next by Date: Re: Re: Embedded Style Sheets
  • Previous by thread: Re: Re: truncated File -> Save As -> HTML conversion problem
  • Next by thread: Re: Mathematica 6 Cell Grouping