9
$\begingroup$

Is there an option or method for Framed analogous to Frame in Graphics to control display of individual edges, eg bottom, left, top, right?

Framed is useful for visualizing nested structures, but often 4 sides are redundant, eg in this healthcare related prototype would like to display only the left edges:

If not an option, is there a workaround that does not explicitly involve Graphics?

enter image description here

$\endgroup$
  • 2
    $\begingroup$ In version 8, it used to be possible to do something like this, see this question and answer. Unfortunately, it no longer works in version 10. $\endgroup$ – Jens Jun 23 '16 at 4:50
  • $\begingroup$ Related: (21082) $\endgroup$ – Mr.Wizard Jul 19 '16 at 18:49
8
$\begingroup$

Would a CellFrame around a TextCell work?

Framed[
 x -> TextCell[
   Column[{"Depression", "PTSD", "Diabetes Type II", "Smoker"}], 
   "Text",
   CellFrame -> {{True, False}, {False, False}}]]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Great, is it possible to control line width? $\endgroup$ – alancalvitti Jun 29 '16 at 21:12
  • $\begingroup$ @alancalvitti Harder than I thought, given that CellFrameStyle shows up in the option inspector: System`CellFrameStyle -> {{AbsoluteThickness[12], None}, {None, None}} yields this. Note that (on V10.4.1) CellFrameStyle is not already in the System` context and Global`CellFrameStyle won't work. -- Just checked and "CellFrameStyle" -> {{AbsoluteThickness[12], None}, {None, None}} also works. $\endgroup$ – Michael E2 Jun 29 '16 at 21:22
8
$\begingroup$

An alternative way of getting a similar display would be to define a new function leftFramed that only puts a vertical extensible line to the left of the content:

leftFrame /: MakeBoxes[leftFrame[obj_], _] := 
 RowBox[{"\[LeftBracketingBar]", ToBoxes[obj]}]

Framed[x -> 
  leftFrame[
   Column[{"Depression", "PTSD", "Diabetes Type II", "Smoker"}]]]

bracket

You can see that this vertical line is in fact an extensible character, not a graphical line.

In the same vein, you could also use other extensible symbols to decorate the left side:

leftBrace /: MakeBoxes[leftBrace[obj_], _] := 
 StyleBox[RowBox[{"{", ToBoxes[obj]}], SpanMaxSize -> Infinity]

Framed[x -> 
  leftBrace[
   Column[{"Depression", "PTSD", "Diabetes Type II", "Smoker"}]]]

brace

$\endgroup$
  • $\begingroup$ Jens, yours is a nice approach too, I will likely use it as well, but accepted Michael E2 because TextCell seems easier more user friendly. $\endgroup$ – alancalvitti Jul 13 '16 at 19:50

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.