1

Group openers are helpful as they tell the user if a cell group is open or not. Cell brackets give even more information as they also display what constitutes the cell group. The latter is very helpful. However, from a student perspective (in my lectures), brackets can be confusing to look at as they include brackets for each individual cell (which I don't need) and they can be very small (see the brackets on the far right on pic below).

I would like to create something very simple that boldly tells the user whether a cell group is open or not and what constitutes the entire group. My idea is to create something like what you see in the pic below (of the far left). I would like vertical bars to the left of a cell that indicates what constitutes the group of cells. When the cell group is open the vertical bar expands to the length of the cell group. When a cell group is closed the vertical bar collapses to a point indicating it's closed but can be opened.

enter image description here

It would be much easier to follow my lectures in class since they will be able to clearly see what constitutes the entire group of cells without having to look closely at cell brackets.

Unfortunately, I can't seem to find a way to draw these red bars since they would have to be plotted over more than one cell and the area between cells (just like cell brackets are). I don't have any code to supply as I can't figure out where to start. I'm wondering whether an attached cell would do it.

Any ideas?

Edit:

So far I have this below, but not sure how to make the length dynamic depending on the size of the contents.

col = True;
CreateDocument[
 CellGroup[{TextCell["Click within this cell", "Text", 
    WholeCellGroupOpener -> True, ShowGroupOpener -> False, 
    Background -> LightRed,
    CellEventActions -> {"MouseClicked" :> (
    col = col /. {True -> False, False -> True};
    If[col,
     NotebookDelete[obj2];

     obj3 = AttachCell[EvaluationCell[], 
       Graphics[{Thickness[.02], Red, Line[{{0, 0}, {0, 1}}]}, 
        PlotRange -> {{-.04, .04}, Inherited}], Left, 20, Top],


     NotebookDelete[obj3];

     obj2 = AttachCell[EvaluationCell[], 
       Graphics[{Thickness[.02], Red, Line[{{0, .98}, {0, 1}}]}, 
        PlotRange -> {{-.04, .04}, Inherited}], Left, 20, Top]

     ]), PassEventsDown -> True, PassEventsUp -> True}], 

TextCell["Contents", "Text"], TextCell["Contents", "Text"], TextCell["Contents", "Text"], TextCell["Contents", "Text"]}], CellGrouping -> Manual]

B flat
  • 5,523
  • 2
  • 14
  • 36
  • related https://mathematica.stackexchange.com/questions/139079/change-style-of-cell-if-group-collapses?rq=1 – B flat Dec 05 '22 at 03:42
  • Is having on the right acceptable? If so, you could probably just play around with CellBracketOptions e.g. adding something like to your top-level Cell[] in the stylesheet: ShowCellBracket->True, CellBracketOptions->{"Color"->RGBColor[1,0,0],"HoverColor"->RGBColor[1,0,0]} – George Varnavides Dec 05 '22 at 03:53
  • @GeorgeVarnavides Thank you for the suggestion. I would rather have it on the left but may be impossible or too hard to code. I'm looking for a solution that boldly indicates where the contents of the cell group start and where they end without anything else. The brackets show other things like layers and even brackets on each individual cell which I don't want. – B flat Dec 05 '22 at 04:16

0 Answers0