0
$\begingroup$
Graphics[{Circle[{0, 0}], 
  Inset[Style["ABC", FontSize -> 30], {0.5, 0}]}, ImageSize -> 200]

QWE = "ABC"; 
GraphicsBox[{CircleBox[{0, 0}], 
     InsetBox[StyleBox[QWE, FontSize -> 30], {0.5, 0}]}, 
    ImageSize -> 200] // BoxData // Cell // CellPrint

GraphicsBox[{CircleBox[{0, 0}], 
     InsetBox[StyleBox["ABC", FontSize -> 30], {0.5, 0}]}, 
    ImageSize -> 200] // BoxData // Cell // CellPrint

GraphicsBox[{CircleBox[{0, 0}], 
   InsetBox[StyleBox[ToString[ABC], FontSize -> 30], {0.5, 0}]}, 
  ImageSize -> 200] // BoxData // Cell // CellPrint

Above are 4 codes.
1st, 2nd, 3rd works but 4th codes not works as expected.
I don't know why 4th-code made an error.

Also, can you construct function SomeExcellentFunction, so that

GraphicsBox[{CircleBox[{0, 0}], 
       InsetBox[StyleBox[SomeExcellentFunction[ABC], FontSize -> 30], {0.5, 0}]}, 
      ImageSize -> 200] // BoxData // Cell // CellPrint

works correctly ?

I add a screenshot for 1st to 4th code, in order.

enter image description here

enter image description here

enter image description here

enter image description here

+-+-+-+ added -+-+-+-+-+-+-+-

You can further try

GraphicsBox[{CircleBox[{0, 0}], 
     InsetBox[StyleBox[Identity["ABC"], FontSize -> 30], {0.5, 0}]}, 
    ImageSize -> 200] // BoxData // Cell // CellPrint

It doesn't works surprisingly.
An exceptional phenomenon for Identity.

$\endgroup$
2
  • 2
    $\begingroup$ It's probably best to post answers in the answers section, not the question body. IMO. $\endgroup$
    – Michael E2
    Commented May 25, 2023 at 4:13
  • $\begingroup$ The help says that "StyleBox" takes boxes as input. But you give a string. $\endgroup$ Commented May 25, 2023 at 8:02

1 Answer 1

1
$\begingroup$

So far I've used RowBox, GridBox, AdjustmentBox mostly.

But

{RowBox, GridBox, AdjustmentBox, GraphicsBox, InsetBox} // 
  Attributes // TableForm[#, TableDepth -> 1] &

gives

{Protected}
{Protected,ReadProtected}
{Protected,ReadProtected}
{HoldAll,Protected,ReadProtected}
{HoldAll,Protected,ReadProtected}

Unlike RowBox, GridBox, AdjustmentBox, check that GraphicsBox, InsetBox has HoldAll attribute.

It seems that I can temporarily remove that attribute.

Finally I found the solution on my own. The solution is

graphicsbox[x__]:=GraphicsBox[x]  
insetbox[x__]:=InsetBox[x]

Then, use graphicsbox and insetbox instead of GraphicsBox and InsetBox.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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