9
$\begingroup$

I'd like use rounded rectangles for my cell style, but I'm not sure if this is possible. Perhaps it can be faked with an image as a background for it?

$\endgroup$
1
  • $\begingroup$ Framed has the option RoundingRadius. This is not for cell frames though, but it may lead the way to a solution. $\endgroup$
    – Szabolcs
    Mar 1, 2013 at 18:42

2 Answers 2

8
$\begingroup$

I don't think this is possible. One can set the four sides of the cell frame to various different styles using the undocumented option CellFrameStyle which you have to prefix with the System` context to get it to work (syntax coloring won't recognize it as a valid option):

CellPrint[
 TextCell[
   StringTake[ExampleData[{"Text", "AliceInWonderland"}], {200, 1000}], 
   "Text", 
   CellFrame -> True, 
   System`CellFrameStyle -> 
    { Directive[Red, Thickness[5] ], 
      Directive[Green, Thickness[10], Dashed ], 
      Directive[Blue, Thickness[5] , Dotted], 
      Directive[Gray, Thickness[5] , Dashing[{20, 3}]]
    }, 
   CellMargins -> {{100, 50}, {5, 5}}]]

Mathematica graphics.

The fact that you can specify it as four separate frame parts make me believe rounded corners are not possible. With sides specified separately I don't think an option like RoundingRadius would work.

$\endgroup$
2
  • $\begingroup$ On my system (v9 Linux), the System context is not required, and Dashed and Dotted do not seem to work the same as your example (but Dashing does). CapForm or JoinForm might be useful for producing rounding but also do not work. $\endgroup$
    – Xerxes
    Mar 1, 2013 at 23:45
  • $\begingroup$ @xerxes interesting. On Windows, using it without context, doesn't do anything. Upon inspection of the cell code (ctrl shift E) I see an extra $CellContext tagged to CellFrameStyle. Tagging it with System prevents this. $\endgroup$ Mar 2, 2013 at 9:00
9
$\begingroup$

You might work around the limitations of CellFrame by framing the content. Framed allows for a RoundingRadius.

CellPrint[
Framed[TextCell[
StringTake[
ExampleData[{"Text", "AliceInWonderland"}], {200, 1000}], "Text", 
CellMargins -> {{100, 50}, {5, 5}}], RoundingRadius -> 15, 
FrameStyle -> Red]]

enter image description here

$\endgroup$
5
  • $\begingroup$ Sorry, Szabolcs. I only noticed your comment after answering the question. Really. $\endgroup$
    – DavidC
    Mar 1, 2013 at 23:44
  • 1
    $\begingroup$ You notice the artefacts this yields in the text? $\endgroup$ Mar 1, 2013 at 23:49
  • $\begingroup$ Thanks. Placing Framed around the TextCell seems to take care of it. $\endgroup$
    – DavidC
    Mar 2, 2013 at 0:00
  • 1
    $\begingroup$ Much better. Though not really a cell frame as asked by the OP, I think this is the closest to what it would look like. $\endgroup$ Mar 2, 2013 at 8:56
  • $\begingroup$ Yes but this won't work in a style sheet :/ $\endgroup$
    – M.R.
    Mar 4, 2013 at 9:08

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.