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[]]]},
    Function[{frame, pos},
        CellMargins -> {{66, 10}, {0, 0}},
        CellFrame   -> {{2, 2}, frame},
        Background  -> LightBlue] &,
    {{{0, 2}, {0, 0}, {2, 0}}, {1, 2 ;; -2, -1}}
] // CreatePalette

Update with GIF to explain: enter image description here

  • $\begingroup$ I rephrased this question to include the exact functionality I am looking for. $\endgroup$
    – B flat
    Dec 6 '15 at 7:43
  • 1
    $\begingroup$ The frame should be only around the section group etc, or you want to create them manually? $\endgroup$
    – Kuba
    Dec 6 '15 at 9:22
  • $\begingroup$ @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. $\endgroup$
    – B flat
    Dec 6 '15 at 22:19
  • $\begingroup$ And yes. I am using manual grouping turned on. $\endgroup$
    – B flat
    Dec 6 '15 at 22:22
  • 1
    $\begingroup$ 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 :/ $\endgroup$
    – Kuba
    Dec 7 '15 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.