How do I create a circled symbol in Mathematica?

838 views Asked by At

I know that Framed is used to show a frame around a symbol, how can I show a circle around a symbol?

5

There are 5 answers

0
WReach On BEST ANSWER

If you don't mind having to micromanage the alignment parameters, you can overlay the empty circle character over a symbol:

TraditionalForm @ Style[
  Overlay[{x, Style[\[EmptyCircle], 24]}, Alignment -> {0.075, 0.16}]
, "DisplayFormula"
]

circled "x"

The exhibited font size and alignment parameters work for the font on my machine, but you may have to tweak them for good results on your screen. And tweak them again for a decent print-out. The following Manipulate can aid in that process:

Manipulate[
  TraditionalForm @ Style[
    Overlay[
      {Style[x, xSize], Style[\[EmptyCircle], circleSize]}
    , Alignment -> {xAlign, yAlign}
    ]
  , "DisplayFormula"
  ]
, {{xSize, 12}, 8, 40, 1, Appearance -> "Labeled"}
, {{circleSize, 24}, 8, 40, 1, Appearance -> "Labeled"}
, {{xAlign, 0.075}, -1, 1, Appearance -> "Labeled"}
, {{yAlign, 0.016}, -1, 1, Appearance -> "Labeled"}
]

image adjustment manipulator

11
Mr.Wizard On

Here is an attempt to create a function that circles arbitrary expressions. It's rather clumsy, but I cannot think of a better way at the moment.

circled =
    With[{m = Max@Rasterize[#,"RasterSize"]},
       Framed[
         Pane[#, {m, m}, Alignment -> Center],
         RoundingRadius -> 1*^6]
    ] &;


circled[1/x + y + z]

enter image description here

2
Dr. belisarius On

The same idea of WReach, but trying to autocalculate:

cirBeli[x_] := 
 TraditionalForm@
    Style[Overlay[{#, 
       Style[\[EmptyCircle], 
        N@2 Norm[ImageDimensions[Rasterize[#]][[1 ;; 2]]]]}, 
      Alignment -> Center], "DisplayFormula"] &@x

cirBeli[x]

enter image description here

4
John Flatness On

Framed can take an option RoundingRadius.

Framed[expr, RoundingRadius -> radius]

At smaller values of radius the corners of the frame are simply slightly rounded, but at larger values, the frame becomes an oval or circle.

4
Dr. belisarius On

Using Framed[ ] with RoundingRadius

f = Rasterize[#, "RasterSize"] &;
circledBeli[x_] := Framed[ x,
                    FrameMargins -> (Norm@f@x - Array[1 &, {2, 2}] f@x)/2,
                    RoundingRadius -> Norm@f@x];

circledBeli[Sin[z^2]/Exp[z] + Integrate[Sin[x] Cos[x] Sqrt[x], x]]

enter image description here

circledBeli["3((1/x+y+z)/h)\n2\nm\np"]

enter image description here

Edit

The following seems to work better with TraditionalForm:

f = ImageDimensions[Rasterize[#]][[1 ;; 2]] &;
g = Reverse[ImageDimensions[Rasterize[Rotate[#, Pi/2]]][[1 ;; 2]]] &;
h = Max /@ Transpose@{f@#, g@#} &;
circledBeli[x_] := 
  Framed[x, FrameMargins -> (Norm@h@x - Array[1 &, {2, 2}] h@x)/2, 
   RoundingRadius -> Norm@h@x];
t = TraditionalForm[Sin[z^2]/Exp[z] + Integrate[Sin[x] Cos[x] Sqrt[x], x]]
circledBeli[t]

enter image description here