# How to change the appearance of a Cell GroupOpener?

I would like to change the Cell GroupOpener appearance.

In the present Mathematica design it is too small and can be missed by a reader unfamiliar with Mma. I know, how to change its color through the OptionInspector.

Now, how can I put there something instead of the check-mark that is there at present? For example, a gray triangle that has been there previously, of something more complex, some graphics of my own design

Edit: To answer the question of Silva below: This is how the Cell GroupOpener looks like at my machine operating on Windows XP, Mma 9.0.1.

Now on my other machine with Windows 7 and same Mma version the GroupOpener looks like a tiny check-mark. It is hardly visible and it is more difficult to operate (i.e. to open and close). For example, visually it is difficult to distinguish the closed from the open one. I am sorry, being presently at the machine with the XP I cannot provide an image for the GroupOpener at Win7.

Now, it is not too bad, as long as it concerns myself, this or that GroupOpener presentation is it. However, I am creating documents to give away, and need that inexperienced people would easily identify the GroupOpener and easily operate with it. So I would like to be able to control its appearance.

• I am not sure I understand what you are asking, but you should look at Opener > Options > Appearance in the Documentation Center where this is discussed. Apr 14 '14 at 15:40
• Is this question about changing a notebook's style or is it about controlling the appearance of an Opener control in code? Apr 14 '14 at 15:43
• @m_goldberg I guess OP is asking about the Cell GroupOpeners. Apr 14 '14 at 15:50
• @Alexei I think a screenshot would help to clarify your question. And I think the GroupOpener is disabled by default, so it might be helpful to explain what is this GroupOpener and how to enable them. Also, I can see the Cell GroupOpeners are "check-mark" under Windows, but are they the same under Mac / Linux? In other words, it might be helpful to clarify if your question is OS related. Apr 14 '14 at 16:02
• I guess it's doable by using Dynamic in CellDingbat or similar options. Apr 15 '14 at 11:34

According to the documentation, CellGroupData supports Dynamic-object as its status. So with the help of CellGrouping -> Manual, we can design our own "CellGroup opener". It can be a Button or EventHandler placed in CellDingbat, CellFrameLabels, etc. Here is a simple demostration (tested in Mathematica 9.0.1 and 10.0 pre-release on Windows 8.1):

openerIconOpen =
GraphicsBox[{RGBColor[0.26, 0.59, 0.26],
PolygonBox[{{0, -0.25}, {-0.3, 0.25}, {0.3, 0.25}, {0, -0.25}}]},
ImageSize -> 15, PlotRange -> All];

openerIconClosed =
GraphicsBox[{RGBColor[0.8, 0.16, 0.17],
PolygonBox[{{0.5, 0}, {0, -0.3}, {0, 0.3}, {0.5, 0}}]},
ImageSize -> 15, PlotRange -> All];

cellopenflag$1 = True; cellopenflag$2 = False;

Clear[openerBoxFunc]
openerBoxFunc[flag_] := TagBox[
DynamicBox[If[flag, $CellContextopenerIconOpen,$CellContextopenerIconClosed]],
EventHandlerTag[{"MouseClicked" :> (flag = ! flag)}]
]

cellBodys = {
"This is a Text Cell.",
BoxData[RowBox[{"Another Text Cell with GridBox: ", GridBox[{{"a", "b", "c"}}, GridBoxDividers -> {"Rows" -> {{True}}, "Columns" -> {{True}}}]}]],
BoxData[RowBox[{"1", "-", "2"}]],
BoxData[RowBox[{"-", "1"}]],
BoxData[DynamicBox[GridBox[{{"cellopenflag$1", "cellopenflag$2"}, {cellopenflag$1, cellopenflag$2}}, GridBoxDividers -> {"Rows" -> {{True}}, "Columns" -> {{True}}}]]]
};

Notebook[{
(* Start of group 1: *)
Cell[CellGroupData[{
(* Cell 1: *)
Cell[cellBodys[[1]], "Text",
CellDingbat -> openerBoxFunc[$CellContextcellopenflag$1]
],
(* Cell 2: *)
Cell[cellBodys[[2]], "Text"],
(* Start of group 2: *)
Cell[CellGroupData[{
(* Cell 3: *)
Cell[cellBodys[[3]], "Input",
CellDingbat -> openerBoxFunc[$CellContextcellopenflag$2]
],
(* Cell 4: *)
Cell[cellBodys[[4]], "Output"]
},
Dynamic[$CellContextcellopenflag$2]
]](* <- End of group 2. *)
},
Dynamic[$CellContextcellopenflag$1]
]](* <- End of group 1. *),
(* Cell 5: *)
Cell[cellBodys[[5]], "Text"]
}(* <- End of Notebook body. *),
CellGrouping -> Manual,
ShowGroupOpener -> False
] // NotebookPut

• This is a neat implementation. Is it possible to design a template with this type of functionality? In my initial attempts, editing a stylesheet complains when trying to add the option CellDingbat -> openerBoxFunc[...] Jun 19 '14 at 16:58
• @bobthechemist Thanks! Maybe we can define the openerBoxFunc in the stylesheet. Jun 19 '14 at 17:02
• @bobthechemist After another thought, I think it might be better to post process a completed Notebook than to integrate the function in stylesheet... Jun 19 '14 at 17:27
• @Silvia Great. Is it possible to make analogous thing by hand, rather thjan programmatically. For example, would it be possible to open the background cell code (Sift+Ctrl+E) and edit it such that this functionality would be included? Jun 20 '14 at 7:29
• @AlexeiBoulbitch The synchronous working is because they share the same cellopenflag\$xxx status variables, so we'll need to (programmly) generate unique status variables for each CellGroupData. About issue 3, maybe we can put the initial code in the init.m file of the mma kernel, or as a NotebookDynamicExpression for the notebooks. Also you can consider the TaggingRules method for storing the status. Jun 24 '14 at 10:10

in the absence of a suitable answer to change the appearance of the cell opener and if the cell does not require user edits, you can set WholeCellGroupOpener to True (Format menu - Option Inspector under Cell Options (ensure you have the cell selected)) or by using the Classroom Assistant palette in the Content drop down menu in the Writing and Formatting section and avoid using the cell opener all together.

• Thank you for your help, but it is not what I am asking about. In the case I already have put ShowCellOpener->True, I would like to be able to control, how the Group Opener looks like. May I, say, use an arrow instead of the triangle, or a check mark? Or may I fix it to be a triangle both at Windows XP and Windows 7. May I change its color? Red instead of gray? That are the questions. Apr 22 '14 at 12:24