2

I am trying to create a framed cell around cells that collapse and expand. Mr. Wizard's answer below almost does it, however, when the cells are collapsed I lose the lower frame border. I'd like to keep it. Here is his code. I'm having trouble fixing this. Can someone help?

Button["Frame Multiple Cells",
  With[{cells = Cells[NotebookSelection[InputNotebook[]]]},
   MapThread[
    Function[{frame, pos},
     MapAt[
      SetOptions[#,
        CellMargins -> {{66, 10}, {0, 0}},
        CellFrame   -> {{2, 2}, frame},
        Background  -> LightBlue] &,
      cells,
      pos
     ]
    ],
    {{{0, 2}, {0, 0}, {2, 0}}, {1, 2 ;; -2, -1}}
   ]
  ]
] // CreatePalette

Update with GIF to explain: enter image description here

B flat
  • 5,523
  • 2
  • 14
  • 36
  • I rephrased this question to include the exact functionality I am looking for. – B flat Dec 06 '15 at 07:43
  • 1
    The frame should be only around the section group etc, or you want to create them manually? – Kuba Dec 06 '15 at 09:22
  • @Kuba When I have a group of cells I see a frame surrounding the entire group. But when I collapse the cells so that I only see the first cell, I see a frame that only surrounds the left, top and right. The bottom no longer has the frame. I'm looking for a solution that keeps the frame around all the content whether the group is closed (to show only the first cell) or open (showing all cells in the group). I can make an animated gif if this doesn't describe it to your satisfaction. – B flat Dec 06 '15 at 22:19
  • And yes. I am using manual grouping turned on. – B flat Dec 06 '15 at 22:22
  • In trying to alter the code, but it seems the way it is written I can't do this without putting in some sort of conditional somewhere. I can't seem to figure out how to do this as I don't know of a way that Mathematica can tell me if a group is currently open or closed programmatically. – B flat Dec 07 '15 at 00:33
  • I updated the question with an animated gif to illustrate the question. – B flat Dec 07 '15 at 02:20
  • 1
    Does this framing work for you well? When I use Mr. Wizard's method Input cells that are grouped with Output have additional indenting so the frame isn't straight :/ – Kuba Dec 07 '15 at 10:26
  • @Kuba It works for me so long as I treat it as a group shown in the gif above. I'm actually collapsing all cell into the first cell. So its not actually a group. But it works. There is no indentation which is nice, but I can't seem to get the frame on the bottom to stay. – B flat Dec 08 '15 at 06:01
  • @MichaelMcCain, may I ask you to share the snippet for making buttons for Cells 'Background' colors (I can see four of them in the upper left corner of the GIF :-)? – garej Jan 06 '16 at 23:03
  • Sure you can email me at michaelmccain@mac.com – B flat Jan 07 '16 at 08:32
  • @MichaelMcCain, I've sent an email from garej{a}mail.ru – garej Jan 07 '16 at 10:30

0 Answers0