Suppose I want to display some expression, say foo[p1_,p2_], as a point in a circle.

I can achieve this using MakeBoxes, like in the following:

foo /: MakeBoxes[foo[p1_, p2_], fmt_] := 
 GraphicsBox[{CircleBox[{0, 0}], [email protected], PointBox[{p1, p2}]}, 
  ImageSize -> 70]

which produces the desired result:

enter image description here

However, a problem arises when I use ??foo:

enter image description here

As you can see, Mathematica is also issuing MakeBoxes on the foo[p1_,p2_] that should appear in the informations. Infact, the problem can be traced back to the fact that also the expression


triggers the MakeBoxes evaluation.

How can this problem be avoided?

PS: apologies for the not-much-informative title, please change it if you find a better way to describe the question.

  • 2
    $\begingroup$ Why not restrict the argument, since the display will only make sense for those arguments: MakeBoxes[foo[p1_?NumberQ, p2_?NumberQ], fmt_]? $\endgroup$ Commented Feb 27, 2016 at 1:35

1 Answer 1


I concur with the answer J.M. gave in a comment to the question, but would limit evaluation by a condition that constrain the coordinates given to lie on or within the unit circle.

foo /: MakeBoxes[foo[p1_, p2_] /; Norm[{p1, p2}] <= 1, form_] := 
  GraphicsBox[{CircleBox[{0, 0}], PointSize @ .08, PointBox[{p1, p2}]}, 
  ImageSize -> 70]

Testing with points along the ray through {1, 1}

foo[#, #] & /@ Range[0, 1, .5]


Testing with points lying on the circle.

foo @@@ N[CirclePoints[5]]





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.